Manage Google Sheets with AI
TypeScript MCP server that lets AI agents create, read, update, share and copy Google Sheets with OAuth2 or a service account.
1.0.0Add to Favorites
Why it matters
Enable AI agents to securely interact with Google Sheets, offering robust capabilities for creating, reading, updating, and managing spreadsheets and their data.
Outcomes
What it gets done
Create, list, and rename spreadsheets and sheets.
Read and write cell data, including batch updates.
Share spreadsheets with granular permissions.
Automate Google Sheets operations via API.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
Creates a new spreadsheet and optionally moves it to configured Drive folder
Lists all sheet tabs in the given spreadsheet
Renames an existing sheet tab
Adds a new sheet tab to the spreadsheet
Gets metadata including title, sheet IDs, and grid properties for a spreadsheet
Lists all spreadsheets in the configured Drive folder or My Drive
Shares spreadsheet with users at specified permission levels and sends notifications
Reads cell values from a sheet range or entire sheet
Overview
A Bun-based TypeScript MCP server with tools for creating, reading, editing, sharing and copying Google Sheets. It supports service account and OAuth2 authentication. Use when an assistant must work on Google spreadsheets. Requires a Google Cloud project with Sheets and Drive APIs enabled.
What it does
MCP-Google-Sheets is a TypeScript Model Context Protocol server that lets AI agents securely interact with Google Sheets through well-typed tools. It is built on Bun and the @modelcontextprotocol/sdk, and it supports two authentication flows: a service account, supplied as a base64-encoded CREDENTIALS_CONFIG value, and OAuth2, which uses credentials.json plus a generated token.json for user-scoped access.
When to use - and when NOT to
Use it when an assistant needs to create, read, edit, organize or share Google spreadsheets on your behalf, for example building a budget sheet, reading a range of cells, appending rows, or copying a tab between spreadsheets.
It needs a real Google Cloud setup, so do not choose it if you cannot enable the Sheets API and the Drive API or obtain either an OAuth2 client ID or a service account key. It also requires Bun 1.0 or newer on your PATH.
Capabilities
The server registers these tools:
- create makes a new spreadsheet and moves it into your Drive folder if one is configured.
- listSheets lists all sheet tabs in a spreadsheet.
- renameSheet renames an existing tab, and createSheet adds a new tab.
- spreadsheetInfo fetches metadata such as title, sheet IDs and grid properties.
- listSpreadsheets lists spreadsheets in your configured Drive folder, or in My Drive.
- shareSpreadsheet shares a spreadsheet with users as reader, commenter or writer and sends notifications.
- sheetData reads cell values from a sheet and range, or the whole sheet.
- updateCells writes a two-dimensional array of values into an A1-style range.
- batchUpdate applies multiple range updates in a single request.
- addRows and addColumns insert rows or columns at a given index.
- copySheet copies a tab between spreadsheets, optionally renaming it.
How to install
Prerequisites are Bun, a Google Cloud project with the Sheets API and Drive API enabled, and either an OAuth2 client ID (download credentials.json) or a service account key (download service_account.json). A Drive folder ID is optional and is used if you want new sheets moved out of My Drive.
Clone the repository, install dependencies with bun install, then configure the environment. The settings are CREDENTIALS_CONFIG for a base64-encoded service account key, EMAIL_ID for the Google email address you will use to access the spreadsheet, and the optional DRIVE_FOLDER_ID. If you use OAuth2 instead, place credentials.json next to index.ts, and token.json is generated after the first OAuth run. On Linux or macOS you can produce the base64 value by encoding the service account file and stripping newlines. Then start the server:
bun index.ts
On the first OAuth2 run you will see a URL. Visit it, grant access, and paste the code back into the terminal, after which token.json is created automatically.
How it works internally: initContext() chooses the auth method in order of service account, then OAuth2, then an error, and builds shared Google Sheets and Drive clients. Each tool is registered with server.tool(...), and the server uses StdioServerTransport so Claude can invoke tools over stdin and stdout. An agent sends a JSON request naming the tool and its arguments, such as the create tool with a title, and the server calls the Google APIs and returns JSON-wrapped results.
Who it's for
Developers and analysts who want an assistant to work with Google Sheets, and contributors who want to extend it: the project welcomes issues and pull requests for new tools, bug fixes and enhancements.
Source README
MCP-Google-Sheets
A TypeScript Model Context Protocol (MCP) server that lets AI agents securely interact with Google Sheets via well-typed “tools.” Built on Bun and the @modelcontextprotocol/sdk, it supports both OAuth2 and Service-Account flows.
🚀 Features
- Authentication
- Service-Account via base64-encoded
CREDENTIALS_CONFIG - OAuth2 using
credentials.json+token.jsonfor user-scoped access
- Service-Account via base64-encoded
- Tools
create
Creates a new spreadsheet (and moves it into your Drive folder if configured).listSheets
Lists all sheet tabs in a given spreadsheet.renameSheet
Renames an existing sheet tab.createSheet
Adds a new sheet tab to a spreadsheet.spreadsheetInfo
Fetches metadata (title, sheet IDs, grid properties) for a spreadsheet.listSpreadsheets
Lists all spreadsheets in your configured Drive folder (or My Drive).shareSpreadsheet
Shares a spreadsheet with users (reader/commenter/writer) and sends notifications.sheetData
Reads cell values from a sheet and range (or whole sheet).updateCells
Writes a 2D array of values into an A1-style range.batchUpdate
Applies multiple range updates in a single request.addRows/addColumns
Inserts rows or columns at a specified index.copySheet
Copies a sheet tab between spreadsheets (optionally renaming it).
📋 Prerequisites
- Bun (v1.0+) installed and on your
PATH - A Google Cloud project with:
- Sheets API & Drive API enabled
- An OAuth2 Client ID (download
credentials.json) or a Service Account key (downloadservice_account.json)
- (Optional) A Drive folder ID if you want new sheets moved out of My Drive
⚙️ Setup
- Clone the repo
git clone https://github.com/yourusername/mcp-google-sheets.git cd mcp-google-sheets - Install dependencies
bun install
- Configure environment
Create a .env (or export) with:
# Base64-encoded service-account key JSON (optional)
CREDENTIALS_CONFIG=BASE-64 ENCODED SERVICE_ACCOUNT.JSON
# Or put your OAuth2 JSON files next to index.ts:
# credentials.json (OAuth client secret)
# token.json (generated after first OAuth run)
# The google email address that you'll use to access the spreadsheet
EMAIL_ID="Enter the email address you’ll use to access the spreadsheet"
# (Optional) ID of the Drive folder to store new sheets
DRIVE_FOLDER_ID=1a2B3c4D5e6F...
Tip: On Linux/macOS you can do
export CREDENTIALS_CONFIG=$(base64 service_account.json | tr -d '\n')
▶️ Running the Server
bun index.ts
On first OAuth2 run (if using credentials.json), you’ll see a URL. Visit it, grant access, then paste the code back into your terminal. A token.json will be generated automatically.
🔧 How It Works
Initialization
initContext() picks your auth method (Service-Account → OAuth2 → error).
Builds google.sheets & google.drive clients and stores them in a shared context.
MCP Tool Registration
- Each “tool” (e.g. create, listSheets, sheetData) is registered via server.tool(...).
Transport
- Uses StdioServerTransport so Claude can invoke tools over stdin/stdout.
Invocation
The agent sends a JSON request:
{ "tool": "create", "args": { "title": "Budget Q2" } }
The server runs your handler, calls Google APIs, and returns JSON-wrapped results.
🛠️ Try It Out
Clone & configure as above.
Start the server:
bun index.ts
Invoke a tool via Claude
Demo
❤️ Contributing
Feel free to open issues or PRs for new tools, bug fixes, and enhancements.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.