mcp-google-drive
Enables reading and searching Google Drive files, Google Docs, and Google Sheets via a CLI or MCP server, with support for section-based content extraction and Markdown import.
README
Google Drive CLI & MCP server
Read access to Google Drive, Docs, and Sheets through two surfaces that share
one implementation: a gdrive CLI (the primary surface, built for shell
pipelines and AI agents) and an MCP server (stdio). Both authenticate with
OAuth2 and call into a transport-agnostic core/ layer.
Requires Node.js >= 24.
This project includes code originally developed by Anthropic, PBC, licensed under the MIT License from this repo, and additional work from isaacphi/mcp-gdrive.
CLI
Build (npm run build), then invoke node dist/bin/gdrive.js <command>. For a
bare gdrive command, symlink dist/bin/gdrive.js into any directory on your
PATH. Every command accepts a Drive file ID or a Google URL.
gdrive search <query> [--type docs|sheets] [--page-size N] [--page-token TOKEN]
gdrive meta <fileId|url>
gdrive docs read <fileId|url> [--section "Heading"] [--json] [--no-images]
gdrive docs headings <fileId|url> [--min N] [--max N]
gdrive docs comments <fileId|url> [--include-resolved]
gdrive docs create --name "Title" [--from FILE] (or pipe markdown on stdin)
gdrive docs update <fileId|url> [--from FILE] (or pipe markdown on stdin)
gdrive sheets read <fileId|url> [--range A1:B10] [--csv|--tsv|--json]
gdrive files read <fileId|url>
docs create/update import Markdown via Drive's native converter. Updates
are a full-body replace: text and structure (headings, lists, tables,
links) convert, but it does not preserve embedded images or anchored
comments. Local image references () are stripped before import
(they make Drive's importer fail); public image URLs are kept and embedded.
Content is written to stdout so you can pipe or redirect it; structured
output is available via --json, and auxiliary notes (e.g. the embedded-image
manifest) go to stderr. Binary content is refused on an interactive terminal —
redirect it (gdrive files read <id> > out.pdf). Run any command with
--help for its flags.
Examples:
gdrive docs read <id> > prd.md # whole doc as Markdown
gdrive docs read <id> --section "2. Context" # just one section
gdrive sheets read <id> --range "'Sheet2'!A1:C9" --tsv
gdrive search "quarterly" --type docs
MCP Components
Tools
-
gdrive_search
- Description: Search for files in Google Drive.
- Input:
query(string): Search query.pageToken(string, optional): Token for the next page of results.pageSize(number, optional): Number of results per page (max 100).
- Output: Returns structured JSON with file metadata by default. Set
MCP_GDRIVE_OUTPUT_FORMAT=textto return a plain text list.
-
gdrive_read_file
- Description: Convenience tool to read contents of a file from Google Drive (legacy behavior preserved).
- Input:
fileId(string): ID of the file to read.url(string, optional): Google Docs/Drive URL with heading anchor (for section extraction).sectionHeading(string, optional): Heading text to extract a section.
- Output: Returns structured JSON with file metadata and content by default, or plain text with
MCP_GDRIVE_OUTPUT_FORMAT=text.
-
gdrive_parse_link
- Description: Parse a Google Docs URL and extract identifiers.
- Input:
url(string): Google Docs URL to parse.
- Output: Returns
fileId, optionalheadingId, anddocType.
-
gdrive_get_metadata
- Description: Fetch file metadata and optional headings for Google Docs.
- Input:
fileId(string): ID of the file to inspect.includeHeadings(boolean, optional): Include headings when file is a Google Doc.
- Output: Returns file metadata, optional
docType, and optional headings list.
-
gdrive_list_headings
- Description: List headings for a Google Doc.
- Input:
fileId(string): ID of the Google Doc to inspect.minLevel(number, optional): Minimum heading level to include (e.g.,2for H2+).maxLevel(number, optional): Maximum heading level to include (e.g.,3for up to H3).
- Output: Returns a headings list (with levels) and file metadata.
-
gdrive_read_content
- Description: Read content explicitly by mode (
fullorsection). - Input:
fileId(string): ID of the file to read.mode(string, optional):full(default) orsection.sectionHeading(string, optional): Required whenmode="section".
- Output: Returns file metadata and content, or a specific section when requested.
- Description: Read content explicitly by mode (
-
gdrive_download
- Description: Download content to a local file, returning byte offsets for local paging.
- Input:
fileId(string): ID of the file to read.mode(string, optional):full(default) orsection.sectionHeading(string, optional): Required whenmode="section".destinationPath(string, optional): Output path or directory for the download.chunkSizeBytes(number, optional): Chunk size for offsets in bytes.
- Output: Returns file metadata, download path, and byte offsets for local paging.
Download directory
The default download directory can be configured via GDRIVE_DOWNLOAD_DIR. If not set, downloads go to:
~/.mcp-gdrive/downloads
Output format
Tool output format is configured globally via environment variable:
MCP_GDRIVE_OUTPUT_FORMAT=json # default
MCP_GDRIVE_OUTPUT_FORMAT=text
Agent Workflow (Docs Link)
- Parse the link with
gdrive_parse_linkto getfileIdandheadingId. - List headings with
gdrive_list_headings(usegdrive_get_metadatafor file metadata). - Read with
gdrive_read_contentusingmode="section"per heading (avoid full reads for large docs).
Prompts
The server exposes prompt templates to guide agents through common workflows:
outline_doc(args:url, optionalminLevel,maxLevel)read_section_by_heading(args:url,sectionHeading)
Sheets
The MCP server reads spreadsheets as CSV via the generic read tools. For
range- and tab-aware reads (the Sheets values API), use the CLI's
gdrive sheets read. Write operations (creating/updating Docs or Sheets) are
not implemented on either surface.
Resources
The server does not currently expose any gdrive:/// resources. Access Drive
content via tools.
Setup
Three steps, ~3 minutes. You never edit a .env — credentials are read from
the file you download from Google.
1. Install
git clone https://github.com/abanka27/mcp-google-drive.git
cd mcp-google-drive
npm install # builds automatically (requires Node >= 24)
2. Get Google credentials (one-time, ~2 min)
Each person needs their own OAuth client — credentials can't be shared. Click through these exact pages:
- Create or pick a project: https://console.cloud.google.com/projectcreate
- Enable three APIs — click Enable on each:
- Drive — https://console.cloud.google.com/apis/library/drive.googleapis.com
- Docs — https://console.cloud.google.com/apis/library/docs.googleapis.com
- Sheets — https://console.cloud.google.com/apis/library/sheets.googleapis.com
- OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent Pick Internal if your account offers it. (An External app in "Testing" expires logins every 7 days — add yourself as a test user, or publish it.)
- Create credentials → OAuth client ID, application type Desktop app: https://console.cloud.google.com/apis/credentials/oauthclient
- Download the JSON. That single file is all you need.
3. Run setup
npm run setup
This finds the file you just downloaded (in the current directory or
~/Downloads), stores it, opens your browser to sign in once, and links
gdrive onto your PATH. If it can't find the file, pass the path explicitly:
node dist/bin/gdrive.js setup ~/Downloads/client_secret_XXXX.json
Done — try it:
gdrive search "" --page-size 3
Credentials and the saved token live in ~/.config/mcp-gdrive
($XDG_CONFIG_HOME/mcp-gdrive), or set GDRIVE_CREDS_DIR to override. The
browser prompt only appears on first run; after that the token refreshes
silently.
Use with an AI agent (Claude Code skill)
This repo ships a skill at .claude/skills/gdrive/ that teaches an agent the
commands and when to reach for them. It loads automatically when you run Claude
Code inside this repo. To use it from any directory, copy it into your user
skills:
cp -r .claude/skills/gdrive ~/.claude/skills/gdrive
Then ask your agent to read, search, or update Google Docs/Sheets and it will
drive gdrive for you.
License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。