Skip to main content
Glama
README.md
# MCP Google Docs

[English](#english) | [中文](#中文)

---

## English

Lightweight MCP Server for querying, reading, and modifying Google Drive documents and spreadsheets.

### Setup

#### 1. Create Google Cloud Project

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project
3. Enable Google Drive API, Google Docs API, Google Sheets API
4. Create OAuth 2.0 credentials (Desktop app type)
5. Save your Client ID and Client Secret

#### 2. Configure MCP Client

Add to your Claude Desktop config:

```json
{
  "mcpServers": {
    "google-docs": {
      "command": "npx",
      "args": ["-y", "mcp-google-docs"],
      "env": {
        "GOOGLE_CLIENT_ID": "your_client_id",
        "GOOGLE_CLIENT_SECRET": "your_client_secret"
      }
    }
  }
}
```

#### 3. First Use

Call `auth_login` tool, browser will open Google authorization page.

### Tools

| Tool | Description |
|------|-------------|
| `auth_login` | OAuth login |
| `auth_status` | Check auth status |
| `gdrive_list` | List files |
| `gdrive_search` | Search files |
| `gdrive_info` | Get file info |
| `gdocs_read` | Read document |
| `gdocs_insert` | Insert text |
| `gdocs_append` | Append text |
| `gdocs_replace` | Find and replace |
| `gsheets_info` | Get spreadsheet info |
| `gsheets_read` | Read sheet |
| `gsheets_update` | Update cells |
| `gsheets_batch_update` | Batch update |
| `gsheets_append_row` | Append row |
| `gsheets_append_rows` | Append multiple rows at once |
| `gsheets_insert_rows` | Insert empty rows at position |

### Prompt Template

```markdown
## Google Docs MCP Rules

### Workflow
1. Run auth_login first if not authenticated
2. Use gdrive_search or gdrive_list to find files
3. Use read/update tools to operate

### Required
- Always read before modifying
- Use batch_update for bulk operations

### Forbidden
- Never guess file IDs, always search first
- Never update more than 100 cells at once
```

---

## 中文

轻量级 MCP Server,支持查询、阅读、修改 Google Drive 中的文档和表格。

### 安装配置

#### 1. 创建 Google Cloud 项目

1. 访问 [Google Cloud Console](https://console.cloud.google.com/)
2. 创建新项目
3. 启用 Google Drive API、Google Docs API、Google Sheets API
4. 创建 OAuth 2.0 凭据(桌面应用类型)
5. 记录 Client ID 和 Client Secret

#### 2. 配置 MCP 客户端

在 Claude Desktop 配置文件中添加:

```json
{
  "mcpServers": {
    "google-docs": {
      "command": "npx",
      "args": ["-y", "mcp-google-docs"],
      "env": {
        "GOOGLE_CLIENT_ID": "your_client_id",
        "GOOGLE_CLIENT_SECRET": "your_client_secret"
      }
    }
  }
}
```

#### 3. 首次使用

调用 `auth_login` 工具,浏览器会弹出 Google 授权页面,授权后即可使用。

### 工具列表

| 工具 | 说明 |
|------|------|
| `auth_login` | OAuth 授权登录 |
| `auth_status` | 检查授权状态 |
| `gdrive_list` | 列出文件 |
| `gdrive_search` | 搜索文件 |
| `gdrive_info` | 获取文件信息 |
| `gdocs_read` | 读取文档 |
| `gdocs_insert` | 插入文本 |
| `gdocs_append` | 追加文本 |
| `gdocs_replace` | 查找替换 |
| `gsheets_info` | 获取表格信息 |
| `gsheets_read` | 读取表格 |
| `gsheets_update` | 更新单元格 |
| `gsheets_batch_update` | 批量更新 |
| `gsheets_append_row` | 追加行 |
| `gsheets_append_rows` | 批量追加多行 |
| `gsheets_insert_rows` | 在指定位置插入空行 |

### 使用提示词

```markdown
## Google Docs MCP 使用规则

### 流程
1. 首次使用先调用 auth_login 授权
2. 用 gdrive_search 或 gdrive_list 找到目标文件
3. 用对应的 read/update 工具操作

### 强制
- 修改前必须先读取确认内容
- 批量操作使用 batch_update

### 禁止
- 不要猜测文件ID,必须先搜索
- 不要一次修改超过100个单元格
```

## License

MIT