Google Docs MCP Server

Google Docs MCP Server

Provides read-only access to Google Docs and Google Sheets, enabling users to read document content, spreadsheet data, and list/search accessible files through natural language.

Category
访问服务器

README

Google Docs MCP Server

An MCP (Model Context Protocol) server that provides read-only access to Google Docs and Google Sheets.

Features

  • Read Google Docs content
  • Read Google Sheets data
  • List accessible documents and spreadsheets
  • Search documents by query

Available Tools

Tool Description
get_document Get full content of a Google Doc by ID or URL
list_documents List accessible Google Docs with optional search
get_spreadsheet Get spreadsheet metadata and sheet list
get_sheet_data Read data from a specific range
list_spreadsheets List accessible Sheets with optional search

Setup

1. Create Google Cloud Credentials

  1. Go to Google Cloud Console
  2. Create a new project (or select an existing one)
  3. Enable the following APIs:
    • Google Docs API
    • Google Sheets API
    • Google Drive API
  4. Go to APIs & ServicesOAuth consent screen
    • Select "External" user type
    • Fill in the required fields (app name, support email)
    • Add scopes: docs.readonly, spreadsheets.readonly, drive.readonly
    • Add your email as a test user
  5. Go to APIs & ServicesCredentials
    • Click Create CredentialsOAuth client ID
    • Select Desktop application
    • Download the JSON file

2. Install the Server

# Clone or navigate to the project
cd google-docs-mcp

# Place your downloaded credentials file in the project root
mv ~/Downloads/client_secret_*.json ./client_secret.json

# Install dependencies
bun install

3. Authenticate

bun run auth

This will:

  1. Open your browser for Google login
  2. Ask you to grant read-only access to Docs, Sheets, and Drive
  3. Save the refresh token to .credentials/tokens.json

4. Run the Server

The server supports two transport modes:

HTTP Mode (Default)

# Start with HTTP transport (default, port 12333)
bun run start

# Or explicitly
bun run start --http

# Custom port via environment variable
MCP_PORT=8080 bun run start

Stdio Mode

# Start with stdio transport (for MCP clients that use stdio)
bun run start --stdio

5. Configure Your MCP Client

Claude Desktop (stdio mode)

Add to your Claude Desktop config (~/.config/claude/claude_desktop_config.json):

{
  "mcpServers": {
    "google-docs": {
      "command": "bun",
      "args": ["run", "/path/to/google-docs-mcp/src/index.ts", "--stdio"]
    }
  }
}

Claude Code (stdio mode)

Add to your Claude Code MCP settings:

{
  "mcpServers": {
    "google-docs": {
      "command": "bun",
      "args": ["run", "/path/to/google-docs-mcp/src/index.ts", "--stdio"]
    }
  }
}

HTTP Mode

For clients that support HTTP transport, connect to:

  • RPC endpoint: POST http://localhost:12333/rpc
  • Health check: GET http://localhost:12333/health

Environment Variables

Variable Description Default
MCP_PORT Port for HTTP server 12333
PORT Alternative port variable 12333

Usage Examples

Once configured, you can ask your MCP client to:

  • "List my recent Google Docs"
  • "Read the document at https://docs.google.com/document/d/ABC123/edit"
  • "Show me the data in Sheet1 of my budget spreadsheet"
  • "Search for documents containing 'project proposal'"

File Structure

google-docs-mcp/
├── client_secret.json     # Your Google OAuth credentials (git-ignored)
├── .credentials/          # Stored tokens (git-ignored)
│   └── tokens.json
├── src/
│   ├── index.ts           # MCP server entry point
│   ├── auth/
│   │   └── oauth.ts       # OAuth2 client management
│   ├── tools/
│   │   ├── docs.ts        # Google Docs tools
│   │   └── sheets.ts      # Google Sheets tools
│   └── types/
│       └── index.ts       # TypeScript types
└── bin/
    └── auth.ts            # CLI authentication script

Re-authenticating

If you need to re-authenticate (e.g., token expired or want to use a different account):

rm -rf .credentials
bun run auth

Troubleshooting

"Google credentials not found"

Make sure client_secret.json is in the project root directory.

"Not authenticated"

Run bun run auth to complete the OAuth flow.

"Access denied" errors

Ensure you've enabled the required APIs in Google Cloud Console and added your email as a test user in the OAuth consent screen.

Token expired

For apps in "Testing" status, refresh tokens may expire after 7 days. Re-run bun run auth to get a new token, or publish your app in Google Cloud Console for longer-lived tokens.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选