mcp-google

by Ejb503
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables AI agents to read, send, manage drafts and attachments, search and filter emails, and handle email threads through MCP commands

  • Allows AI agents to create and manage events, handle event invitations, search and filter calendar events, and manage multiple calendars through MCP commands

  • Provides read-only access to Google Drive content through MCP, allowing AI agents to interact with files and documents

systemprompt-mcp-google

网站|文档|博客

一个专用的模型上下文协议 (MCP) 服务器,可将 Google 服务(Gmail、Google 日历等)集成到您的 AI 工作流程中。该服务器支持通过 MCP 无缝访问 Google 服务,从而使 AI 代理能够与 Gmail、Google 日历和其他 Google 服务进行交互。

演示

YouTube 演示

先决条件

在使用此服务器之前,您需要:

  1. Systemprompt API 密钥(免费):
  2. 与 MCP 兼容的客户端,例如:
  3. Google Cloud 项目设置:
    • Google Cloud 帐户
    • 为所需服务(Gmail、日历等)启用 API 访问
    • OAuth2 凭据已配置

设置

1. Google Cloud 设置

  1. Google Cloud Console中创建项目
  2. 启用您需要的 API:
    • Gmail API(阅读、发送、撰写、修改、标签)
    • Google 日历 API(读取事件)
    • Google Drive API(只读)
  3. 创建 OAuth2 凭证:
    • 前往“API 和服务”>“凭证”
    • 创建 OAuth 2.0 客户端 ID
    • 设置授权重定向 URI(包括http://localhost:3333/oauth2callback
    • 下载凭据 JSON 文件并将其保存为credentials/google-credentials.json

2.服务器配置

  1. 安装软件包:
npm install systemprompt-mcp-google
  1. 创建凭证目录:
mkdir -p credentials
  1. 运行身份验证脚本:
npm run auth-google

这将:

  • 打开默认浏览器进行 Google OAuth 身份验证
  • 在端口 3333 上启动本地服务器来处理 OAuth 回调
  • 生成令牌并将其保存到credentials/google-token.json
  • 身份验证完成后自动关闭

该脚本将请求以下权限:

  • Gmail:阅读、发送、撰写、修改和管理标签
  • 日历:读取事件和日历
  • 驱动器:只读访问

3. MCP 客户端设置

选择您首选的 MCP 客户端:

使用 Systemprompt MCP 客户端

  1. 按照安装说明安装并配置客户端
  2. 在客户端的 MCP 配置中,添加此服务器:
{ "servers": { "google": { "type": "stdio", "command": "SYSTEMPROMPT_API_KEY=your_api_key npx systemprompt-mcp-google" } } }

注意:将your_api_key替换为来自systemprompt.io/console的实际 Systemprompt API 密钥。

使用 Claude Desktop

  1. 安装 Claude Desktop
  2. 使用 API 密钥在 Claude 的 MCP 配置部分中添加此服务器:
    { "command": "SYSTEMPROMPT_API_KEY=your_api_key npx systemprompt-mcp-google" }
  3. 配置连接以使用 stdio 模式

特征

Google 服务集成

  • Gmail 集成
    • 通过 MCP 命令阅读和发送电子邮件
    • 管理草稿和附件
    • 搜索和过滤电子邮件
    • 处理电子邮件线程
  • 日历集成
    • 通过 MCP 命令创建和管理事件
    • 处理活动邀请
    • 搜索和过滤日历事件
    • 管理多个日历

MCP 集成

  • 标准 MCP 接口
    • 与任何符合 MCP 标准的客户端兼容
    • 结构化命令响应
    • 错误处理和状态报告
    • 会话管理

安全与身份验证

  • 安全 OAuth2 身份验证流程
  • 自动令牌刷新
  • 不同服务的范围访问
  • 基于环境的配置

开发特性

  • 全面支持 TypeScript
  • 全面的错误处理
  • 广泛的测试覆盖范围
  • MCP兼容接口

配置

  1. 设置 Google Cloud 项目和 OAuth2 凭据:
    • Google Cloud Console中创建项目
    • 启用 Gmail 和日历 API
    • 创建 OAuth2 凭据
    • 下载凭证文件
  2. 配置环境变量:
GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret GOOGLE_REDIRECT_URI=your_redirect_uri
  1. 运行身份验证脚本:
npm run auth-google

用法

通过 MCP 客户端

配置完成后,您可以使用任何 MCP 客户端向此服务器发送命令。示例交互:

Gmail操作

// Example MCP command structure for sending an email { "command": "gmail.sendEmail", "parameters": { "to": "recipient@example.com", "subject": "Hello from MCP", "body": "This email was sent via MCP!" } } // Example MCP command for listing messages { "command": "gmail.listMessages", "parameters": { "maxResults": 10 } }

日历操作

// Example MCP command for creating an event { "command": "calendar.createEvent", "parameters": { "summary": "Team Meeting", "start": "2024-03-01T10:00:00", "end": "2024-03-01T11:00:00", "attendees": ["team@company.com"] } } // Example MCP command for listing events { "command": "calendar.listEvents", "parameters": { "timeMin": "2024-03-01T00:00:00Z", "maxResults": 10 } }

测试

该项目包括针对 MCP 协议处理和 Google 服务集成的全面测试:

# Run all tests npm test # Watch mode for development npm run test:watch # Generate coverage report npm run test:coverage

调试 MCP 通信

由于 MCP 服务器通过 stdio 进行通信,因此调试需要特别注意:

  1. 使用 MCP 检查器:
npm run inspector
  1. 启用调试日志记录:
# Set environment variable DEBUG=mcp:* npm run dev
  1. 使用提供的测试客户端:
npm run test:client

执照

麻省理工学院

相关项目

发展

本地开发设置

  1. 克隆存储库:
git clone https://github.com/yourusername/systemprompt-mcp-google.git cd systemprompt-mcp-google
  1. 安装依赖项:
npm install
  1. 设置环境变量:
# Copy example environment file cp .env.example .env # Edit .env and add: SYSTEMPROMPT_API_KEY=your_api_key # Required - get from systemprompt.io/console
  1. 设置 Google 凭据:
  • 将您的 Google OAuth 凭据保存为credentials/google-credentials.json
  • 运行npm run auth-google来通过 Google 进行身份验证
  1. 启动开发服务器:
npm run dev
-
security - not tested
F
license - not found
-
quality - not tested

一个专用的模型上下文协议 (MCP) 服务器,可将 Google 服务(Gmail、Google 日历等)集成到您的 AI 工作流程中。该服务器支持通过 MCP 无缝访问 Google 服务,从而使 AI 代理能够与 Gmail、Google 日历和其他 Google 服务进行交互。

  1. Demo
    1. Prerequisites
      1. Setup
        1. 1. Google Cloud Setup
        2. 2. Server Configuration
        3. 3. MCP Client Setup
      2. Features
        1. Google Service Integration
        2. MCP Integration
        3. Security & Authentication
        4. Development Features
        5. Configuration
      3. Usage
        1. Through MCP Client
        2. Testing
        3. Debugging MCP Communication
      4. License
        1. Related Projects
          1. Development
            1. Local Development Setup
          ID: 0ixu86x2zs