Google Docs MCP Server
The Google Docs MCP Server enables AI systems to interact with Google Docs through a Model Context Protocol (MCP) interface, providing four core capabilities:
Read documents: Retrieve content from specific Google Docs using their document ID
Create documents: Generate new Google Docs with a specified title and optional initial content
Update documents: Modify existing documents by ID, adding or replacing content with optional positioning control
Search documents: Find Google Docs using search queries with customizable result limits
Enables reading, creating, updating, and searching Google Docs documents through the Google Docs API, allowing AI agents to manipulate document content programmatically.
Facilitates interaction with Google Drive for document management, including search functionality and authorization for accessing Google Docs content.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Google Docs MCP Servercreate a new document titled 'Meeting Notes' with today's agenda"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Node.js (v14 or higher recommended)
@modelcontextprotocol/sdk - Official implementation of the MCP SDK
Google APIs Node.js Client - Access to Google APIs
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-mcp2. Install dependencies
npm install3. Google Cloud Platform Settings
Create a project in the Google Cloud Console (or choose an existing project)
Enable Google Drive API and Google Docs API
Create an OAuth 2.0 client ID and download credentials
Place the downloaded credentials file as
credentials.jsonin the project root.
4. Preferences
Create a
.envfile 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.jsonExplanation 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 nameSERVER_VERSION: MCP server versionCREDENTIALS_PATH: Path to the Google API credentials fileTOKEN_PATH: Path to store authentication token
Start the development server and get a token:
npm run devAfter 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.jsonfile, and authentication will be performed automatically from then on.
Build and run
Build
npm run buildexecution
Run as a regular server:
npm startRunning in development mode:
npm run devUse 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_google_documents
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
Do a full restart of Cursor.
Please make sure
.cursor/mcp.jsonsettings are correct.Manually start the MCP server and check that it works:
npm run devVerify that when you run this command, you see the message "Google Docs MCP Server started" and that the process continues to run without exiting.
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
Make sure the
credentials.jsonfile is correctly placed in the project root.If
token.jsonfile exists, delete it and try authenticating again.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:
src/googleDocsService.ts- Add new methods to the GoogleDocsService class.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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol server that provides seamless integration with Google Workspace, allowing operations with Google Drive, Docs, and Sheets through secure OAuth2 authentication.83MIT
- Alicense-qualityAmaintenanceA Model Context Protocol server that enables AI assistants like Claude to read from, append to, and format text in Google Documents programmatically.3,704637MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that enables AI agents to interact with Google Workspace services including Drive, Docs, and Sheets through natural language commands.8MIT
- Alicense-qualityDmaintenanceA powerful Model Context Protocol (MCP) server implementation for seamless Google Docs API integration, enabling AI assistants to create, read, update, and manage Google Docs.9MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
MCP (Model Context Protocol) server for Appwrite
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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