Policy gateway for Google Workspace APIs with MCP server integration
Project description
Gatekeeper 🔐
Policy gateway for Google Workspace APIs — fine-grained control over what AI agents can do with your Google Drive, Gmail, and Calendar. Exposes enabled routes as MCP tools so agents discover and call only what you allow.
Quick Start
Option 1: One-line install (recommended)
The install script walks you through setup interactively:
curl -fsSL https://raw.githubusercontent.com/brimdor/gatekeeper/main/install.sh | bash
Option 2: Install with uv
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install "gatekeeper @ git+https://github.com/brimdor/gatekeeper"
Option 3: Install with pip
pip install git+https://github.com/brimdor/gatekeeper
Option 4: Podman/Docker
git clone https://github.com/brimdor/gatekeeper.git
cd gatekeeper
cp .env.example .env
# Edit .env with your Google OAuth credentials and module preferences
podman-compose up -d
After starting, authenticate with Google (gatekeeper auth), then visit http://localhost:8080/admin to enable modules and create an API key. See docs/SETUP.md for the full walkthrough.
Why Gatekeeper?
Google's OAuth scopes are all-or-nothing. gmail.modify gives full read/write/delete on everything. There's no way to say "read-only this label" or "create events but never delete them."
Gatekeeper sits between your AI agents and Google's APIs, acting as a policy layer:
- Enable/disable individual routes — turn off
gmail.messages.sendbut keepgmail.messages.list - Cap limits — restrict
maxResultsto 50, limit recipients to 5 - Filter data — exclude SPAM/TRASH from Gmail, block sensitive fields
- Audit everything — every request logged with key, route, status, timestamp
- MCP server — agents discover only enabled routes as tools, auto-updating when you toggle routes in the admin UI
graph LR
A[AI Agent] -- API Key --> G[Gatekeeper]
G -- OAuth2 --> Google[Google APIs]
G -- Policy Engine --> Google
For the full design walkthrough, see docs/ARCHITECTURE.md.
Setup
-
Configure environment:
cp .env.example .envand set at minimumGATEKEEPER_GOOGLE_CLIENT_ID,GATEKEEPER_GOOGLE_CLIENT_SECRET, and the modules you want (GATEKEEPER_DRIVE_ENABLED, etc.). -
Google OAuth setup: Run
gatekeeper auth(desktop flow) orgatekeeper auth --flow device(headless). See the canonical OAuth steps in docs/SETUP.md § Google OAuth Setup. -
Start the server:
gatekeeper serve. -
(Optional) Run as a systemd service:
gatekeeper service installthengatekeeper service enable. See docs/PODMAN_DEPLOYMENT.md § systemd. -
Configure remote MCP access:
gatekeeper hosts add myserver.local. See docs/MCP_SETUP_HUMAN.md. -
Create an API key:
gatekeeper key create --name my-agent gatekeeper key create --name drive-reader --permissions drive
Keys are prefixed with
gkp_. The full key is shown once on creation.
For step-by-step details, see docs/SETUP.md.
Using with AI Agents
Gatekeeper connects to AI agents via MCP (Model Context Protocol). Write routes are disabled by default; only a human admin can enable them.
- For humans → docs/MCP_SETUP_HUMAN.md
- For AI agents → docs/MCP_SETUP_AGENT.md
- Error handling → docs/AGENT_ERRORS.md
Example MCP server config:
{
"mcpServers": {
"gatekeeper": {
"url": "http://localhost:8080/mcp/sse",
"transport": "sse",
"headers": {
"X-Gatekeeper-API-Key": "gkp_your_api_key_here"
}
}
}
}
Every tool requires an api_key parameter. Disabled routes return 403.
Admin UI
Access the admin UI at http://localhost:8080/admin/ with HTTP Basic Auth.
| Page | Purpose |
|---|---|
| Dashboard | Requests, keys, auth status |
| Modules | Enable/disable modules and routes |
| API Keys | Create, list, revoke keys |
| Audit Log | Filterable request log |
| Auth Status | Google OAuth connection status |
REST API
Example calls:
# List Gmail messages
curl -H "Authorization: Bearer gkp_your_key" \
http://localhost:8080/api/v1/gmail/messages/list
# Get a Drive file
curl -H "Authorization: Bearer gkp_your_key" \
http://localhost:8080/api/v1/drive/files/get?file_id=1abc...
For the full reference — all 174 routes, auth, rate limits, binary/multipart routes, and admin endpoints — see docs/API_REFERENCE.md. The canonical route table lives in docs/ROUTES.md.
Policy Configuration
Route policies control what each key can do. Example:
curl -u admin:password -X PATCH http://localhost:8080/admin/api/routes/1 \
-H "Content-Type: application/json" \
-d '{"enabled": false, "policy_config": {"max_results": 25}}'
For the full transform list and recipes, see docs/POLICY_REFERENCE.md.
CLI Reference
gatekeeper serve # Start the server
gatekeeper init # Initialize DB and seed policies
gatekeeper auth # Google OAuth (desktop flow)
gatekeeper auth --flow device # Google OAuth (device flow)
gatekeeper key create --name my-agent # Create an API key
gatekeeper key list # List keys
gatekeeper key revoke --prefix gkp_a1b2 # Revoke a key
gatekeeper status # Show configuration status
gatekeeper service install # Install systemd service
gatekeeper hosts add <hostname> # Allow MCP host
gatekeeper hosts list # List allowed MCP hosts
Configuration
All configuration uses environment variables (prefix GATEKEEPER_) or .env:
| Variable | Default | Description |
|---|---|---|
GATEKEEPER_HOST |
127.0.0.1 |
Bind host |
GATEKEEPER_PORT |
8080 |
Bind port |
GATEKEEPER_DATABASE_URL |
sqlite+aiosqlite:///./gatekeeper.db |
Database URL |
GATEKEEPER_GOOGLE_CLIENT_ID |
(required) | Google OAuth client ID |
GATEKEEPER_GOOGLE_CLIENT_SECRET |
(required) | Google OAuth client secret |
GATEKEEPER_MCP_ENABLED |
true |
Enable MCP server |
GATEKEEPER_MCP_ALLOWED_HOSTS |
[] |
Additional allowed MCP hosts |
GATEKEEPER_RATE_LIMIT_PER_MINUTE |
120 |
Per-key rate limit |
GATEKEEPER_DRIVE_ENABLED |
false |
Enable Drive OAuth scope |
GATEKEEPER_GMAIL_ENABLED |
false |
Enable Gmail OAuth scope |
GATEKEEPER_CALENDAR_ENABLED |
false |
Enable Calendar OAuth scope |
Auto-generated secrets are persisted in gatekeeper_secrets.json (chmod 600). The file is already in .gitignore.
Container Deployment
podman build -t gatekeeper .
podman-compose up -d
The /data volume persists the database, Google token, and secrets. For full Podman/systemd deployment instructions, see docs/PODMAN_DEPLOYMENT.md.
Documentation
| Document | Purpose |
|---|---|
| docs/SETUP.md | Canonical install + OAuth setup |
| docs/MCP_SETUP_AGENT.md | Agent quick start and tool usage |
| docs/MCP_SETUP_HUMAN.md | Human-facing MCP setup |
| docs/PODMAN_DEPLOYMENT.md | Podman, Docker, and systemd deployment |
| docs/ARCHITECTURE.md | Design walkthrough and request flow |
| docs/API_REFERENCE.md | REST API reference |
| docs/ROUTES.md | Auto-generated route table |
| docs/MODULE_DEVELOPMENT.md | Add new Google API modules |
| docs/AGENT_ERRORS.md | Error handling and recovery |
| docs/POLICY_REFERENCE.md | Policy transform reference |
| docs/AGENT_TESTING.md | Test an agent integration |
| docs/UPGRADING.md | Upgrade and migration guide |
| SECURITY.md | Security policy |
| CONTRIBUTING.md | Contributing guidelines |
| CHANGELOG.md | Release notes |
Security
- TLS: Use a reverse proxy (Caddy/nginx) for HTTPS in production.
- API keys: bcrypt-hashed, prefix-based lookup, revocable.
- Token encryption: Google OAuth tokens encrypted at rest with Fernet.
- Network: Binds
127.0.0.1by default. - MCP host allowlist: DNS rebinding protection; only localhost by default.
- Admin auth: HTTP Basic Auth with auto-generated credentials.
See SECURITY.md for details.
Development
git clone https://github.com/brimdor/gatekeeper.git
cd gatekeeper
uv pip install -e ".[dev]"
uv run pytest tests/ -v
uv run ruff check gatekeeper/
uv run gatekeeper serve
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aigatekeeper-0.3.1rc2.tar.gz.
File metadata
- Download URL: aigatekeeper-0.3.1rc2.tar.gz
- Upload date:
- Size: 315.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25f1a64ac79c7003100f8f75d510fa952b76be400fc9cc26f63cac19ac67df96
|
|
| MD5 |
652684d3de49596b983a89df18536aeb
|
|
| BLAKE2b-256 |
ee047e9964bb62910e833783427af82251751e92c8d9577b8b7ff35156bada96
|
Provenance
The following attestation bundles were made for aigatekeeper-0.3.1rc2.tar.gz:
Publisher:
pypi.yml on brimdor/gatekeeper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aigatekeeper-0.3.1rc2.tar.gz -
Subject digest:
25f1a64ac79c7003100f8f75d510fa952b76be400fc9cc26f63cac19ac67df96 - Sigstore transparency entry: 2118667884
- Sigstore integration time:
-
Permalink:
brimdor/gatekeeper@f64175b8766b5e32dababed52b36d18122637e6a -
Branch / Tag:
refs/tags/v0.3.1-rc.2 - Owner: https://github.com/brimdor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f64175b8766b5e32dababed52b36d18122637e6a -
Trigger Event:
push
-
Statement type:
File details
Details for the file aigatekeeper-0.3.1rc2-py3-none-any.whl.
File metadata
- Download URL: aigatekeeper-0.3.1rc2-py3-none-any.whl
- Upload date:
- Size: 77.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63c20371ee8631e49cfc07c285511ffa22373e3b023510744541d328f52b76d2
|
|
| MD5 |
09b68c1b480735d56a5805f8bce7c96a
|
|
| BLAKE2b-256 |
90d7419a41464f835e86ac4a547dc426bc533fd96a0fc0d862b09fbceea84438
|
Provenance
The following attestation bundles were made for aigatekeeper-0.3.1rc2-py3-none-any.whl:
Publisher:
pypi.yml on brimdor/gatekeeper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aigatekeeper-0.3.1rc2-py3-none-any.whl -
Subject digest:
63c20371ee8631e49cfc07c285511ffa22373e3b023510744541d328f52b76d2 - Sigstore transparency entry: 2118668010
- Sigstore integration time:
-
Permalink:
brimdor/gatekeeper@f64175b8766b5e32dababed52b36d18122637e6a -
Branch / Tag:
refs/tags/v0.3.1-rc.2 - Owner: https://github.com/brimdor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f64175b8766b5e32dababed52b36d18122637e6a -
Trigger Event:
push
-
Statement type: