一个强大的模型上下文协议(MCP)服务器,提供与Google Drive的无缝集成,允许AI模型在Google Drive中搜索、列出和读取文件。
gdrive_search
使用强大的全文搜索功能在您的Google Drive中搜索文件。
{
"query": "string (您的搜索查询)"
}

gdrive_read_file
直接使用Google Drive文件ID读取文件内容。
{
"file_id": "string (Google Drive文件ID)"
}

服务器智能处理不同的Google Workspace文件类型:
创建 Google Cloud 项目
启用 Google Drive API
配置 OAuth 同意屏幕
https://www.googleapis.com/auth/drive.readonly
创建 OAuth 客户端 ID
在项目中设置凭据
# 创建凭据目录
mkdir credentials
# 移动并重命名下载的 JSON 文件
mv path/to/downloaded/client_secret_*.json credentials/gcp-oauth.keys.json

# Clone the repository
git clone https://github.com/felores/gdrive-mcp-server.git
cd gdrive-mcp-server
# Install dependencies
npm install
# Build the project
npm run build

创建一个凭据目录并将您的 OAuth 密钥放入其中:
mkdir credentials
# 将下载的 OAuth JSON 文件移动到凭据目录,并命名为 gcp-oauth.keys.json

运行身份验证命令:
node dist/index.js auth
在浏览器中完成 OAuth 流程
凭据将保存在 credentials/.gdrive-server-credentials.json
中
# Start the server
node dist/index.js

将以下配置添加到您的应用程序服务器设置中:
{
"mcpServers": {
"gdrive": {
"command": "node",
"args": ["path/to/gdrive-mcp-server/dist/index.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "path/to/gdrive-mcp-server/credentials/gcp-oauth.keys.json",
"MCP_GDRIVE_CREDENTIALS": "path/to/gdrive-mcp-server/credentials/.gdrive-server-credentials.json"
}
}
}
}

将 path/to/gdrive-mcp-server
替换为实际的安装目录路径。
搜索文件:
// 搜索包含“季度报告”的文档
const result = await gdrive_search({ query: "quarterly report" });

读取文件内容:
// 使用其 ID 读取特定文件
const contents = await gdrive_read_file({ file_id: "your-file-id" });

credentials
目录中欢迎贡献!请随时提交 Pull Request。
此 MCP 服务器基于 MIT 许可证发布。详情请参见 LICENSE 文件。
如果您遇到问题:
credentials
目录中