这个MCP服务器与Google Drive集成,支持文件列表查询、读取和搜索功能。
query
(字符串类型):搜索查询内容该服务器提供对Google Drive文件的访问:
gdrive:///<file_id>
)
https://www.googleapis.com/auth/drive.readonly
gcp-oauth.keys.json
并放置到本仓库根目录(即servers/gcp-oauth.keys.json
)确保使用npm run build
或npm run watch
构建服务器。
要进行认证并保存凭证:
auth
参数运行服务器:node ./dist auth
servers/.gdrive-server-credentials.json
)要将此服务器集成到桌面应用中,请在应用的服务器配置中添加以下内容:
认证:
假设你已经在Google Cloud上完成了OAuth应用的设置,现在可以使用以下命令认证服务器(将/path/to/gcp-oauth.keys.json
替换为你的OAuth密钥文件路径):
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

该命令会打印出需要在浏览器中打开的URL。在浏览器中打开此URL并完成认证过程。凭证将保存在mcp-gdrive
卷中。
认证完成后,你可以在应用的服务器配置中使用该服务器:
{
"mcpServers": {
"gdrive": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "mcp/gdrive"]
}
}
}

{
"mcpServers": {
"gdrive": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gdrive"
],
"env": {
"GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"
}
}
}
}

要快速安装,请使用下面的任一一键安装按钮:
对于手动安装,请将以下JSON块添加到VS Code的用户设置(JSON)文件中。你可以通过按Ctrl + Shift + P
并输入Preferences: Open User Settings (JSON)
来完成此操作。
或者,你可以将其添加到工作区中的.vscode/mcp.json
文件中。这将允许你与他人共享配置。
注意:在
.vscode/mcp.json
文件中不需要mcp
键。
{
"mcp": {
"servers": {
"gdrive": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gdrive"
],
"env": {
"GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"
}
}
}
}
}

{
"mcp": {
"servers": {
"gdrive": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"mcp-gdrive:/gdrive-server",
"-e",
"GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json",
"mcp/gdrive"
]
}
}
}
}

此MCP服务器采用MIT许可证。这意味着你可以在MIT许可证的条款和条件下自由使用、修改和分发该软件。有关详细信息,请参阅项目仓库中的LICENSE文件。