Google Extras MCP
by davefx
README.md
# google-extras-mcp
A remote [MCP](https://modelcontextprotocol.io) server for the parts of your Google account that
Claude's official connectors don't cover: **Google Keep** and **Google Contacts**. You run it on
your own machine and add it to **Claude.ai** as a custom connector, so it works on the web and in
the mobile apps, for your account only.
> **Unofficial.** This project is not affiliated with Google or Anthropic. The Keep module uses
> Keep's **internal, undocumented API** (through [gkeepapi](https://github.com/kiwiz/gkeepapi)),
> which Google can change or block at any time, and which needs a *master token* with broad
> access to your account. Read "Security model" before you deploy it. It's a personal project,
> shared as is, with no promise of support.
## Modules
Each module turns itself on when its credentials are set. Configure one or both.
| Module | Google API | Credentials | Tools |
|---|---|---|---|
| Keep | Internal, unofficial (gkeepapi) | `GOOGLE_EMAIL` + `GOOGLE_MASTER_TOKEN` | `search_notes`, `get_note`, `list_labels`, `create_note`, `create_list`, `update_note`, `add_list_items`, `set_list_item`, `move_list_item`, `reorder_list_items`, `set_list_item_parent`, `share_note`, `trash_note` |
| Contacts | Official People API | `GOOGLE_CONTACTS_REFRESH_TOKEN` | `search_contacts`, `list_contacts`, `get_contact`, `create_contact`, `update_contact` |
### Keep
* **Notes and checklists**: search, read, create, update, archive, pin, color, labels, trash.
Nothing is ever deleted permanently.
* **List order.** `add_list_items` takes an optional `position` (0 = first; omitted = last).
`move_list_item` moves one item to a position. `reorder_list_items` puts the given items
first, in that order, and keeps the rest after them in their current order. Positions count
among siblings: the top-level items, or the subitems of one parent. A top-level item moves
with its subitems.
* **Subitems.** Each list item reports its `parent_id`. `add_list_items` takes `parent_id` to
create subitems, and `set_list_item_parent` nests an item under another or takes it out again.
Keep allows only one level of nesting.
* **Sharing.** Notes report `shared`, `shared_with_family` and `collaborators` (owner,
collaborators, pending invitations, and the family group). `search_notes` can filter by
`shared`. `share_note` adds or removes collaborators by email, and shares or unshares the note
with your Google **family group** (`family_group: true/false`). The family group's address is
taken from any note already shared with it; if there is none, set `KEEP_FAMILY_GROUP_EMAIL`.
* **Safe mode** (default): notes created through the server get the `keep-mcp` label
(`KEEP_LABEL`), and only notes with that label can be changed, shared or trashed. Every note
can be read. `UNSAFE_MODE=true` lifts the restriction.
### Contacts
Search, list, read, create and update contacts. Contacts are never deleted through the server.
## Security model
| Layer | What it does |
|---|---|
| Cloudflare Tunnel | No ports open on your router. Your home IP is never exposed. |
| Cloudflare WAF (optional) | `/mcp`, `/token` and `/register` answer only Anthropic's egress IPs. |
| Restricted OAuth redirect URIs | Only Claude's callback (`claude.ai` / `claude.com`) can complete login. Any other MCP client is refused when it tries to register. |
| Google login + **email allowlist** | Every MCP request is checked against Google. The account must have a verified email listed in `ALLOWED_EMAILS`. Anyone else gets `401`. |
| Consent screen | You must approve each new client before it is sent on to Google. |
| Keep safe mode (default) | Only notes with the `keep-mcp` label can be changed. |
| systemd hardening | The service runs as an unprivileged user with a read-only filesystem. Secrets live in a `0600` file. |
The secret that matters most is the **Keep master token**. It gives broad access to your Google
account, not just Keep. It lives only in the server's env file. Back that machine up carefully,
and if the token is ever exposed, revoke it (see "Revoking access").
---
The steps below use a Proxmox LXC and a Cloudflare Tunnel, which is how I run it. Any Debian
machine and any way to publish an HTTPS hostname will do. Replace `mcp.example.com` with your
hostname and `you@gmail.com` with your Google account.
## 1. Install
* A Debian 12 or 13 machine or container (an **unprivileged** LXC with 1 vCPU, 512 MB RAM and
4 GB disk is plenty). It needs outbound internet only.
* Copy this repository onto it, then run as root:
```bash
./deploy/install.sh
```
This creates the `google-extras-mcp` user and service, the virtualenv in
`/opt/google-extras-mcp`, and `/etc/google-extras-mcp/google-extras-mcp.env` with a fresh
`JWT_SIGNING_KEY`.
## 2. Create the Google OAuth client (used to log you in)
In <https://console.cloud.google.com/>:
1. Create a project.
2. **Google Auth Platform → Branding / Audience**: User type **External**. Under *Data access*,
add the scopes `openid` and `.../auth/userinfo.email`. These are non-sensitive, so Google
doesn't need to verify the app.
* **Audience → Publishing status:** leave it in *Testing* and add your account as the only
test user. Google itself then blocks every other account, on top of this server's
allowlist. (If you enable Contacts, see step 6: it needs the app *In production*.)
3. **Clients → Create client → Web application**, with authorized redirect URI
`https://mcp.example.com/auth/callback`.
4. Put the client ID and secret into `GOOGLE_OAUTH_CLIENT_ID` / `GOOGLE_OAUTH_CLIENT_SECRET`,
and fill in `ALLOWED_EMAILS` and `PUBLIC_BASE_URL` in the env file.
## 3. Keep: get the master token
You can do this on your desktop or on the server, with the package installed:
1. Open <https://accounts.google.com/EmbeddedSetup> and sign in with your account.
2. Click "I agree". The page may then spin forever. That's fine.
3. Open DevTools → Application → Cookies → `accounts.google.com` and copy the `oauth_token`
value (it starts with `oauth2_4/`). It's only valid for a few minutes.
4. On the server, as root, run:
```bash
/opt/google-extras-mcp/venv/bin/google-extras-keep-token \
--email you@gmail.com --write /etc/google-extras-mcp/google-extras-mcp.env
```
and paste the value. The token is written straight into the env file and never printed.
5. Set `GOOGLE_EMAIL` in the env file, then start the service:
```bash
systemctl enable --now google-extras-mcp
journalctl -u google-extras-mcp -f
```
## 4. Publish it: Cloudflare Tunnel
On the server:
```bash
# Install cloudflared (official Debian repository)
mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg -o /usr/share/keyrings/cloudflare-main.gpg
echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main" \
> /etc/apt/sources.list.d/cloudflared.list
apt-get update && apt-get install -y cloudflared
```
A **locally managed** tunnel doesn't need Zero Trust onboarding:
```bash
cloudflared tunnel login # open the URL, pick your zone, click Authorize
cloudflared tunnel create google-extras-mcp
cloudflared tunnel route dns google-extras-mcp mcp.example.com
mkdir -p /etc/cloudflared && mv ~/.cloudflared/<TUNNEL_ID>.json /etc/cloudflared/
cat > /etc/cloudflared/config.yml <<EOF
tunnel: <TUNNEL_ID>
credentials-file: /etc/cloudflared/<TUNNEL_ID>.json
no-autoupdate: true
ingress:
- hostname: mcp.example.com
service: http://127.0.0.1:8000
- service: http_status:404
EOF
cloudflared service install && systemctl enable --now cloudflared
shred -u ~/.cloudflared/cert.pem # the zone cert isn't needed to run the tunnel
```
Check it: `curl https://mcp.example.com/.well-known/oauth-protected-resource/mcp` should return
JSON, and `curl -X POST https://mcp.example.com/mcp` should return `401` (or `403` once the WAF
rule below is active).
> Don't put **Cloudflare Access** (Zero Trust login) in front of this hostname. Claude's
> servers can't pass an Access login, so the connector would break. Google OAuth handles
> authentication instead.
### Optional, recommended: Cloudflare WAF rule
In your zone, **Security → WAF → Custom rules → Create rule**, *Edit expression*, action
**Block**:
```
(http.host eq "mcp.example.com"
and (starts_with(http.request.uri.path, "/mcp")
or http.request.uri.path in {"/token" "/register"})
and not ip.src in {160.79.104.0/21 2607:6bc0::/48})
```
These endpoints are only ever called by Anthropic's servers. `/authorize`, `/consent` and
`/auth/callback` must stay open because your own browser opens them while you log in.
Anthropic's egress range is shared by every Claude user, so this rule only filters out noise;
the allowlist is what keeps people out. If connecting fails while the rule is active, first try
removing `/token` and `/register` from it. Anthropic's current ranges:
<https://platform.claude.com/docs/en/api/ip-addresses>.
## 5. Add the connector in Claude
1. On claude.ai, go to **Settings → Connectors → Add custom connector**.
2. Give it a name and the URL `https://mcp.example.com/mcp`. Leave the advanced OAuth fields
empty.
3. Click *Connect*, approve the consent page, then sign in with Google.
4. The connector shows up in the Claude mobile apps too (same account).
Claude reads the tool list when a conversation starts: after an update that adds tools, open a
new conversation to see them.
To let another person in, add their Google account to `ALLOWED_EMAILS` and restart the
service. Note that they'll be using **your** Keep and Contacts.
## 6. Contacts (optional)
Contacts use the **official People API**, not the master token: a master-token flow is rejected
for it (Google bills it to its own project, which you can't configure). So this needs a normal
OAuth2 refresh token for your account, from the same OAuth client that logs you in.
1. **Enable the People API** in the project (APIs & Services → Library).
2. **Google Auth Platform → Data access**: add the scope `.../auth/contacts` (read/write).
It is a *sensitive* scope.
3. **Branding**: fill in the app home page and a privacy policy URL (required before you can
publish). Then **Audience → Publishing status → Publish app** (*In production*). This
matters: in *Testing*, refresh tokens for sensitive scopes expire after 7 days. Unverified is
fine for a single owner; you click past a one-time "unverified app" warning.
4. Temporarily add a redirect URI you can read the code back from (a page of your own that keeps
the `?code=...` query visible) to the OAuth client, then run on the server as root:
```bash
T=/opt/google-extras-mcp/venv/bin/google-extras-contacts-token
$T authurl --redirect https://your-site.example/ # open it, approve, copy the code
$T exchange <code> --redirect https://your-site.example/ # stores the refresh token (never printed)
systemctl restart google-extras-mcp
```
Then remove that temporary redirect URI again.
## Revoking access
* Remove someone: take them out of `ALLOWED_EMAILS` and restart. They're cut off within
5 minutes (token check cache).
* Log out every client: change `JWT_SIGNING_KEY` and restart.
* Leaked master token: change your Google password, which revokes master tokens, or remove the
device in <https://myaccount.google.com/device-activity>. Then generate a new token.
* Revoke Contacts: remove the app at <https://myaccount.google.com/permissions>, then clear
`GOOGLE_CONTACTS_REFRESH_TOKEN` and restart.
## Development
```bash
uv venv && uv pip install -e . pytest pytest-asyncio
.venv/bin/pytest
```
The tests use fakes for Keep and the People API; they never touch a real account. To run the
server locally, set the variables from `deploy/google-extras-mcp.env.example`, with
`PUBLIC_BASE_URL` pointing to a tunnel, and run `google-extras-mcp`.
### A note on gkeepapi
gkeepapi 0.17 loses note collaborators when it restores a saved state, and drops the field that
identifies the family group. `keep/sharing.py` patches both until
[kiwiz/gkeepapi#194](https://github.com/kiwiz/gkeepapi/pull/194) is released.
## License
Copyright (C) 2026 David Marín Carreño
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU Affero General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version. See [LICENSE](LICENSE).
In short: if you modify it and let others use it, including as a hosted service, you must
publish your source code under the same license and keep this copyright notice.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues