
jasonsum/gmail-mcp-server 是从 https://github.com/jasonsum/gmail-mcp-server. 导入的 MCP 服务器候选
概览
jasonsum/gmail-mcp-server 是从 https://github.com/jasonsum/gmail-mcp-server. 导入的 MCP 服务器候选
概述(AI 翻译)
该MCP服务器与Gmail集成,支持发送、删除、阅读、起草和回复邮件。
注:该服务器使MCP客户端能够读取、删除和发送电子邮件。然而,客户端在执行此类操作前会提示用户。
https://github.com/user-attachments/assets/5794cd16-00d2-45a2-884a-8ba0c3a90c90
组成部分
工具
-
发送邮件
-
向邮箱收件人发送电子邮件
-
输入:
-
recipient_id(字符串):收件人的电子邮件地址 -
subject(字符串):邮件主题 -
message(字符串):电子邮件内容 -
退货状态与 message_id
-
垃圾邮件
-
将邮件移入垃圾桶
-
输入:
-
email_id(字符串):自动生成的电子邮件ID -
返回成功信息
-
标记邮件为已读
-
标记邮件为已读
-
输入:
-
email_id(字符串):自动生成的电子邮件ID -
返回成功信息
-
收回未读邮件
-
检索未读邮件
-
返回邮件列表,包括电子邮件地址
-
已读-邮件
-
检索给定的电子邮件内容
-
输入:
-
email_id(字符串):自动生成的电子邮件ID -
返回电子邮件元数据词典,并将邮件标记为已读
-
打开邮件
-
在浏览器中打开邮件
-
输入:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Gmail Server for Model Context Protocol (MCP)
This MCP server integrates with Gmail to enable sending, removing, reading, drafting, and responding to emails.
Note: This server enables an MCP client to read, remove, and send emails. However, the client prompts the user before conducting such activities.
https://github.com/user-attachments/assets/5794cd16-00d2-45a2-884a-8ba0c3a90c90
Components
Tools
-
send-email
- Sends email to email address recipient
- Input:
recipient_id(string): Email address of addresseesubject(string): Email subjectmessage(string): Email content
- Returns status and message_id
-
trash-email
- Moves email to trash
- Input:
email_id(string): Auto-generated ID of email
- Returns success message
-
mark-email-as-read
- Marks email as read
- Input:
email_id(string): Auto-generated ID of email
- Returns success message
-
get-unread-emails
- Retrieves unread emails
- Returns list of emails including email ID
-
read-email
- Retrieves given email content
- Input:
email_id(string): Auto-generated ID of email
- Returns dictionary of email metadata and marks email as read
-
open-email
- Open email in browser
- Input:
email_id(string): Auto-generated ID of email
- Returns success message and opens given email in default browser
Setup
Gmail API Setup
- Create a new Google Cloud project
- Enable the Gmail API
- Configure an OAuth consent screen
- Select “external”. However, we will not publish the app.
- Add your personal email address as a “Test user”.
- Add OAuth scope
https://www.googleapis.com/auth/gmail/modify - Create an OAuth Client ID for application type “Desktop App”
- Download the JSON file of your client’s OAuth keys
- Rename the key file and save it to your local machine in a secure location. Take note of the location.
- The absolute path to this file will be passed as parameter
--creds-file-pathwhen the server is started.
- The absolute path to this file will be passed as parameter
Authentication
When the server is started, an authentication flow will be launched in your system browser.
Token credentials will be subsequently saved (and later retrieved) in the absolute file path passed to parameter --token-path.
For example, you may use a dot directory in your home folder, replacing [your-home-folder].:
| Parameter | Example |
|---|---|
--creds-file-path |
/[your-home-folder]/.google/client_creds.json |
--token-path |
/[your-home-folder]/.google/app_tokens.json |
Usage with Desktop App
安装
npx @modelcontextprotocol/inspector uv run [absolute-path-to-git-repo]/src/gmail/server.py --creds-file-path [absolute-path-to-credentials-file] --token-path [absolute-path-to-access-tokens-file]配置
{
"mcpServers": {
"gdrive": {
"command": "uv",
"args": [
"--directory",
"[absolute-path-to-git-repo]",
"run",
"gmail",
"--creds-file-path",
"[absolute-path-to-credentials-file]",
"--token-path",
"[absolute-path-to-access-tokens-file]"
]
}
}
}