Google Calendar MCP Server

Google Calendar MCP Server

Enables management of multiple Google Calendar accounts with support for searching, creating, updating, and deleting events on primary calendars through natural language, with encrypted credential storage.

Category
访问服务器

README

@ideadesignmedia/gcal-mcp

Private MCP server (stdio) and CLI for linking and operating multiple Google Calendar accounts. It stores tokens in a local SQLite database and can encrypt refresh tokens at rest with a user password.

The server speaks MCP over stdio and keeps stdout clean (JSON‑RPC only); all human‑readable logs go to stderr.

Requirements

  • Node.js >= 18.17
  • A Google Cloud OAuth client (Web application) with Calendar API enabled
    • You will need GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

One‑liner (npx)

Use npx to run without installing globally. The package name is @ideadesignmedia/gcal-mcp and the binary is gcal-mcp.

# Help
npx -y @ideadesignmedia/gcal-mcp --help

# Link an account (prints an authorization URL)
npx -y @ideadesignmedia/gcal-mcp add \
  --client-id "$GOOGLE_CLIENT_ID" \
  --client-secret "$GOOGLE_CLIENT_SECRET"

# Lock the database (encrypts existing refresh tokens)
npx -y @ideadesignmedia/gcal-mcp passwd --pass 'your-strong-pass'

# Start the MCP server over stdio (stdout is JSON only)
GMAIL_MCP_DB_PASS='your-strong-pass' \
  npx -y @ideadesignmedia/gcal-mcp start

Database

  • Default location: ~/.idm/gcal-mcp/db.sqlite
  • Override with --db <path> on any command
  • When locked, refresh tokens are encrypted with AES‑GCM using a DEK derived from your password via scrypt

Global Flags

  • --db <path>: SQLite database path (defaults above)
  • --pass <pass>: Database password (where applicable). For start, consider GMAIL_MCP_DB_PASS instead.
  • --read-only: Start server with write tools disabled (create/update/delete)

Environment variables:

  • GMAIL_MCP_DB_PASS: Password used by start (and as a fallback elsewhere)
  • GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET: OAuth credentials (used by add if flags not supplied)

Commands

  • start

    • Starts the MCP server over stdio
    • Respects --read-only
    • Stdout: JSON‑RPC messages only; logs to stderr
    • Examples:
      • GMAIL_MCP_DB_PASS='...' npx -y @ideadesignmedia/gcal-mcp start
  • add

    • Links a Google account and stores its refresh token
    • Options:
      • --client-id <id> / --client-secret <secret> (or use env vars)
      • --device for Device Code flow (headless), otherwise uses loopback redirect and prints a URL to visit (default port 43112; change with --listen-port <port>)
      • --scopes <list> to provide custom scopes (comma or space separated)
      • --choose-scopes to interactively select calendar access (read-only vs read/write) and optionally add extra scopes
    • Example:
      • npx -y @ideadesignmedia/gcal-mcp add --client-id $GOOGLE_CLIENT_ID --client-secret $GOOGLE_CLIENT_SECRET
      • npx -y @ideadesignmedia/gcal-mcp add --choose-scopes --client-id $GOOGLE_CLIENT_ID --client-secret $GOOGLE_CLIENT_SECRET
  • list

    • Lists linked accounts (id, email, display name, created)
  • remove <key>

    • Removes an account and its tokens by id or email
  • passwd

    • Locks the database or rotates an existing password
    • Options:
      • --pass <pass>: Password to set when locking, or new password when rotating
      • --rotate: Rotate the existing password (requires --old-pass)
      • --old-pass <old>: Old password for rotation
      • --hint <text>: Optional password hint stored alongside the KDF parameters

MCP Server Integration

Any MCP‑capable client can launch this server as a stdio process. A generic config entry looks like:

{
  "mcpServers": {
    "gcal-mcp": {
      "command": "npx",
      "args": ["-y", "@ideadesignmedia/gcal-mcp", "start"],
      "env": {
        "GMAIL_MCP_DB_PASS": "${secret:GCAL_DB_PASS}",
        "GOOGLE_CLIENT_ID": "${env:GOOGLE_CLIENT_ID}",
        "GOOGLE_CLIENT_SECRET": "${env:GOOGLE_CLIENT_SECRET}"
      }
    }
  }
}

Notes:

  • The start command writes only JSON‑RPC to stdout as required by MCP stdio.
  • Use your client’s secret storage for GMAIL_MCP_DB_PASS where available.

Provided Tools

The server exposes the following tools. Names and parameter schemas follow the Chat Completions function tool shape.

Primary calendar only:

  • All operations target the account’s primary calendar automatically; there is no calendarId parameter.
    • This removes confusion between account vs calendar. The server passes primary internally.

Account resolution rules (applies wherever account is accepted):

  • Accepts exact email or id.

  • Also accepts a partial, case-insensitive match on email or display name.

  • If account is omitted and exactly one account is linked, that account is used.

  • If multiple accounts would match or are linked with no account provided, the tool throws a helpful error. Use gcal-list_accounts to choose deterministically.

  • gcal-list_accounts

    • Parameters: none
    • Returns: { accounts: Array<{ id: string, email: string, displayName: string | null }> }
  • gcal-resolve_account

    • Parameters:
      • query (string; optional; email/id or partial). If omitted or blank, returns all accounts.
    • Returns: { query: string, matches: Array<{ id: string, email: string, displayName: string | null }>, exact: boolean, ambiguous: boolean, count: number }
  • gcal-search_events

    • Parameters:
      • account (string; optional)
      • q (string, optional)
      • timeMin (ISO string, optional)
      • timeMax (ISO string, optional)
      • maxResults (integer 1..250, optional)
    • Returns: { events: GoogleCalendarEvent[] } (verbatim event objects)
  • gcal-get_event

    • Parameters:
      • account (string; optional)
      • eventId (string)
    • Returns: GoogleCalendarEvent
  • gcal-create_event

    • Parameters:
      • account (string; optional)
      • summary (string)
      • description (string, optional)
      • location (string, optional)
      • start (object: { dateTime?: string, date?: string, timeZone?: string })
      • end (object: { dateTime?: string, date?: string, timeZone?: string })
      • attendees (array of { email: string }, optional)
    • Returns: GoogleCalendarEvent
  • gcal-update_event

    • Parameters:
      • account (string; optional)
      • eventId (string)
      • patch (object; partial event resource)
    • Returns: GoogleCalendarEvent
  • gcal-delete_event

    • Parameters:
      • account (string; optional)
      • eventId (string)
    • Returns: { ok: true } on success

Read‑only mode:

  • Start with --read-only to disable gcal-create_event, gcal-update_event, and gcal-delete_event.

OAuth Flows

  • Default: Loopback flow. The CLI opens your browser to grant access and listens on 127.0.0.1:43112 for the redirect (customizable via --listen-port).
  • Headless: Device Code flow with --device. The CLI prints a code and verification URL to the terminal.
  • Scopes used: https://www.googleapis.com/auth/calendar, plus openid email profile to capture account identity.

Security Notes

  • When locked, refresh tokens are encrypted at rest (AES‑GCM). The key is derived with scrypt using per‑DB salt and stored KDF parameters.
  • The MCP start command emits no human‑readable output on stdout.
  • Prefer setting GMAIL_MCP_DB_PASS via your MCP client’s secret system; avoid committing secrets in configs.

Troubleshooting

  • Database is locked

    • Set GMAIL_MCP_DB_PASS or pass --pass when needed. For start, use the env var.
  • OAuth did not return a refresh_token

    • Ensure you used the provided add command (it requests offline access with consent). If you previously granted access without offline permission, remove prior consent in your Google Account or create a new OAuth client.
  • Loopback callback failed

    • Check firewall or try --device for Device Code flow.
  • MCP client shows parse errors

    • Verify you are launching the server with start and not another command. STDOUT must remain clean JSON‑RPC.

MIT © Idea Design Media

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选