MCP G套件服务器添加福利群:解决AI开发者的「MCP实战痛点」
一个用于与Google产品交互的MCP服务器。
目前,这个MCP服务器支持Gmail和日历集成,并具备以下功能:
您可以尝试的示例提示:
获取我最新的未读消息
搜索Scrum Master发给我的邮件
获取会计部门的所有邮件
提取关于ABC的邮件并总结内容
给Alice的最后一封邮件写一个得体的回复并保存为草稿
用感谢语回复Bob的邮件并保存为草稿
我明天有哪些安排?
查看我个人账户下周的家庭日程
我需要下周和Tim安排一个2小时的活动,建议几个时间段
要通过Smithery自动为Claude Desktop安装mcp-gsuite:
npx -y @smithery/cli install mcp-gsuite --client claude
Google Workspace(G Suite)API需要OAuth2授权。请按照以下步骤设置认证:
创建OAuth2凭证:
http://localhost:4100/code)所需的OAuth2范围:
[
"openid",
"https://mail.google.com/",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/userinfo.email"
]

.gauth.json文件,包含客户端信息{
"web": {
"client_id": "$your_client_id",
"client_secret": "$your_client_secret",
"redirect_uris": ["http://localhost:4100/code"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}

.accounts.json文件,包含账户信息{
"accounts": [
{
"email": "alice@bob.com",
"account_type": "personal",
"extra_info": "你想告诉Claude的附加信息:例如'包含家庭日历'"
}
]
}

您可以指定多个账户。确保它们在您的Google认证应用中有访问权限。extra_info字段特别有用,您可以在这里添加您想让AI了解的关于账户的信息(例如它是否有特定的日程)
注意:当您第一次为特定账户执行某个工具时,会打开一个浏览器,重定向到Google并要求您的凭证、范围等信息。登录成功后,它会将凭证存储在一个名为.oauth.{email}.json的本地文件中。授权后,将使用刷新令牌。
在MacOS上:~/Library/Application\ Support/Claude/claude_desktop_config.json
在Windows上:%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-gsuite": {
"command": "uv",
"args": [
"--directory",
"<dir_to>/mcp-gsuite",
"run",
"mcp-gsuite"
]
}
}
}

注意:您还可以使用uv run mcp-gsuite --accounts-file /path/to/custom/.accounts.json指定不同的账户文件,或使用--credentials-dir /path/to/custom/credentials指定不同的凭证目录。
{
"mcpServers": {
"mcp-gsuite": {
"command": "uv",
"args": [
"--directory",
"<dir_to>/mcp-gsuite",
"run",
"mcp-gsuite",
"--accounts-file",
"/path/to/custom/.accounts.json",
"--credentials-dir",
"/path/to/custom/credentials"
]
}
}
}

{
"mcpServers": {
"mcp-gsuite": {
"command": "uvx",
"args": [
"mcp-gsuite",
"--accounts-file",
"/path/to/custom/.accounts.json",
"--credentials-dir",
"/path/to/custom/credentials"
]
}
}
}

MCP服务器可以通过几个命令行选项进行配置,以指定认证和账户信息的自定义路径:
--gauth-file:指定包含OAuth2客户端配置的.gauth.json文件的路径。默认为./.gauth.json。--accounts-file:指定包含Google账户信息的.accounts.json文件的路径。默认为./.accounts.json。--credentials-dir:指定成功认证后存储OAuth凭证的目录。默认为当前工作目录,每个账户有一个子目录,命名为.oauth.{email}.json。这些选项允许灵活管理不同的环境或多个凭证和账户集,特别适用于开发和测试场景。
使用示例:
uv run mcp-gsuite --gauth-file /path/to/custom/.gauth.json --accounts-file /path/to/custom/.accounts.json --credentials-dir /path/to/custom/credentials
当您有多个服务器实例运行不同配置,或者部署到默认路径不适合的环境时,此配置特别有用。
要准备包进行分发:
uv sync

uv build
这将在dist/目录中创建源代码和wheel分发版。
uv publish
注意:您需要通过环境变量或命令行标志设置PyPI凭证:
--token或UV_PUBLISH_TOKEN--username/UV_PUBLISH_USERNAME和--password/UV_PUBLISH_PASSWORD由于MCP服务器通过stdio运行,调试可能具有挑战性。为了获得最佳调试体验,我们强烈建议使用MCP Inspector。
您可以通过npm使用以下命令启动MCP Inspector:
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-gsuite run mcp-gsuite
启动后,Inspector将显示一个URL,您可以在浏览器中访问该URL开始调试。
您还可以使用以下命令查看服务器日志:
tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-gsuite.log
