gws-mcp
by bxxd
README.md
# gws-mcp
A stdio MCP server that lets any MCP client use Google Workspace's remote MCP
servers (Calendar, Gmail, Drive, Docs, Sheets, …), including the approval
prompts most clients can't handle yet.
One file, zero runtime dependencies. Node 18+.
## Why
Google requires AI agents to reach Workspace through its own MCP servers
(`https://<service>mcp.googleapis.com/mcp/v1`) rather than the REST APIs.
Technical enforcement begins **February 1, 2027**. Those servers:
- speak the **stateless MCP protocol `2026-07-28`**: there is no session and no
server-to-client stream, and every request carries its own capabilities;
- gate consequential actions behind **form elicitation**. Deleting an event,
inviting an outside guest, sending mail, or even *reading* items owned by
someone outside your account returns an approval form instead of a result.
Clients built on older MCP versions (including the official Python SDK as of 1.26)
get `This action requires user confirmation, which this client does not
support` and stop there. gws-mcp speaks the new flow and hands each approval
to whoever should answer it.
## Who answers an approval
In order:
1. **Your approver hook** (`GWS_APPROVER`), if set. It's your program and your
policy (see below).
2. **The host's own approval UI**, if your MCP client declared elicitation
support. Google's form is forwarded as a standard `elicitation/create`.
3. **The agent**, otherwise. The tool result shows Google's prompt and choices,
and the call is parked:
```
Google requires confirmation before `delete_event` runs. Nothing has happened yet.
Deleting this event.
**Dentist · Thu, Dec 3, 9:00-9:10 AM EST**
Allow my-agent to use delete_event?
ALLOW_ONCE: Allow once
DENY_ONCE: Don't allow
request_id: a8578ad5
Answer with `google_confirm`. ...
```
The agent answers with `google_confirm {request_id, approval}`. It can decide
itself, or ask its user first and pass the answer on (a chained approval).
**Lasting grants** (`ALLOW_TOOL_ALWAYS`, `ALLOW_OWNER_ALWAYS`, …) need
`granted_by`, the person who approved, because Google keeps them on the
account.
## Setup
1. In your Google Cloud project, enable the per-product MCP API (e.g. **Calendar
MCP API**, `calendarmcp.googleapis.com`) and the product API.
2. On your OAuth 2.0 client, tick **Use this client for an AI-powered agent**
(Google Auth Platform → Clients). Without it, Google rejects the token.
3. Get a user access token with the scopes that server needs (Calendar:
`calendar.events`, plus a read scope) and keep it fresh in a file.
4. Register the bridge with your MCP client:
```json
{
"mcpServers": {
"google-calendar": {
"command": "npx",
"args": ["-y", "@bxxd/gws-mcp"],
"env": {
"GWS_MCP_URL": "https://calendarmcp.googleapis.com/mcp/v1",
"GWS_TOKEN_FILE": "/path/to/access-token",
"GWS_CLIENT_NAME": "my-agent"
}
}
}
}
```
Run one instance per Google service.
| Variable | Default | |
|---|---|---|
| `GWS_MCP_URL` | Calendar MCP | Upstream server. |
| `GWS_TOKEN_FILE` / `GWS_TOKEN` | required | Access token. The file is re-read on every call. |
| `GWS_CLIENT_NAME` | `gws-mcp` | Shown in Google's prompts ("Allow *my-agent* to …"). Google keys saved "always" grants to it, so **keep it stable**. |
| `GWS_APPROVER` | unset | Approval hook (below). |
| `GWS_TIMEZONE` | event's `timeZone`, else host zone | Used when localizing Calendar times. |
| `GWS_PROTOCOL_VERSION` | `2026-07-28` | Override if Google moves on. |
## Approver hooks
`GWS_APPROVER` is a command. For each approval it receives JSON on stdin:
```json
{"tool": "delete_event",
"arguments": {"eventId": "…"},
"field": "approval_choice",
"message": "Deleting this event.\n\n**Dentist · Thu, Dec 3, 9:00-9:10 AM EST**",
"title": "Allow my-agent to use delete_event?",
"choices": [{"value": "ALLOW_ONCE", "label": "Allow once"},
{"value": "DENY_ONCE", "label": "Don't allow"}]}
```
It prints one of the offered choice values, or `ask` (or nothing) to fall
through to the host or the agent. Use a hook to send the prompt to a phone or
an inbox, apply a standing policy, or log approvals. Google expects
consequential actions to be confirmed by a person; what your hook does is your
responsibility.
## Rough edges it smooths over
- **Headers and `_meta`**: `MCP-Protocol-Version`, `Mcp-Method`, `Mcp-Name`, and
the `io.modelcontextprotocol/*` capability declaration on every request. If
any are missing, Google answers with a bare `400`.
- **Calendar times**: Google wants local wall-clock `startTime`/`endTime` with
no offset and no `Z` (`2026-12-03T09:00:00`). Times sent with an offset or
`Z` are converted for you.
- **Stale approvals**: if an approval is no longer accepted, Google asks
again. You get the fresh prompt instead of an error.
- **Multi-round approvals**: answers are accumulated across rounds.
- **Choices are never hardcoded**: whatever Google offers is shown. Google says
the list will change.
- **Terse errors get a hint**: API not enabled, client not flagged as an AI
agent, missing capability, insufficient scope.
## Wire format (what Google actually expects)
Every request is a POST to `/mcp/v1` with:
```
Authorization: Bearer <user access token>
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: delete_event
```
```json
{"jsonrpc": "2.0", "id": 1, "method": "tools/call",
"params": {"name": "delete_event", "arguments": {"eventId": "…"},
"_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientInfo": {"name": "my-agent", "version": "1"},
"io.modelcontextprotocol/clientCapabilities": {"elicitation": {"form": {}}}}}}
```
When approval is needed, the result is:
```json
{"resultType": "input_required",
"inputRequests": {"approval_choice": {"method": "elicitation/create",
"params": {"mode": "form", "message": "Deleting this event. …",
"requestedSchema": {"type": "object", "required": ["approval_choice"],
"properties": {"approval_choice": {"type": "string",
"title": "Allow my-agent to use delete_event?",
"enum": ["ALLOW_ONCE", "DENY_ONCE"],
"enumNames": ["Allow once", "Don't allow"]}}}}}},
"requestState": "{\"elicitationId\":\"…\",\"requestBinding\":\"…\"}"}
```
To answer, re-send the **identical** `name` and `arguments` plus the answer.
`requestState` and `inputResponses` go at the top level of `params`, not inside
`_meta`:
```json
"params": {"name": "delete_event", "arguments": {"eventId": "…"}, "_meta": {…},
"requestState": "<unchanged>",
"inputResponses": {"approval_choice": {"action": "accept",
"content": {"approval_choice": "ALLOW_ONCE"}}}}
```
`DENY_ONCE`, `decline` and `cancel` all end the call with *"Action canceled.
The user declined the confirmation request."*. Choices seen so far:
`ALLOW_ONCE`, `DENY_ONCE`, `ALLOW_TOOL_ALWAYS`, `ALLOW_OWNER_ALWAYS`,
`ALLOW_AUDIENCE_ALWAYS`, `ALLOW_RESOURCE_ALWAYS`.
The Google docs that cover this are
[form elicitation](https://developers.google.com/workspace/guides/mcp-elicitation)
and [configuring the MCP servers](https://developers.google.com/workspace/guides/configure-mcp-servers).
## Licence
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues