一款强大的模型上下文协议(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
# 克隆仓库
git clone https://github.com/felores/gdrive-mcp-server.git
cd gdrive-mcp-server
# 安装依赖
npm install
# 构建项目
npm run build
创建凭据目录并将您的OAuth密钥放置其中:
mkdir credentials
# 将下载的OAuth JSON文件移动到凭据目录,并命名为gcp-oauth.keys.json
运行认证命令:
node dist/index.js auth
在浏览器中完成OAuth流程
凭据将被保存在credentials/.gdrive-server-credentials.json
# 启动服务器
node dist/index.js
在您的应用服务器设置中添加以下配置:
{
"mcpServers": {
"gdrive": {
"command": "node",
"args": ["path/to/gdrive-mcp-server/dist/index.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "path/to/gdrive-m-mp-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: "季度报告" });
读取文件内容:
// 使用文件ID读取特定文件
const contents = await gdrive_read_file({ file_id: "your-file-id" });
credentials目录中欢迎贡献!请随时提交Pull Request。
此MCP服务器采用MIT许可证。详情见LICENSE文件。
如果您遇到问题:
credentials目录中