使用说明
基本能力
产品定位
Google Drive 服务是一个与 Google Drive 集成的 MCP 服务器,提供文件管理和搜索功能。
核心功能
- 文件搜索:支持在 Google Drive 中搜索文件,返回文件名和 MIME 类型。
- 文件访问:支持所有文件类型,自动将 Google Workspace 文件转换为常用格式(如 Markdown、CSV、PNG 等)。
适用场景
- 需要从 Google Drive 中检索和管理文件的场景。
- 需要将 Google Workspace 文件转换为其他格式的场景。
工具列表
- search:在 Google Drive 中搜索文件,输入查询字符串,返回匹配的文件名和 MIME 类型。
使用教程
使用依赖
- 创建一个新的 Google Cloud 项目。
- 启用 Google Drive API。
- 配置 OAuth 同意屏幕(测试时可选择“内部”)。
- 添加 OAuth 范围
https://www.googleapis.com/auth/drive.readonly。 - 为“桌面应用”创建 OAuth 客户端 ID。
- 下载客户端 OAuth 密钥的 JSON 文件,并将其重命名为
gcp-oauth.keys.json,放置在项目根目录。
安装教程
- 使用
npm run build或npm run watch构建服务器。 - 运行
node ./dist auth进行身份验证。 - 完成浏览器中的身份验证流程,凭证将保存在项目根目录。
调试方式
- 使用 Docker 运行服务器时,确保挂载正确的密钥文件并设置环境变量。
- 使用 NPX 运行时,确保配置正确的服务器参数。
详细命令
Docker 身份验证
docker run -i --rm --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json -v mcp-gdrive:/gdrive-server -e GDRIVE_OAUTH_PATH=/gcp-oauth.keys.json -e "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json" -p 3000:3000 mcp/gdrive auth
Docker 运行
{
"mcpServers": {
"gdrive": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "mcp/gdrive"]
}
}
}
NPX 运行
{
"mcpServers": {
"gdrive": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gdrive"
]
}
}
}
