google-drive-mcp
A Model Context Protocol server for Google Drive API v3, enabling AI agents like Claude to manage files, folders, and sharing.
README
Google Drive MCP Server
A Model Context Protocol (MCP) server for Google Drive API v3, enabling AI agents like Claude to manage Google Drive files, folders, and sharing.
Provides 26 tools across 9 categories for comprehensive Google Drive management.
Features
| Category | Tools | Description |
|---|---|---|
| Files | 10 | List, search, full-text search, read, upload, update, append, export files |
| Trash | 3 | Trash, restore, list trash |
| Folders | 1 | Create folders |
| Organization | 2 | Move, copy files |
| Sharing | 5 | Share files, manage permissions, create share links |
| Metadata | 2 | Get/update file info |
| Revisions | 2 | List revision history, download specific versions |
| Shared Drives | 2 | List shared drives, get shared drive info |
| Utilities | 1 | Recently accessed files |
Requirements
- Python >= 3.10
- uv (recommended) or pip
- Google Cloud project with Drive API enabled
- OAuth 2.0 credentials (from Google Cloud Console)
Setup
1. Google Cloud Project
- Go to Google Cloud Console and create a new project
- Enable Google Drive API at APIs & Services > Library
- Create credentials at APIs & Services > Credentials:
- OAuth 2.0 Client ID (Desktop app)
- Download the credentials JSON file
2. Installation
git clone https://github.com/software-engineer-mj/google-drive-mcp.git
cd google-drive-mcp
uv sync
3. Configuration
cp .env.example .env
| Variable | Required | Description |
|---|---|---|
GOOGLE_DRIVE_CREDENTIALS_PATH |
Yes | Path to OAuth 2.0 credentials JSON |
GOOGLE_DRIVE_TOKEN_PATH |
No | OAuth token storage path (default: token.json) |
GOOGLE_DRIVE_MAX_DOWNLOAD_MB |
No | Maximum download size in MB (default: 10) |
Authentication
On first run, a browser will open for Google account authorization. After approval, token.json is created and refreshed automatically.
Note: Never commit
credentials.jsonortoken.jsonto version control. They are already in.gitignore.
Usage
stdio (default)
uv run python -m google_drive_mcp
Docker
docker build -t google-drive-mcp .
docker run -v /path/to/credentials.json:/app/credentials.json \
-e GOOGLE_DRIVE_CREDENTIALS_PATH=/app/credentials.json \
google-drive-mcp
MCP Client Configuration
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"google-drive": {
"command": "uv",
"args": ["run", "--directory", "/path/to/google-drive-mcp", "python", "-m", "google_drive_mcp"],
"env": {
"GOOGLE_DRIVE_CREDENTIALS_PATH": "/path/to/credentials.json",
"GOOGLE_DRIVE_TOKEN_PATH": "/path/to/token.json"
}
}
}
}
Claude Code
Add to .mcp.json:
{
"mcpServers": {
"google-drive": {
"command": "uv",
"args": ["run", "--directory", "/path/to/google-drive-mcp", "python", "-m", "google_drive_mcp"],
"env": {
"GOOGLE_DRIVE_CREDENTIALS_PATH": "/path/to/credentials.json",
"GOOGLE_DRIVE_TOKEN_PATH": "/path/to/token.json"
}
}
}
}
Development
# Install with dev dependencies
uv sync --dev
# Run tests
uv run pytest tests/ -v
# Lint
uv run ruff check src/ tests/
# Format
uv run ruff format src/ tests/
Tool Reference
Files (10)
| Tool | Description |
|---|---|
list_files |
List files in Drive, optionally within a folder |
search_files |
Search files using Drive query syntax |
search_file_content |
Search files by their text content (full-text search) |
read_file |
Read file content (Google Docs/Sheets/Slides auto-exported to text/CSV) |
upload_file |
Upload a text file |
upload_binary_file |
Upload a binary file (base64-encoded) |
update_file_content |
Update existing file content |
append_to_file |
Append text to the end of an existing text file |
export_file |
Export Google Workspace file to PDF, DOCX, XLSX, etc. |
create_google_doc |
Create a new Google Docs, Sheets, or Slides |
Trash (3)
| Tool | Description |
|---|---|
trash_file |
Move file to trash (recoverable) |
restore_file |
Restore file from trash |
list_trash |
List files in trash |
Folders (1)
| Tool | Description |
|---|---|
create_folder |
Create a new folder |
Organization (2)
| Tool | Description |
|---|---|
move_file |
Move file to a different folder |
copy_file |
Copy a file |
Sharing (5)
| Tool | Description |
|---|---|
share_file |
Share file by email (reader/writer/commenter/owner) |
list_permissions |
List file permissions |
remove_permission |
Remove a permission |
create_share_link |
Create "anyone with link" share link |
update_permission |
Update existing permission role |
Metadata (2)
| Tool | Description |
|---|---|
get_file_info |
Get detailed file metadata |
update_metadata |
Update file name/description |
Revisions (2)
| Tool | Description |
|---|---|
list_revisions |
List file revision history |
get_revision |
Download specific revision content |
Shared Drives (2)
| Tool | Description |
|---|---|
list_shared_drives |
List all shared drives the user has access to |
get_shared_drive |
Get metadata for a specific shared drive |
Utilities (1)
| Tool | Description |
|---|---|
list_recent |
List recently accessed files |
Google Docs Auto-Conversion
read_file automatically converts Google Workspace files:
| Source Format | Export Format |
|---|---|
| Google Docs | Plain Text |
| Google Sheets | CSV |
| Google Slides | Plain Text |
export_file supports additional formats:
| Source Format | Supported Formats |
|---|---|
| Google Docs | pdf, docx, odt, txt, html |
| Google Sheets | pdf, xlsx, ods, csv, tsv |
| Google Slides | pdf, pptx, txt |
| Google Drawings | pdf, png, svg |
Project Structure
src/google_drive_mcp/
├── __init__.py # FastMCP server instance
├── __main__.py # Entry point with auto-discovery
├── auth.py # OAuth 2.0 authentication
├── client.py # Google Drive API wrapper
├── exceptions.py # Custom exception hierarchy
├── lifespan.py # Server lifecycle management
├── utils.py # MIME type mapping, helpers
├── validators.py # Input validation utilities
└── tools/
├── __init__.py
├── drives.py # Shared drives management
├── files.py # File CRUD operations
├── folders.py # Folder management
├── metadata.py # File metadata
├── organization.py # Move, copy
├── revisions.py # Revision history
├── sharing.py # Sharing and permissions
├── trash.py # Trash operations
└── utilities.py # Recently accessed files
tests/
├── conftest.py
├── test_auth.py
├── test_client.py
├── test_server.py
├── test_utils.py
└── tools/
├── conftest.py
└── test_<domain>.py # Tests matching each tool module
License
MIT - see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。