Google Sheets Integration
STDIOTypeScript MCP server for secure Google Sheets interaction via well-typed tools.
TypeScript MCP server for secure Google Sheets interaction via well-typed tools.
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.
CREDENTIALS_CONFIG
credentials.json
+ token.json
for user-scoped accesscreate
listSheets
renameSheet
createSheet
spreadsheetInfo
listSpreadsheets
shareSpreadsheet
sheetData
updateCells
batchUpdate
addRows
/ addColumns
copySheet
PATH
credentials.json
) or a Service Account key (download service_account.json
)git clone https://github.com/yourusername/mcp-google-sheets.git cd mcp-google-sheets
bun install
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')
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.
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
Transport
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.
Clone & configure as above.
Start the server:
bun index.ts Invoke a tool via Claude
Feel free to open issues or PRs for new tools, bug fixes, and enhancements.