GCal-mcp

GCal-mcp

A stateless Google Calendar MCP proxy that uses Baserow for OAuth management, enabling multi-tenant calendar operations via SSE transport.

Category
访问服务器

README

Stateless Google Calendar MCP Proxy

This is a heavily streamlined, stateless implementation of the Google Calendar Model Context Protocol (MCP) server, designed exclusively for headless integration with orchestrators like n8n.

By aggressively adhering to the "ponytail rule" (lazy senior dev: extreme simplicity, YAGNI, no speculative complexity), all stateful components—such as SQLite databases, embedded web interfaces, complex local multi-tenancy mappings, and internal token refreshing background jobs—have been stripped out.

Instead, this server acts as a thin, highly reliable proxy between the MCP standard and the Google Calendar API, leveraging an external Baserow database as the single source of truth for Google OAuth credentials.

Architecture

  • Stateless by Design: This application does not persist any local state.
  • HTTP/SSE Transport: Instead of using standard stdio (which lacks the ability to pass per-request metadata like headers in a multi-tenant environment), this server implements the MCP StreamableHTTPServerTransport. It listens on a specified port (default 3000) for standard HTTP-based MCP connections (e.g. /sse endpoint).
  • Context Injection: When n8n makes a request to execute a tool, it MUST inject the X-Baserow-Row-Id header (and optionally X-Timezone).
  • Async Context: The Node AsyncLocalStorage safely isolates the authentication context for each incoming request, preventing race conditions.
  • Baserow Auth Engine: Before a tool accesses Google Calendar, the handler fetches the X-Baserow-Row-Id from the context, securely pulls the Google OAuth credentials directly from Baserow via the REST API, instantiates a headless Google OAuth2Client, and performs the requested operation.

Prerequisites

  1. Baserow Database: A Baserow table configured with fields to store client_id, client_secret, access_token, refresh_token, and expiry_date.
  2. Environment Variables: Create a .env file containing the connection details for your Baserow instance:
    BASEROW_URL=https://api.baserow.io
    BASEROW_DATABASE_TOKEN=your_database_token_here
    BASEROW_TABLE_ID=your_table_id_here
    PORT=3000
    

Installation and Execution

# Install dependencies
npm ci

# Build the project
npm run build

# Start the server (runs on port 3000 by default)
npm start

Alternatively, use the provided Dockerfile to build and deploy to any container platform:

docker build -t gcal-mcp-stateless .
docker run -p 3000:3000 --env-file .env gcal-mcp-stateless

Integrating with n8n

When configuring the MCP node or the HTTP Client in your n8n workflow, you must connect to this server using the Server-Sent Events (SSE) / HTTP URL (e.g., http://localhost:3000/sse) and supply the following HTTP headers:

Header Required? Description
X-Baserow-Row-Id Yes The exact Row ID in your Baserow table containing the user's Google OAuth credentials.
X-Timezone No A standard IANA Timezone string (e.g., America/Los_Angeles). Defaults to UTC. Used for relative datetime calculations.

Because n8n will dynamically inject these headers for each execution based on the user running the workflow, this server seamlessly supports infinite users without requiring multi-tenancy logic.

Tools Available

This MCP server exposes the following Google Calendar tools. Note that account mapping parameters have been entirely removed; calendarId is directly passed as-is to the Google API.

  • list-calendars: Fetch calendars the authenticated user has access to.
  • list-events: Fetch events from a calendar.
  • search-events: Free-text search across a calendar.
  • get-event: Retrieve a specific event by ID.
  • create-event: Insert a new event.
  • create-events: Bulk insert multiple events.
  • update-event: Patch an existing event.
  • delete-event: Remove an event.
  • get-freebusy: Check free/busy availability.
  • get-current-time: Helpful for LLMs to understand the relative local time.
  • respond-to-event: Accept, decline, or mark tentative for invitations.

Developer Note (Ponytail Architecture)

If you are extending this server:

  1. Do not add state.
  2. Do not add caching layers for tokens; let Baserow handle the data persistence. If performance becomes an issue, implement caching at the n8n layer.
  3. Keep handlers simple. Extract data from this.getClient(), use googleapis, format the response, and return.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选