mcp-server-google-workspace
Enables Gmail, Google Calendar, and Google Drive access through the Model Context Protocol, supporting email management, event scheduling, and file operations.
README
MCP Server - Google Workspace
A Model Context Protocol (MCP) server for Google Workspace integration, providing tools for Gmail, Google Calendar, and Google Drive access.
Features
- 🔐 Simple Authentication: Environment variable based credentials
- 📧 Gmail: List, read, search, and send emails
- 📅 Calendar: List calendars (including shared), list and create events in any accessible calendar
- 📁 Drive: File management (coming soon)
- 🔄 Auto Token Refresh: Automatic OAuth token refresh
- 🏢 Multi-User Support: Host applications can decrypt and inject user-specific credentials
- 🤝 Shared Calendar Support: Access and manage events in calendars shared with you
Installation
For Individual Use
npm install mcp-server-google-workspace
# or
pnpm add mcp-server-google-workspace
For Development
git clone <repo-url>
cd mcp-server-google-workspace
pnpm install
pnpm build
Authentication
The MCP server reads Google OAuth credentials from environment variables:
# .env
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REFRESH_TOKEN=your_refresh_token
GOOGLE_ACCESS_TOKEN=your_access_token # optional
Multi-User Platforms
For platforms serving multiple users, the host application should:
- Fetch encrypted credentials from database
- Decrypt credentials (e.g., using AWS KMS)
- Pass decrypted credentials as environment variables when starting the MCP server
This keeps the MCP server simple and delegates credential management to the host application.
Available Tools
Gmail Tools
gmail_list_emails
List recent emails from Gmail inbox.
Parameters:
hours(number, optional): Hours to look back (default: 24)maxResults(number, optional): Max emails to return (default: 50)query(string, optional): Gmail search query
Example:
{
"hours": 168,
"maxResults": 50,
"query": "from:boss@company.com"
}
gmail_read_email
Read full content of a specific email.
Parameters:
emailId(string, required): Gmail message ID
gmail_search_emails
Search emails with Gmail query syntax.
Parameters:
query(string, required): Search querymaxResults(number, optional): Max results (default: 50)
Query Examples:
"from:user@example.com subject:meeting""has:attachment after:2025/11/01""is:unread label:important"
Calendar Tools
calendar_list_calendars
List all accessible calendars, including shared calendars.
Parameters:
showHidden(boolean, optional): Include hidden calendars (default: false)minAccessRole(string, optional): Minimum access role filter (freeBusyReader, reader, writer, owner)
Example:
{
"showHidden": false,
"minAccessRole": "reader"
}
Response:
Returns a list of calendars with their IDs, names, access roles, and other metadata. Use the calendar id field for other calendar operations.
calendar_list_events
List calendar events for a date range. Returns events with timezone information.
Parameters:
calendarId(string, optional): Calendar ID (default: 'primary'). Usecalendar_list_calendarsto get IDs of shared calendars.date(string, optional): Start date (YYYY-MM-DD), default: todaydays(number, optional): Number of days (default: 1)maxResults(number, optional): Max events (default: 50)
Response:
Each event includes startTimeZone and endTimeZone fields, making it easy to handle events across different timezones (e.g., ET vs UTC).
calendar_create_event
Create a new calendar event with proper timezone support.
Parameters:
calendarId(string, optional): Calendar ID (default: 'primary'). Usecalendar_list_calendarsto get IDs of shared calendars.summary(string, required): Event titlestart(string, required): Start time (ISO 8601)end(string, required): End time (ISO 8601)timeZone(string, optional): IANA timezone (e.g., "America/New_York", "America/Los_Angeles", "UTC"). If not specified, uses the calendar's default timezone.description(string, optional): Event descriptionlocation(string, optional): Event locationattendees(array, optional): Attendee emails
Examples:
Creating event in EST timezone:
{
"calendarId": "primary",
"summary": "Team Meeting",
"start": "2025-11-02T10:00:00",
"end": "2025-11-02T11:00:00",
"timeZone": "America/New_York",
"description": "Quarterly review",
"attendees": ["team@company.com"]
}
Creating event in UTC (default if not specified):
{
"summary": "Team Meeting",
"start": "2025-11-02T15:00:00Z",
"end": "2025-11-02T16:00:00Z"
}
Usage
With Claude Desktop
Add to your Claude Desktop configuration:
{
"mcpServers": {
"google-workspace": {
"command": "npx",
"args": ["-y", "mcp-server-google-workspace"],
"env": {
"GOOGLE_CLIENT_ID": "your_client_id",
"GOOGLE_CLIENT_SECRET": "your_client_secret",
"GOOGLE_REFRESH_TOKEN": "your_refresh_token"
}
}
}
}
Programmatic Usage (e.g., with Claude Agent SDK)
For multi-user platforms, decrypt credentials and inject them when starting the server:
import { Agent } from '@anthropic-ai/claude-agent-sdk';
// Your backend decrypts credentials from database
const credentials = await decryptUserCredentials(userId);
const agent = new Agent({
mcpServers: [{
command: 'node',
args: ['path/to/mcp-server-google-workspace/dist/index.js'],
env: {
GOOGLE_CLIENT_ID: credentials.clientId,
GOOGLE_CLIENT_SECRET: credentials.clientSecret,
GOOGLE_REFRESH_TOKEN: credentials.refreshToken,
}
}]
});
Development
# Install dependencies
pnpm install
# Build
pnpm build
# Watch mode
pnpm watch
# Run locally
pnpm dev
Testing
With MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.js
With Environment Variables
cp .env.example .env
# Edit .env with your credentials
pnpm dev
OAuth Setup
To get Google OAuth credentials:
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Gmail API and Google Calendar API
- Create OAuth 2.0 credentials
- Add authorized redirect URI
- Get client ID and client secret
- Use OAuth playground to get refresh token
Contributing
Contributions welcome! Please feel free to submit a Pull Request.
License
MIT
Author
iskifogl
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。