Tollbooth Oauth2 Collector

io.github.lonnievv0.2.11更新於 Oct 4, 2026

Unauthenticated OAuth2 callback collector for Tollbooth MCP services

已驗證Streamable HTTP可網頁執行Developer ToolsDatabasesSecurity & Monitoring

概覽

AI 產生的概覽

一個遠端信箱式 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 供應商註冊搭配的無伺服器回呼。
安裝前請注意
此收集器被描述為未驗證,任何能存取它的人都可能呼叫其工具;state 權杖是唯一的查詢憑據。它處理 OAuth2 授權碼,授權碼以靜態加密保存且讀取一次後刪除,但用戶端憑據與權杖由搭配的回呼及使用方 MCP 伺服器持有。授權碼 600 秒後過期。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tollbooth Oauth2 Collector,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "tollbooth-oauth2-collector": {
      "type": "http",
      "url": "https://tollbooth-oauth2-collector.fastmcp.app/mcp"
    }
  }
}

README

Tollbooth OAuth2 Collector

[License] [Python]

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    │                                                     └──────────────────────┘
  1. MCP server starts an OAuth flow, setting redirect_uri to the serverless callback function's URL
  2. User authorizes in the browser; the OAuth provider redirects to the serverless callback with ?code=...&state=...
  3. Serverless callback (Val Town) POSTs the code to the collector's store_code MCP tool over /mcp/
  4. Collector encrypts the code (AES-256-GCM keyed on SHA-256 of the state) and stores it in Postgres (600s TTL)
  5. MCP server calls the retrieve_code(state=...) MCP tool to pick up the code (one-time read, auto-deleted)
  6. 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:

bash
fastmcp deploy server.py

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:

python
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:

python
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 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

RepositoryDescription
tollbooth-dpycPython SDK for Tollbooth monetization
dpyc-communityDPYC Social Contract registry and governance
dpyc-oracleFree community concierge — membership, governance, onboarding
tollbooth-authorityCertification Authority MCP service
tollbooth-sampleReference Operator implementation / template
tollbooth-pricing-studioiOS pricing editor for Operators
cypher-mcpMonetized graph answers — named Cypher over Neo4j/AuraDB
schwab-mcpSchwab brokerage MCP server
thebrain-mcpPersonal Brain knowledge-graph MCP server
excalibur-mcpX (Twitter) posting MCP server
taxsort-mcpTax sorting and classification MCP server
optionality-mcpOptions analytics MCP server
tollbooth-oauth2-collectorOAuth2 callback collector (Advocate)
tollbooth-shortlinksURL shortener utility Operator

License

Copyright 2026 Lonnie VanZandt. Licensed under the Apache License, Version 2.0.

來源:README.md,提交 c24b1ed

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v0.2.11最新Sep 16, 2026