tollbooth-oauth2-collector
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., "@tollbooth-oauth2-collectorRetrieve the OAuth2 authorization code for state token 7e9a1c"
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.
Tollbooth OAuth2 Collector
An unauthenticated "dumb mailbox" FastMCP server that holds OAuth2 authorization codes for retrieval by the originating MCP server. A companion serverless function (Val Town) receives the browser redirect from the OAuth provider and hands the code to this collector's store_code MCP tool. This two-part design works around Horizon proxying only POST traffic on the /mcp/ path — browser GET redirects from OAuth providers cannot reach @mcp.custom_route endpoints, so a serverless callback bridges the gap.
How It Works
┌───────────────┐ 1. redirect_uri → serverless ┌──────────────────────┐
│ OAuth Provider│ ─────────────────────────────────→│ Serverless callback │
│ (e.g. Schwab) │ GET ?code=AUTH_CODE&state=TOKEN │ (Val Town) │
└───────────────┘ └──────────────────────┘
│
2. POST store_code │
(JSON-RPC /mcp/) ▼
┌──────────────────────┐
│ OAuth2 Collector │
│ store_code tool │
│ → encrypts + Postgres│
└──────────────────────┘
│
│ 3. code stored
▼
┌──────────────┐ 4. retrieve_code(state=TOKEN) ┌──────────────────────┐
│ MCP Server │ ─────────────────────────────────→ │ OAuth2 Collector │
│ (e.g. │ (JSON-RPC /mcp/) │ retrieve_code tool │
│ schwab-mcp) │ ←───────────────────────────────── │ → returns code once │
└──────────────┘ {"found": true, "code": ...} │ → deletes from DB │
└──────────────────────┘MCP server starts an OAuth flow, setting
redirect_urito the serverless callback function's URLUser authorizes in the browser; the OAuth provider redirects to the serverless callback with
?code=...&state=...Serverless callback (Val Town) POSTs the code to the collector's
store_codeMCP tool over/mcp/Collector encrypts the code (AES-256-GCM keyed on SHA-256 of the state) and stores it in Postgres (600s TTL)
MCP server calls the
retrieve_code(state=...)MCP tool to pick up the code (one-time read, auto-deleted)MCP server decrypts and exchanges the code for a token using its own credentials
The collector also exposes collector_status (pending-code count and TTL) and service_status (deployed build, incl. git sha) as free MCP tools. The serverless callback source lives in val/oauth_callback.js.
Related MCP server: MCP Credentials Broker
Deployment
Deploy to Horizon:
fastmcp deploy server.pySet the NEON_DATABASE_URL environment variable in Horizon to point to your Neon Postgres instance.
DPYC Advocate Identity
This collector is registered as an Advocate in the DPYC Social Contract. Consuming MCP servers discover its URL automatically via the DPYC registry:
from tollbooth.registry import resolve_service_by_name
svc = await resolve_service_by_name("tollbooth-oauth2-collector")
collector_url = svc["url"] # e.g., "https://tollbooth-oauth2-collector.fastmcp.app"No OAUTH_COLLECTOR_URL env var needed — peer discovery is handled by the registry.
Register the serverless callback function's URL (not the collector's) in your OAuth provider's developer portal. It is registered separately in the DPYC registry under the name tollbooth-oauth2-callback:
callback = await resolve_service_by_name("tollbooth-oauth2-callback")
redirect_uri = callback["url"] # e.g., "https://tollbooth-dpyc-oauth.val.run"Security Model
Auth codes are useless alone — exchanging a code requires
client_id+client_secret, held only by the consuming MCP serverEncrypted at rest — codes are stored AES-256-GCM-encrypted (keyed on SHA-256 of the state) via the SDK's
encrypt_collector_code; the consuming MCP server decrypts with the same stateHMAC-signed state tokens — the originating MCP server generates tamper-proof state tokens
One-time read — codes are deleted immediately after retrieval (prevents replay)
Short TTL — expired codes are automatically cleaned up (600s)
No secrets stored — the collector never sees client credentials or tokens
Related Repositories
Repository | Description |
Python SDK for Tollbooth monetization | |
DPYC Social Contract registry and governance | |
Free community concierge — membership, governance, onboarding | |
Certification Authority MCP service | |
Reference Operator implementation / template | |
iOS pricing editor for Operators | |
Monetized graph answers — named Cypher over Neo4j/AuraDB | |
Schwab brokerage MCP server | |
Personal Brain knowledge-graph MCP server | |
X (Twitter) posting MCP server | |
Tax sorting and classification MCP server | |
Options analytics MCP server | |
OAuth2 callback collector (Advocate) | |
URL shortener utility Operator |
License
Copyright 2026 Lonnie VanZandt. Licensed under the Apache License, Version 2.0.
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server with managed OAuth for 15+ toolkits: Google Workspace, Fitbit, Oura, Kalshi, etc.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Create and manage CodeQR short links, QR codes, and analytics from any MCP client.
OAuth scope approvals and consent receipts for remote MCP servers.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA complete OAuth 2.1 server implementation for FastMCP with PKCE support, enabling secure authentication and authorization flows. Provides authorization code exchange, token management, and refresh capabilities for building authenticated MCP applications.-
- AlicenseAqualityFmaintenanceProvides secure OAuth2-based credential management for MCP servers, allowing agents to obtain short-lived token references without exposing raw secrets.722MIT
- AlicenseNot gradedqualityCmaintenanceAuthenticating reverse proxy for MCP servers providing credential isolation, OAuth2 token management, and composite tool aggregation.BSD Zero Clause
- FlicenseNot gradedqualityCmaintenanceAn MCP authorization server implementing OAuth2/OIDC flows, supporting dynamic client registration, PKCE, consent screens, and client ID metadata documents for MCP authorization.-