Gmail MCP 服务器
基于 MCP 框架的 Gmail 集成服务器,提供读取、发送和管理邮件的功能。
快速入门
前置条件
- 安装 Python 3.12 或更高版本。
- 创建 Google Cloud 项目并启用 Gmail API。
- 下载 OAuth 2.0 凭据文件并命名为
client_secret.json
。
安装步骤
- 克隆仓库:
git clone
cd gmail-mcp-server - 创建虚拟环境并激活:
python -m venv venv
Windows: venv\Scripts\activate
Unix/MacOS: source venv/bin/activate
- 安装依赖: pip install .
配置
- 在
gmail_token_creator.py
中设置邮箱标识符。 - 运行以下命令以生成令牌: python gmail_token_creator.py
启动服务器
运行以下命令启动服务: python gmail_server.py
使用示例
- 发送邮件: await send_gmail(email_identifier="your.email@gmail.com", to="recipient@example.com", subject="Test", body="Content")
- 搜索邮件: await search_email_tool(email_identifier="your.email@gmail.com", query="from:someone@example.com")
- 读取最新邮件: await read_latest_emails(email_identifier="your.email@gmail.com", max_results=5)
更多详细信息请参考 README。