Skip to main content
Glama
penysho

Google Docs MCP Server

by penysho

Google Docs MCP Server

This project provides an MCP (Model Context Protocol) server that works with the Google Docs API. It implements an interface for manipulating Google Docs using generative AI.

function

This MCP server provides the following features:

  • Read Google Docs documents

  • Create a new Google Docs document

  • Updating an existing Google Docs document

  • Searching Google Docs documents

Related MCP server: Claude MCP x Google Docs

Technology stack

Prerequisites

  • Node.js (v14 or higher recommended)

  • npm or yarn

  • Google Cloud Platform project and access credentials

set up

1. Clone or download the project

git clone [リポジトリURL]
cd docs-mcp

2. Install dependencies

npm install

3. Google Cloud Platform Settings

  1. Create a project in the Google Cloud Console (or choose an existing project)

  2. Enable Google Drive API and Google Docs API

  3. Create an OAuth 2.0 client ID and download credentials

  4. Place the downloaded credentials file as credentials.json in the project root.

4. Preferences

  1. Create a .env file in your project root and set your environment variables there:

# アプリケーション環境
NODE_ENV=development

# ログ設定
# ログレベル: ERROR, WARN, INFO, DEBUG, TRACE
LOG_LEVEL=INFO
# 標準エラー出力にログを出力するかどうか(MCPの仕様に準拠)
LOG_USE_STDERR=true

# サーバー設定
SERVER_NAME=google-docs-mcp-server
SERVER_VERSION=1.0.0

# Google API認証情報
# 認証情報ファイルのパス(デフォルトは./credentials.json)
CREDENTIALS_PATH=./credentials.json
# トークンファイルのパス(デフォルトは./token.json)
TOKEN_PATH=./token.json

Explanation of environment variables:

  • NODE_ENV : The application's execution environment (development, production, test)

  • LOG_LEVEL : Log detail level (ERROR, WARN, INFO, DEBUG, TRACE)

  • LOG_USE_STDERR : Whether to output logs to standard error output (MCP specification uses standard error output)

  • SERVER_NAME : MCP server name

  • SERVER_VERSION : MCP server version

  • CREDENTIALS_PATH : Path to the Google API credentials file

  • TOKEN_PATH : Path to store authentication token

  1. Start the development server and get a token:

    npm run dev

    After execution, an authorization URL will be displayed in the terminal. Access that URL in your browser and log in with your Google account to perform authorization. Copy the authorization code that is displayed after authorization is complete, paste it into the terminal, and press Enter. This operation will generate a token.json file, and authentication will be performed automatically from then on.

Build and run

Build

npm run build

execution

Run as a regular server:

npm start

Running in development mode:

npm run dev

Use as an MCP server

This project is a server that complies with the Model Context Protocol (MCP) specification. You can connect to it directly from MCP clients (Cursor, Claude.ai, etc.).

Settings on the MCP client

Setting with Cursor

To use it with Cursor, add the following setting to .cursor/mcp.json file:

{
  "mcpServers": {
    "google-docs": {
      "command": "node",
      "args": ["/{プロジェクトへの絶対パス}/docs-mcp/dist/index.js"]
    }
  }
}

Other MCP clients

Other MCP clients communicate using standard input/output (stdio), so specify the appropriate command depending on your client's configuration.

MCP Tools Provided

read_google_document

Read the contents of a Google Docs document.

Parameters :

  • documentId (string): The ID of the Google Docs document to read.

Example usage :

// MCPクライアントでの使用例
const response = await client.callTool({
  name: "read_google_document",
  arguments: {
    documentId: "your-document-id"
  }
});

create_google_document

Create a new Google Docs document.

Parameters :

  • title (string): The title of the new document.

  • content (string, optional): The initial content of the document.

Example usage :

const response = await client.callTool({
  name: "create_google_document",
  arguments: {
    title: "ドキュメントタイトル",
    content: "初期コンテンツ"
  }
});

update_google_document

Update an existing Google Docs document.

Parameters :

  • documentId (string): The ID of the Google Docs document to update.

  • content (string): The content to add or update.

  • startPosition (number, optional): The position to start updating.

  • endPosition (number, optional): The position to end the update at.

Example usage :

const response = await client.callTool({
  name: "update_google_document",
  arguments: {
    documentId: "your-document-id",
    content: "追加または更新するコンテンツ",
    startPosition: 1,
    endPosition: 10
  }
});

Search for the Google Docs document.

Parameters :

  • query (string): The search query.

  • maxResults (number, optional): The maximum number of results to retrieve (default: 10).

Example usage :

const response = await client.callTool({
  name: "search_google_documents",
  arguments: {
    query: "検索キーワード",
    maxResults: 5
  }
});

Example of use from a program

Example of using MCP client from TypeScript or JavaScript program:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

async function main() {
  // MCPクライアントの作成
  const client = new Client({
    name: "google-docs-client",
    version: "1.0.0"
  });

  // Google Docs MCPサーバーへの接続
  const transport = new StdioClientTransport({
    command: "npm",
    args: ["run", "mcp"]
  });

  await client.connect(transport);

  // サーバー情報の取得
  const info = await client.getServerInfo();
  console.log("利用可能なツール:", info.tools);

  // ドキュメントの検索
  const searchResult = await client.callTool({
    name: "search_google_documents",
    arguments: {
      query: "会議資料",
      maxResults: 5
    }
  });
  console.log("検索結果:", searchResult);

  // 接続を閉じる
  await client.disconnect();
}

main().catch(console.error);

troubleshooting

If a connection error occurs with Cursor

  1. Do a full restart of Cursor.

  2. Please make sure .cursor/mcp.json settings are correct.

  3. Manually start the MCP server and check that it works:

    npm run dev

    Verify that when you run this command, you see the message "Google Docs MCP Server started" and that the process continues to run without exiting.

  4. Check the "MCP Server" section in Cursor's settings and make sure the "google-docs" server is listed.

If you get a Google authentication error

  1. Make sure the credentials.json file is correctly placed in the project root.

  2. If token.json file exists, delete it and try authenticating again.

  3. Verify that the Google Drive API and Google Docs API are enabled for your project in the Google Cloud Console.

Extend and Configure

This MCP server is designed with extensibility in mind, allowing you to add new features such as:

  1. src/googleDocsService.ts - Add new methods to the GoogleDocsService class.

  2. src/index.ts - defines new tools and registers them on the server

Notes

  • On first run, you will be prompted for authorization to authenticate with Google. After authorization, a token will be saved to a file and used automatically on subsequent runs.

  • Google Cloud Platform charges may apply depending on your usage of the API.

license

MIT License

Available Tools

4 tools
create_google_documentD
ParametersJSON Schema
NameRequiredDescriptionDefault
contentNoドキュメントの初期内容(オプション)
titleYes新しいドキュメントのタイトル

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_google_documentD
ParametersJSON Schema
NameRequiredDescriptionDefault
documentIdYes読み取るGoogle DocsドキュメントのID

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_google_documentsD
ParametersJSON Schema
NameRequiredDescriptionDefault
maxResultsNo取得する最大結果数(デフォルト: 10)
queryYes検索クエリ

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

update_google_documentD
ParametersJSON Schema
NameRequiredDescriptionDefault
contentYes追加または更新するコンテンツ
documentIdYes更新するGoogle DocsドキュメントのID
endPositionNo更新を終了する位置(オプション)
startPositionNo更新を開始する位置(オプション)

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv1.0.0
    • First observedcreate_google_document
    • First observedread_google_document
    • First observedsearch_google_documents
    • First observedupdate_google_document

TDQS

C2/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose targeting a specific operation in the Google Docs domain: create, read, search, and update. There is no overlap or ambiguity between these core functions, making it easy for an agent to select the right tool for each task.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with 'google_document' as the common noun component. The verbs (create, read, search, update) are standard and uniformly formatted in snake_case, providing excellent predictability and readability.

Tool Count4/5

With 4 tools, the count is appropriate for basic document operations, though it feels slightly thin for a full Google Docs server. Core CRUD functions are covered, but additional tools for deletion or more advanced features might be expected in a broader scope.

Completeness3/5

The toolset covers create, read, search, and update operations, which handles basic workflows, but there are notable gaps. Missing a delete tool prevents full lifecycle management, and other common document operations like sharing or formatting are absent, limiting comprehensive coverage of the domain.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/penysho/docs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server