
Tollbooth Oauth2 Collector
io.github.lonnievv0.2.11更新於 Oct 4, 2026
Unauthenticated OAuth2 callback collector for Tollbooth MCP services
概覽
一個遠端信箱式 MCP 伺服器,用來保存回傳的 OAuth2 授權碼,並一次性交還給發起請求的 MCP 伺服器。
- 功能
- 它提供 store_code 工具,接收無伺服器回傳的 OAuth2 授權碼與 state 權杖,加密後存入 Postgres,有效期 600 秒。retrieve_code 依 state 一次性回傳授權碼並立即刪除。另外還提供 collector_status(待處理授權碼數量與 TTL)和 service_status(部署版本,含 git sha)兩個免費工具。
- 適用情境
- 當某個 MCP 伺服器需要完成 OAuth2 授權碼流程,但瀏覽器重新導向無法到達自身的回呼路由時,可透過無伺服器橋接把授權碼送到此收集器,之後再一次性取回。
- 執行需求
- 遠端 streamable HTTP 端點;連線本身未宣告驗證或環境變數。部署端需要 Postgres 執行個體,以 NEON_DATABASE_URL 環境變數設定,並在 OAuth 供應商註冊搭配的無伺服器回呼。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Tollbooth Oauth2 Collector,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"tollbooth-oauth2-collector": {
"type": "http",
"url": "https://tollbooth-oauth2-collector.fastmcp.app/mcp"
}
}
}README
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
- MCP server starts an OAuth flow, setting
redirect_urito the serverless callback function's URL - User 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.
Deployment
Deploy to Horizon:
Set 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:
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:
Security Model
- Auth codes are useless alone — exchanging a code requires
client_id+client_secret, held only by the consuming MCP server - Encrypted 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 state - HMAC-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
License
Copyright 2026 Lonnie VanZandt. Licensed under the Apache License, Version 2.0.
來源:README.md,提交 c24b1ed
工具
0版本歷史
1- v0.2.11最新Sep 16, 2026


