Google Workspace Code MCP
Provides programmable access to Google Workspace APIs, allowing users to execute JavaScript or TypeScript code to interact with services like Google Drive and Google Calendar via the googleapis SDK.
Click on "Deploy 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 Workspace Code MCP List my calendar events for today"
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 Workspace Code MCP
Important: This is an alternative experiment, not my primary setup
If you are looking for the Google Workspace integration I actually use day-to-day, use this skill instead:
This repository is an alternative code-first MCP experiment built around one execute tool.
It is intentionally aligned with the ideas in:
Your MCP Doesn’t Need 30 Tools: It Needs Code — https://lucumr.pocoo.org/2025/8/18/code-mcps/
That post explores code-supported/code-first MCP design (fewer fixed tools, more programmable capability).
A local JavaScript/TypeScript MCP server with a single tool: execute.
execute runs JavaScript (or TypeScript with type stripping) and gives that code authenticated access to Google Workspace APIs.
What this server does
Exposes one MCP tool:
executeRuns user-provided JavaScript/TypeScript (async function body; TS types stripped)
Automatically performs OAuth login on first use (browser flow)
Reuses stored tokens on subsequent calls
Provides a small runtime API inside executed code:
auth— Google OAuth clientgoogle—googleapisSDK rootworkspace— helper methods (call,service,whoAmI)state— persistent mutable object across calls
This follows a code-mode design: one flexible execution tool instead of many fixed tools.
Related MCP server: google-workspace-mcp-advanced
Requirements
Node.js 20+
Local desktop/browser access for the initial OAuth sign-in
Install
npm installRun
npm startor:
node src/server.jsMCP configuration
This repo already includes .mcp.json:
{
"mcpServers": {
"google-workspace-code": {
"type": "stdio",
"command": "node",
"args": [
"/Users/mitsuhiko/Development/workspace-mcp/src/server.js"
],
"env": {
"GOOGLE_WORKSPACE_AUTH_MODE": "cloud"
}
}
}
}If you move the project, update the args path.
Tool contract
Tool name
execute
Input schema
script(string, required): JavaScript/TypeScript async function body (TS type syntax is stripped before execution)timeoutMs(number, optional): execution timeout in milliseconds (default30000, max300000)scopes(string[], optional): override OAuth scopes for the callresetState(boolean, optional): clears persistentstatebefore execution
Execution environment
Your script runs as an async function body with these variables in scope:
authgoogleworkspacestate
Return values are serialized and sent back as tool output.
Example scripts
1) Who am I + list Drive files
const me = await workspace.whoAmI();
const files = await workspace.call('drive', 'files.list', {
pageSize: 5,
fields: 'files(id,name,mimeType)'
});
state.lastEmail = me.email;
return {
user: me,
files: files.files,
remembered: state.lastEmail
};2) List today’s calendar events
const start = new Date();
start.setHours(0, 0, 0, 0);
const end = new Date(start);
end.setDate(end.getDate() + 1);
return await workspace.call('calendar', 'events.list', {
calendarId: 'primary',
timeMin: start.toISOString(),
timeMax: end.toISOString(),
singleEvents: true,
orderBy: 'startTime'
});OAuth and token storage
First call without token triggers browser login automatically
Default config directory:
~/.pi/google-workspaceDefault token path:
~/.pi/google-workspace/token.jsonDefault auth mode:
cloud(unless overridden)
Environment variables
GOOGLE_WORKSPACE_CONFIG_DIRGOOGLE_WORKSPACE_CREDENTIALSGOOGLE_WORKSPACE_TOKENGOOGLE_WORKSPACE_AUTH_MODE(cloudorlocal)GOOGLE_WORKSPACE_CLIENT_IDGOOGLE_WORKSPACE_CLOUD_FUNCTION_URLGOOGLE_WORKSPACE_CALLBACK_HOST
Security notes
Uses Node
vmfor execution convenience, not a hardened sandbox.Treat this as trusted local tooling.
Do not expose this server to untrusted users or networks.
Available Tools
1 toolexecuteExecute JavaScript/TypeScriptB
Execute JavaScript/TypeScript inside a Node vm context with authenticated Google Workspace access. TypeScript type syntax is stripped before execution. The script runs inside an async function body and can use: auth, google, workspace, state. Return values with return ....
Inputs: script (required), timeoutMs, scopes, resetState.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility of ambiguity or overlap between tools. The tool has a single, clearly defined purpose: executing JavaScript/TypeScript code in a Google Workspace context.
A single tool inherently has perfect naming consistency. The tool name 'execute' follows a clear verb-based pattern, and there are no other tools to create inconsistency.
One tool is too few for a server with the broad scope implied by 'Google Workspace Code MCP'. This suggests a single-purpose utility rather than a comprehensive interface to Google Workspace, which typically involves multiple resources and operations.
The tool set is severely incomplete for the stated purpose. A Google Workspace integration would typically require tools for managing users, groups, documents, calendars, etc., but this server only provides a generic code execution tool with no specific Workspace operations.
Maintenance
Related MCP Connectors
Hosted MCP server with managed OAuth for 15+ toolkits: Google Workspace, Fitbit, Oura, Kalshi, etc.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Hosted MCP for Google Workspace, Atlassian and Notion: one OAuth, per-user accounts, write access.
The Google Compute Engine MCP server is a fully-managed Model Context Protocol server that provides tools to manage Google Compute Engine resources through AI agents. It enables capabilities including instance management (creating, starting, stopping, resetting, listing), disk management, handling instance templates and group managers, viewing machine and accelerator types, managing images, and accessing reservation and commitment information. The server operates as a zero-deployment, enterprise-grade endpoint at https://compute.googleapis.com/mcp with built-in IAM-based security.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server for automating Google Workspace applications including Sheets, Apps Script, Drive, Docs, and Gmail. It enables users to manipulate spreadsheets, edit scripts, manage files, and send emails directly from conversational AI interfaces.31MIT
- AlicenseBqualityDmaintenanceProduction-ready MCP server for Google Workspace providing broad coverage across Gmail, Drive, Calendar, Docs, Sheets, and more, with safe-by-default write operations and markdown-to-Google-Docs support.100MIT
- AlicenseNot gradedqualityDmaintenanceEnables local execution of Google Apps Script tools for Google Workspace automation via an MCP server, using gas-fakes for secure sandboxed execution.74 npm4ISC
- AlicenseNot gradedqualityDmaintenanceA unified MCP server for Google Workspace APIs providing tools for Chat, Gmail, and Calendar operations including messaging, email management, and event scheduling.873 npmMIT