Google Drive MCP工具

一个用于与Google Drive交互的MCP服务器工具,支持文件管理、搜索和上传等功能。

  • by san-10
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 san-10/mcp-_tools

使用说明

MCP工具

📂 Google Drive MCP-安装指南

此存储库包括一个MCP服务器,用于与 Google 云端硬盘.
按照此指南配置凭据、验证您的帐户并在本地运行服务器。


🔧 1.设置您的凭据目录

选择一个存储您的Google Drive凭据的目录。

例子:

export GDRIVE_CREDS_DIR="/Applications/mcp-gdrive/creds"

确保目录存在:

mkdir -p "$GDRIVE_CREDS_DIR"

🌐 2.运行手动身份验证

此步骤生成MCP服务器所需的OAuth令牌文件。

cd mcp-gdrive
node manual_auth.js

您将看到如下消息:

Open this URL in your browser to authorize access:
https://accounts.google.com/o/oauth2/v2/auth?...

After you allow access, copy the code from the URL and paste it here.

粘贴代码后,您应该看到:

Tokens saved to <your-creds-dir>/.gdrive-server-credentials.json

🔑 3.设置所需的环境变量

替换 <your-client-id> 和 <your-client-secret> 使用您的真实OAuth凭据
(永远不要将这些提交到GitHub).

export CLIENT_ID="<your-client-id>"
export CLIENT_SECRET="<your-client-secret>"
export GDRIVE_CREDS_DIR="/Applications/SAP/mcp-gdrive/creds"
export GOOGLE_APPLICATION_CREDENTIALS="/Applications/SAP/mcp-gdrive/creds/.gdrive-server-credentials.json"

重新加载shell会话:

source ~/.zshrc

📦 4.安装依赖项并构建

确保你正在运行Node.js v20+:

node -v

然后安装并构建:

cd mcp-gdrive
rm -rf node_modules package-lock.json
npm install
npm run build

🧩 5.MCP客户端配置示例

将此添加到MCP配置文件中
(例如。, claude_desktop_config.json, config.json,或您的自定义MCP加载器):

{
  "mcpServers": {
    "gdrive": {
      "command": "npx",
      "args": ["-y", "@isaacphi/mcp-gdrive"],
      "env": {
        "CLIENT_ID": "<your-client-id>",
        "CLIENT_SECRET": "<your-client-secret>",
        "GDRIVE_CREDS_DIR": "/Applications/SAP/mcp-gdrive/creds",
        "GOOGLE_APPLICATION_CREDENTIALS": "/Applications/SAP/mcp-gdrive/creds/.gdrive-server-credentials.json"
      }
    }
  }
}

确保:

  • 这 creds/ 文件夹存在
  • .gdrive-server-credentials.json 在里面
  • 环境变量与实际路径匹配

🎉 您已准备好使用Google Drive MCP

配置后:

  • 重新启动MCP客户端
  • Google Drive MCP服务器将自动加载
  • 现在,您可以在启用MCP的工具中列出、搜索、上传、重命名和管理驱动器文件

⚠️ 重要安全注意事项

  • 永不承诺 您的客户端ID、客户端密码、OAuth令牌JSON或环境变量。
  • 始终保持 creds/ 您的目录 .gitignore.
  • 如果你不小心暴露了新的秘密,请立即生成新的秘密。

📁 存储库结构(示例)

mcp-gdrive/
  ├── creds/                     # OAuth token stored here
  ├── dist/                      # Build output
  ├── tools/                     # MCP tools (list, search, rename, etc.)
  ├── manual_auth.js             # Run this to authenticate
  ├── package.json
  ├── tsconfig.json
  ├── README.md                  # (This file)