目前,此MCP服务器支持Gmail和日历集成,具有以下功能:
您可以尝试的示例提示:
检索我最新的未读邮件
从Scrum Master那里搜索我的邮件
检索来自会计的所有邮件
查看关于ABC的邮件并总结它
写一封友好的回复给Alice的最后一封邮件,并上传草稿。
对Bob的邮件回复感谢信。将其保存为草稿
我明天的日程是什么?
检查我的私人账户下周的家庭日程
我需要在下周与Tim安排一个两小时的活动。建议一些时间段。
要通过Smithery自动安装mcp-gsuite到Claude Desktop:
npx -y @smithery/cli install mcp-gsuite --client claude
Google Workspace(G Suite)APIs需要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 Auth应用中有访问权限。extra_info字段特别有用,因为您可以在此处添加有关账户的信息(例如,是否具有特定日程)。
注意:当您首次执行特定账户的工具时,浏览器会打开,重定向到Google并请求您的凭据、范围等。成功登录后,它会在名为.oauth.{email}.json的本地文件中存储凭据。一旦授权,将使用刷新令牌。
在MacOS上:~/Library/Application\ Support/Claude/claude_desktop_config.json
在Windows上:%APPDATA%/Claude/claude_desktop_config.json
<details> <summary>开发/未发布的服务器配置</summary>{
"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"
]
}
}
}
</details>
<details>
<summary>已发布的服务器配置</summary>
{
"mcpServers": {
"mcp-gsuite": {
"command": "uvx",
"args": [
"mcp-gsuite",
"--accounts-file",
"/path/to/custom/.accounts.json",
"--credentials-dir",
"/path/to/custom/credentials"
]
}
}
}
</details>
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/目录中创建源和轮子分布。
uv publish
注意:您需要通过环境变量或命令标志设置PyPI凭据:
--token 或 UV_PUBLISH_TOKEN--username/UV_PUBLISH_USERNAME 和 --password/UV_PUBLISH_PASSWORD由于MCP服务器通过标准I/O运行,调试可能具有挑战性。为了获得最佳的调试体验,我们强烈推荐使用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