# Google Tasks MCP ![gtasks mcp logo](https://raw.githubusercontent.com/zcaceres/gtasks-mcp/main/logo.jpg) [![npm version](https://img.shields.io/npm/v/gtasks.svg)](https://www.npmjs.com/package/gtasks) [![docs](https://img.shields.io/badge/docs-gtasks.zach.dev-1A56DB.svg)](https://gtasks.zach.dev) **Manage Google Tasks lists, tasks, and subtasks from AI agents or your terminal.** A lightweight, agent-friendly MCP server (`gtasks-mcp`, supporting `stdio` and `2025-11-25` Streamable HTTP) and local CLI (`gtasks`) backed by a shared domain core and a minimal Google Tasks API v1 REST client—with safe scoped defaults, calendar due dates, 1-level subtasks, O(1) MCP Task Resources, and defense-in-depth read-only mode. Supports Node.js `>= 22` LTS and Bun. **Docs:** [gtasks.zach.dev](https://gtasks.zach.dev) · **LLM-friendly docs:** [gtasks.zach.dev/llms.txt](https://gtasks.zach.dev/llms.txt) ## What's New & Breaking Changes in v2.0.0 ### Highlights - **Three form factors over one core:** MCP `stdio` (`gtasks-mcp`), stateless MCP `2025-11-25` Streamable HTTP (`gtasks-mcp --http`), and a full local CLI (`gtasks auth|lists|tasks` with human-readable text or `--json`). - **Full Google Tasks API v1 coverage:** 13 Terminology-aligned tools covering full Task List CRUD (`@default` delete-guarded), Task CRUD, search, clear, `tasks_move` (reordering, cross-list moves, and 1-level subtasks), server-side list filters (`dueMin`, `dueMax`, `showAssigned`, `showDeleted`), `webViewLink`, and `assignmentInfo`. - **Defense-in-depth Read-Only Mode:** pass `--read-only`, set `GTASKS_READ_ONLY=true`, or log in with `gtasks auth login --read-only` (`https://www.googleapis.com/auth/tasks.readonly`) to hide mutating MCP tools and block all 8 mutations locally before any API call across MCP and CLI. - **Minimal dependency footprint:** replaced `googleapis` and `@google-cloud/local-auth` with `google-auth-library`, Zod, native `fetch`, and `@modelcontextprotocol/sdk` `1.32+`, clearing legacy Dependabot CVEs and fixing Windows/spaces-in-path credential bugs. - **Cross-vendor MCP `2025-11-25` conformance:** strict `additionalProperties: false`, flat JSON Schemas, accurate `readOnlyHint`/`destructiveHint`/`idempotentHint`/`openWorldHint` annotations, lazy auth on tool/resource calls, and O(1) Task Resources (`gtasks:///lists//tasks/`). ### Breaking Changes - **Package & binary names:** npm package is now `gtasks` (replacing legacy `@modelcontextprotocol/server-gtasks`), shipping `gtasks` (CLI, with `gtasks mcp` aliasing the MCP server) and `gtasks-mcp` (standalone MCP binary). - **Aligned MCP tool names:** legacy `list`, `search`, `create`, `update`, `delete`, `clear` are replaced by 13 namespaced tools (`tasklists_*` and `tasks_*`). The unused legacy `uri` parameter on task updates is removed. - **Scoped `tasks_list` & `tasks_search` defaults:** both now default to the `@default` task list, hide completed tasks by default (`includeCompleted: false`), and cap pages at `maxResults: 20` (pass `allLists: true` to scan every list). - **MCP Resource URIs:** changed from `gtasks:///` to `gtasks:///lists//tasks/` with Resource Template `gtasks:///lists/{taskListId}/tasks/{taskId}` for O(1) reads, and `resources/list` omits `nextCursor` on the final page (never returning `null`). - **Credential storage & auth lifecycle:** keys and tokens now default to the OS user config directory (`~/.config/gtasks-mcp/` on macOS/Linux, `%APPDATA%\gtasks-mcp\` on Windows) with `0600` permissions rather than the repo/package install directory. Authentication runs explicitly via `gtasks auth login` (never auto-launched on MCP startup). - **Runtime floor:** requires Node.js `>= 22` LTS or Bun. ## Setup & Authentication ### 1. Create Google OAuth 2.0 Desktop credentials 1. Open [Google Cloud Console](https://console.cloud.google.com/projectcreate) and create or select a project. 2. Enable the [Google Tasks API](https://console.cloud.google.com/apis/library/tasks.googleapis.com). 3. Configure the [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) (adding your Google account as a Test User if External) and add scope `https://www.googleapis.com/auth/tasks` (and/or `https://www.googleapis.com/auth/tasks.readonly` for read-only use). 4. Create an [OAuth 2.0 Client ID](https://console.cloud.google.com/apis/credentials/oauthclient) of type **Desktop app** and download the JSON keys file. 5. Save the keys file to your OS config directory (or point to it with `GTASKS_OAUTH_KEYS_PATH`, or pass inline `GTASKS_CLIENT_ID` + `GTASKS_CLIENT_SECRET`): - **macOS / Linux:** `~/.config/gtasks-mcp/gcp-oauth.keys.json` (respects `$XDG_CONFIG_HOME`) - **Windows:** `%APPDATA%\gtasks-mcp\gcp-oauth.keys.json` ### 2. Authenticate once via the CLI ```bash npx gtasks auth login ``` This runs a local `127.0.0.1` loopback OAuth 2.0 flow with PKCE (`S256`) and CSRF `state`, writing credentials with `0600` permissions to `~/.config/gtasks-mcp/credentials.json` (or `GTASKS_CREDENTIALS_PATH`). ```bash # Headless / remote terminal (prints consent URL without auto-opening browser) npx gtasks auth login --no-browser # Least-privilege read-only OAuth scope (tasks.readonly) npx gtasks auth login --read-only # Inspect configuration, Access Mode, and token status (never prints secrets) npx gtasks auth status # Revoke token (best-effort) and remove local credentials npx gtasks auth logout ``` Headless MCP servers (`gtasks-mcp` over `stdio` or `--http`) proactively refresh expired access tokens without clobbering your `refresh_token`, and never auto-launch a browser. ## Installation ### As an MCP server (`stdio`) Add to your MCP client configuration (Claude Code, Claude Desktop, Gemini CLI, Cursor, etc.): ```json { "mcpServers": { "gtasks": { "command": "npx", "args": ["-y", "gtasks", "mcp"] } } } ``` Or with Claude Code: ```bash claude mcp add gtasks -- npx -y gtasks mcp ``` ### As a Streamable HTTP MCP server (`2025-11-25`) Start the stateless Streamable HTTP server (defaults to `127.0.0.1:3000` on `POST /mcp`): ```bash npx -y gtasks mcp --http --host 127.0.0.1 --port 3000 ``` | Flag | Default | Description | |------|---------|-------------| | `--http` | *(off — uses `stdio`)* | Enable stateless MCP `2025-11-25` Streamable HTTP transport on `POST /mcp` | | `--host ` | `127.0.0.1` | Bind address (requires `--http`) | | `--port ` | `3000` | Listen port `1`–`65535` (requires `--http`) | | `--read-only` | *(off)* | Hide mutating tools from `tools/list` and refuse all mutations locally | Loopback listeners validate `Host` and `Origin` headers against loopback hosts (`403` on mismatch to block DNS rebinding). Unknown paths (including legacy `/sse`) return `404`, and non-`POST` methods on `/mcp` return `405` (`Allow: POST`). Non-loopback binds warn on `stderr` and honor `GTASKS_ALLOWED_HOSTS` / `GTASKS_ALLOWED_ORIGINS`. Connect with MCP Inspector: ```bash npx @modelcontextprotocol/inspector --url http://127.0.0.1:3000/mcp ``` ### As a local CLI (`gtasks`) ```bash npm install -g gtasks gtasks lists list gtasks tasks list --all-lists gtasks tasks create "Ship v2.0" --due 2026-06-01 --notes "Publish npm package" gtasks tasks list --json ``` ### With Docker ```bash docker build -t gtasks-mcp . # stdio mode (mount your OS config dir read-write for token refresh persistence) docker run --rm -i \ -v ~/.config/gtasks-mcp:/home/node/.config/gtasks-mcp \ gtasks-mcp # Streamable HTTP mode (put behind an authenticating reverse proxy for non-loopback use) docker run --rm -p 127.0.0.1:3000:3000 \ -v ~/.config/gtasks-mcp:/home/node/.config/gtasks-mcp \ -e GTASKS_ALLOWED_HOSTS=localhost:3000,127.0.0.1:3000 \ gtasks-mcp --http --host 0.0.0.0 --port 3000 ``` ## MCP Tools (13) All 13 tools conform to MCP `2025-11-25`, enforce `additionalProperties: false`, carry accurate `readOnlyHint`/`destructiveHint`/`idempotentHint`/`openWorldHint` annotations, and return typed errors as `isError: true`. ### Task Lists (5) | Tool | Read-Only | Destructive | Description | |------|-----------|-------------|-------------| | `tasklists_list` | Yes | No | List task lists with pagination (`maxResults` 1–100, default 20; `pageToken`) | | `tasklists_get` | Yes | No | Get details for a task list by `taskListId` (supports `@default`) | | `tasklists_create` | No | No | Create a new task list (`title` 1–1,024 chars) | | `tasklists_update` | No | No | Rename a task list (`taskListId`, `title`) | | `tasklists_delete` | No | Yes | Delete a task list (`@default` is refused locally) | ### Tasks (8) | Tool | Read-Only | Destructive | Description | |------|-----------|-------------|-------------| | `tasks_list` | Yes | No | List tasks (`@default` by default, or `taskListId`, or `allLists: true`; active tasks by default with `includeCompleted`, `showDeleted`, `showAssigned`, `dueMin`/`dueMax`, `completedMin`/`completedMax`, `updatedMin`, `maxResults`, `pageToken`) | | `tasks_get` | Yes | No | Get full details for a single task (`taskId`, optional `taskListId`), including `webViewLink` and `assignmentInfo` | | `tasks_search` | Yes | No | Case-insensitive substring search across `title` and `notes` (`query`, optional `taskListId` or `allLists`, `includeCompleted`, `maxResults`; scans up to 20 pages / 2,000 tasks per list and appends a truncation note if more remain) | | `tasks_create` | No | No | Create a task or subtask (`title`, optional `taskListId`, `notes`, calendar `due` `YYYY-MM-DD`, `parent`, `previous`) | | `tasks_update` | No | No | Partial patch update (`taskId`, optional `taskListId`, `title`, `notes`, `due`, `status`; pass `""` or `null` to clear `notes`/`due`; setting `status: "needsAction"` clears `completed`) | | `tasks_move` | No | No | Reorder a task, nest under `parent`, position after `previous`, or move across lists via `destinationTasklist` | | `tasks_delete` | No | Yes | Permanently delete a task (`taskId`, optional `taskListId`) | | `tasks_clear` | No | Yes | Clear all completed tasks from a task list (optional `taskListId`, default `@default`) | ## MCP Resources - **Resource URI:** `gtasks:///lists//tasks/` - **Resource Template:** `gtasks:///lists/{taskListId}/tasks/{taskId}` - **`resources/list`:** enumerates active tasks across all task lists (default page size `20`) using an opaque composite cursor and omits `nextCursor` on the final page. - **`resources/read`:** fetches the addressed task in O(1) with a single Google Tasks API call. ## Read-Only Mode Enable defense-in-depth read-only mode in any of three ways: 1. **Startup / CLI flag:** `gtasks-mcp --read-only`, `gtasks-mcp --http --read-only`, or `gtasks tasks create "Foo" --read-only` 2. **Environment variable:** `GTASKS_READ_ONLY=true` (strict boolean: `true`/`1`/`false`/`0`; any other value fails fast) 3. **Read-only OAuth scope:** `gtasks auth login --read-only` requests `https://www.googleapis.com/auth/tasks.readonly` only; stored credentials with `tasks.readonly` automatically enforce read-only mode even if `GTASKS_READ_ONLY` is unset. How enforcement works: - When `gtasks-mcp` is started with `--read-only` or `GTASKS_READ_ONLY=true`, `tools/list` advertises only the 5 read-only tools (`tasklists_list`, `tasklists_get`, `tasks_list`, `tasks_get`, `tasks_search`) plus MCP Resources (keeping `tools/list` independent of disk credentials). - At execution time—under `--read-only`, `GTASKS_READ_ONLY=true`, or stored `tasks.readonly`-only credentials—any of the 8 mutating operations across MCP (`stdio` / `--http`) and the `gtasks` CLI is **refused locally before any Google Tasks API request is made**. ## CLI Usage (`gtasks`) ```text gtasks [subcommand] [options] ``` | Command | Description | |---------|-------------| | `mcp [--http [--host ] [--port ]] [--read-only]` | Start the MCP server (`stdio` or Streamable HTTP; alias for `gtasks-mcp`) | | `auth login [--no-browser] [--read-only] [--json]` | Run loopback OAuth 2.0 login and persist `0600` credentials | | `auth status [--read-only] [--json]` | Show OAuth config, effective Access Mode, and token expiry status | | `auth logout [--json]` | Best-effort revoke token and remove local credentials | | `lists list\|get\|create\|update\|delete` | Manage Google Task Lists (`--max-results`, `--page-token`, `--read-only`, `--json`) | | `tasks list\|get\|search\|create\|update\|move\|delete\|clear` | Manage Tasks & subtasks (`--list`, `--all-lists`, `--include-completed`, `--due`, `--notes`, `--clear-notes`, `--clear-due`, `--parent`, `--previous`, `--destination-list`, `--read-only`, `--json`) | All errors are redacted and written to `stderr` with exit code `1`. ## Environment Variables | Variable | Description | |----------|-------------| | `GTASKS_CLIENT_ID` & `GTASKS_CLIENT_SECRET` | Inline Google OAuth 2.0 Desktop client credentials (highest precedence; both must be non-empty if either is set) | | `GTASKS_OAUTH_KEYS_PATH` | Explicit path to `gcp-oauth.keys.json` (fails explicitly if missing or malformed; overrides OS config dir) | | `GTASKS_CREDENTIALS_PATH` | Explicit path to stored OAuth `credentials.json` (overrides OS config dir) | | `GTASKS_READ_ONLY` | Strict boolean (`true`/`1`/`false`/`0`) enabling read-only mode; fails fast on invalid values | | `GTASKS_ALLOWED_HOSTS` | Comma-separated allowed `Host` values for non-loopback `--http` deployments | | `GTASKS_ALLOWED_ORIGINS` | Comma-separated allowed `Origin` values for non-loopback `--http` deployments | | `GTASKS_API_BASE_URL` | Optional Google Tasks API base URL override (restricted to `https://` or loopback `http://127.0.0.1` / `http://localhost` for offline replay testing) | ## Security & Reliability - **Credential Hygiene:** Stored credentials are written atomically with owner-only `0600` permissions (in `0700` parent dirs), token refresh merges onto existing credentials without clobbering `refresh_token`, and all tokens/client secrets/bearer headers are redacted from errors, CLI output, and MCP responses. - **No Surprises on Startup:** Headless MCP servers never open a browser and keep `stdio` `stdout` strictly JSON-RPC clean. - **Local Safety Guards:** `@default` task list deletion is blocked locally, read-only mode refuses all 8 mutations locally before calling the API, and Streamable HTTP blocks DNS-rebinding `Host`/`Origin` mismatches with `403`. - **Predictable Network Calls:** Direct single-attempt REST v1 calls over native `fetch` with a `30s` timeout and strict Zod response validation. ## Development ```bash bun install bun run lint # Biome lint & formatting check bun run typecheck # TypeScript typecheck bun run build # Build dist/index.js and dist/cli.js bun test # Unit, integration, MCP conformance & scenario tests bun run harness # Interactive DD harness (type help) bun run harness run scenarios # Replay all DD harness scenarios bun run verify:replay # 3-form-factor offline replay against built dist/ binaries bun run verify:live # On-demand live Google Tasks check (uses & deletes a temp list) ``` ## More MCP & CLI Projects - **[fetch-mcp](https://fetch.zach.dev)** — SSRF-hardened MCP server and CLI for fetching public web pages and YouTube transcripts. - **[markdownify-mcp](https://markdownify.zach.dev)** — Convert PDFs, Office docs, images, audio, web pages, and Git repositories into clean Markdown over MCP or the CLI. - **[spotify-cli](https://spotify-cli.zach.dev)** — Control Spotify playback, search tracks, and manage playlists from your AI agent or terminal. - **[builtwith-mcp](https://builtwith.zach.dev)** — Query website technology stacks via BuiltWith over MCP or the CLI. ## License This project is licensed under the MIT License.