Tollbooth Authority

io.github.lonniev由 GitHub 帳號 lonniev 發布v0.12.0更新於 Oct 27, 2026

Tollbooth Authority — Certified Purchase Order Service for DPYC operators

發布方自己的服務:authority.md

已驗證Streamable HTTP可網頁執行金融開發者工具安全與監控

概覽

AI 產生的概覽

為 DPYC 收費亭營運者提供認證的機構:登記營運者、收取閃電網路費用,並簽發 Schnorr 簽章的採購訂單憑證。

可以做什麼
  • 登記與管理營運者:採納申請、核准或拒絕、登錄檔更新、註銷與結構修復
  • 處理額度與付款:購買額度、取得閃電網路發票、查詢付款與餘額
  • 認證收費:依 2% 從價費率扣款並簽發 Nostr kind 30079 憑證
  • 身分證明:NIP-98 簽章請求,或 OAuth 持有者透過 Nostr 私訊證明 npub
  • 以 OpenTimestamps 公證與驗證帳本,並提供預言機委派與定價工具
適用情境
適用於 DPYC / Tollbooth 生態系內的營運者與所有者,需要在收費亭開啟前由權威機構認證已付款的採購訂單,或想自行架設一套認證執行個體。
執行需求
遠端 streamable HTTP 端點,要求 OAuth;OAuth 持有者用戶端不需 API 金鑰,持金鑰用戶端以 NIP-98 簽署請求。自架需要 Neon Postgres 連線字串、用於簽章的 Nostr nsec,以及透過 Secure Courier 交付的 BTCPay 憑證。
安裝前請注意
涉及真實閃電網路付款:認證費從預先儲值的餘額扣除,額度需以 sats 購買。自架需要 Nostr 私鑰與具備發票及提領權限的 BTCPay API 金鑰。所有者工具可核准、註銷與修復營運者,且外部登錄檔無法連線時認證會被拒絕。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tollbooth Authority,將其新增到工作區。
  2. 連接 所需的 憑證。它們會被私密儲存,絕不會在公開頁面上展示。
  3. 為需要使用其工具的對話啟用該服務。

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

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.lonniev%2Ftollbooth-authority/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。 客戶端會在首次連接時完成 OAuth 登入。

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

README

Tollbooth Authority

[Milo drives the Lightning Turnpike — Don't Pester Your Customer]

The institution that built the infrastructure.

The metaphors in this project are drawn with admiration from The Phantom Tollbooth by Norton Juster, illustrated by Jules Feiffer (1961). Milo, Tock, the Tollbooth, Dictionopolis, and Digitopolis are creations of Mr. Juster's extraordinary imagination. We just built the payment infrastructure.


The Turnpike Authority

Every turnpike has an authority. Not the operators who run the booths, and not the drivers who pay the fares — but the institution that poured the concrete, erected the signs, and stamped the purchase orders.

The Tollbooth Authority is the Massachusetts Turnpike Authority of the Lightning economy. It doesn't operate any toll booths. It doesn't touch operator BTCPay stores. It never sees user payment data. What it does is simpler and more essential:

  • It registers operators who want to run toll booths on the turnpike.
  • It collects a modest certification fee — 2% of every fare, minimum 10 sats — paid in advance via Lightning.
  • It stamps purchase orders — Schnorr-signed Nostr event certificates (kind 30079) that prove an operator has paid their fee before collecting a fare.
  • It never touches the fare itself. The operator collects from the user directly.

The Authority's signature is the proof that the turnpike is legitimate. Without the stamp, the toll booth doesn't open.

Architecture

As of v0.9.0, this Authority is a thin consumer of the tollbooth-dpyc wheel. Every piece of generic Authority code — onboarding state machine, Schnorr certificate signer, replay tracker, Neon tenant provisioner, and the full Authority tool surface — lives in the wheel's tollbooth.authority package. This repo's server.py supplies only actor-specific configuration: identity name, human-readable instructions, OperatorRuntime construction, and two register_*_tools(mcp, runtime) calls.

python
# The entire server.py, distilledfrom fastmcp import FastMCPfrom tollbooth.authority import (    AUTHORITY_TOOL_REGISTRY,    OPERATOR_CREDENTIAL_TEMPLATE,    register_authority_tools,)from tollbooth.runtime import OperatorRuntime, register_standard_toolsfrom tollbooth.tool_identity import STANDARD_IDENTITIES
mcp = FastMCP("tollbooth-authority", instructions="…")runtime = OperatorRuntime(    tool_registry={**STANDARD_IDENTITIES, **AUTHORITY_TOOL_REGISTRY},    vault_source="env",               # Authority arrives with its own Neon    purchase_mode="auto",             # derive direct/certified from the registry chain    service_name="Tollbooth Authority",    ots_enabled=True,    operator_credential_template=OPERATOR_CREDENTIAL_TEMPLATE,)register_standard_tools(mcp, "authority", runtime, ...)register_authority_tools(mcp, runtime)

Refactor history:

  • v0.5.0 introduced OperatorRuntime and delegated standard tools to the wheel — ~1,900 lines → ~970.
  • v0.19.0 required+verified proof on every tool that names it; the local _verify_operator_proof helper was promoted to wheel-side tollbooth.identity_proof.require_proof.
  • v0.21.0 (wheel) promoted 6 supporting modules (onboarding, nostr_signing, replay, tenant_provisioner, role_migration, settings) from forked Authority code into tollbooth.authority.*.
  • v0.22.0 (wheel) promoted the 10 Authority @tool definitions into register_authority_tools(mcp, runtime).
  • v0.9.0 (this release) deleted the eight now-redundant modules and slimmed server.py from ~970 lines to about a hundred. NorthAmerica and NewEngland followed suit in their own 0.4.0 releases.

Three-Party Protocol

The Tollbooth ecosystem is a three-party protocol spanning three repositories:

RepoRole
tollbooth-authority (this repo)The institution — fee collection, Schnorr signing, purchase order certification
tollbooth-dpycThe booth — operator-side credit ledger, BTCPay client, tool gating
thebrain-mcpThe first city — reference MCP server powered by Tollbooth

The Wider DPYC Federation

The three-party protocol above is the core, but the Authority certifies a wider federation of independent MCP services, all built on the same tollbooth-dpyc SDK:

RepoRole
tollbooth-dpycShared SDK — crypto, vault, auth, pricing, audit
dpyc-communityGovernance registry — members/read-only-lookup-cache.json, GOVERNANCE.md, CI validation
dpyc-oracleFree community concierge — membership, governance, onboarding answers
tollbooth-authorityThis repo — certification backbone, Schnorr certs, fee ledger
tollbooth-sampleReference template for new operators
tollbooth-pricing-studioPricing editor — native iOS, Nostr DMs
cypher-mcpMonetized graph answers — named Cypher over Neo4j/AuraDB
schwab-mcpCharles Schwab brokerage data
thebrain-mcpTheBrain knowledge-graph access
excalibur-mcpX/Twitter posting
taxsort-mcpTax sorting + classification
optionality-mcpOptions analytics
goodearth-mcpClimate analytics for small farms
beesknees-mcpThe Bee's Knees race game
roastify-mcpRoastify coffee catalog + packaging artwork
ChartRemotely-mcpDrives a desktop chart through a paired agent
tollbooth-webShared browser SDK for operator front ends
tollbooth-oauth2-collectorShared OAuth2 callback collector (community Advocate)
tollbooth-shortlinksURL shortener utility

How It Works

  1. Adopt. An operator calls request_adoption(authority_npub=..., service_url=..., display_name=...) on its own MCP, signing the request with its nsec. Its service delivers the request to the Authority, which records it as pending and notifies its owner. The owner approves it with approve_operator_request (or turns it down with reject_operator_request); approval creates the operator's ledger entry, provisions its isolated Neon schema and registers it through the Oracle.

  2. Fund. The operator calls purchase_credits with the number of sats they want to pre-fund. The Authority returns a Lightning invoice from its own BTCPay Server. The operator pays. After settlement, check_payment credits the balance.

  3. Certify. When a user wants to buy credits from an operator, the operator's server calls certify_credits. The Authority deducts the 2% ad valorem fee (via the @runtime.paid_tool decorator), signs a Schnorr-based Nostr event certificate, and returns it.

  4. Verify. The operator's tollbooth-dpyc library verifies the certificate using the Authority's Nostr npub. Only if the stamp is valid does the operator create a Lightning invoice for the user. No stamp, no fare.

Nostr Certificate Format (kind 30079)

Certificates are Schnorr-signed Nostr events (NIP-33 parameterized replaceable events) rather than Ed25519 JWTs. Each certificate contains the operator npub in a p tag, the certified amount and protocol in t/L tags, an expiration tag, and the content field holds the structured claim data. Verification uses BIP-340 Schnorr signatures against the Authority's Nostr npub.

DPYC Registry Enforcement

The Authority checks the dpyc-community registry cache members/read-only-lookup-cache.json at certification time. Operators must have "status": "active" in the registry. The registry is HTTP-cached with a configurable TTL. Design is fail-closed: if the registry is unreachable, certification is denied.

Upstream Topology Is Registry Metadata

Parent Authority relationships live in the dpyc-community registry — each Authority's upstream_authority_npub points at its sponsor. Operator MCPs resolve their certifying Authority through the Oracle (resolve_authority_for(npub)), which walks that registry chain; no per-Authority env var configures the upstream. The Authority's own certify_credits simply collects the ad valorem fee from its operator's pre-funded balance and signs the certificate — no per-transaction upstream call.

Ad Valorem Pricing

certify_credits is registered as a @runtime.paid_tool with 2% ad valorem pricing on the amount_sats parameter (minimum 10 sats). The fee is debited by the decorator, and the cost is read from runtime._last_debit_cost — no double computation.

OTS Notarization

OpenTimestamps notarization is enabled (ots_enabled=True on the runtime). Ledger state can be notarized and verified through the standard notarize_ledger and get_notarization_proof tools provided by the wheel.

Anti-Replay (ReplayTracker)

Every certificate includes a unique JTI (JWT ID). The Authority tracks seen JTIs in an in-memory ordered dict with TTL-based pruning. This prevents certificate replay attacks even if a certificate is intercepted before expiration.

MCP Tools

All tools are now wheel-defined and registered by the two register_*_tools calls in server.py. For the full canonical tables (Authority tools mounted by register_authority_tools, standard tools mounted by register_standard_tools) see the tollbooth-dpyc README. The short version:

  • Authority tools (Schnorr cert signing, operator lifecycle, 3-step Authority onboarding, registry membership check) — register_authority_tools(mcp, runtime). This set also includes the owner's request queue: receive_adoption_request (where an operator's adoption request arrives), list_operator_requests, approve_operator_request and reject_operator_request. The queue holds two kinds of request, an adoption and an update to an operator's registry entry (update_operator, which the operator calls and the owner approves). deregister_operator needs no approval: either the operator (leaving) or the Authority's owner (disowning it) may call it alone. repair_operator_schema is the owner's repair of a tenant's table ownership.
  • The standard tools (credit/payment, identity, secure courier, npub proof, pricing model, OpenTimestamps notarization, oracle delegation) — register_standard_tools(mcp, "authority", runtime, ...).

Every tool that takes npub requires the connection to prove it, and each request acts as exactly one npub. A request signed with that npub's nsec (NIP-98) proves it. A keyless client connects as an OAuth holder and proves the npub into its wallet once, with request_npub_proof, a reply to the DM, then receive_npub_proof. Owner-only tools require the request to prove the Authority's own npub. No proof travels in a tool argument.

Getting Started

Connecting via Horizon MCP

The Authority runs on Horizon. Any MCP client (Claude Desktop, Cursor, your own agent) can connect via Horizon:

https://www.fastmcp.cloud/server/lonniev/tollbooth-authority

Connecting needs no API key. A client holding a key signs each request with it (NIP-98). Any other client connects with OAuth as a holder, which acts as no npub until one is proven into it by a Nostr DM.

First Connection Walkthrough

Once connected, walk through the bootstrap in order:

  1. request_adoption(authority_npub="npub1...", service_url="...") — call it on your own operator MCP, signed with your operator nsec. The Authority's owner approves it (approve_operator_request), which creates your ledger entry and provisions your Neon schema. Your operator's adoption_status reads provisioned once it is done.
  2. purchase_credits(amount_sats=1000) — Returns a Lightning invoice. Pay it with any Lightning wallet.
  3. check_payment(invoice_id="...") — Pass the invoice ID from step 2. Confirms settlement and credits your balance.
  4. check_balance — Verify your balance is funded.
  5. operator_status — See your registration, balance, vault backend, and the Authority's npub. tollbooth-dpyc looks that npub up in the registry when it verifies a certificate, so there is nothing to hardcode.

Self-Hosting

To run your own Authority instance, set these environment variables:

Required
VariablePurposeExample
NEON_DATABASE_URLNeon Postgres URL for persistent operator ledgers. The Authority IS the trust root -- it reads this from env (unlike certified operators, which bootstrap it from Authority via Nostr DM). At startup, the Authority injects search_path=authority into the connection string for per-schema isolation.postgresql://...
TOLLBOOTH_NOSTR_OPERATOR_NSECNostr secret key (nsec) for Schnorr certificate signing and Secure Courier DMsnsec1...
Credentials via Secure Courier (NOT env vars)

BTCPay credentials are delivered via Secure Courier, not set as environment variables:

CredentialDescription
btcpay_hostAuthority's BTCPay Server URL for fee collection
btcpay_api_keyBTCPay API key with invoice + payout permissions
btcpay_store_idBTCPay store ID for the Authority's fee store
Optional
VariablePurposeDefault
CERTIFICATE_TTL_SECONDSHow long a signed certificate remains valid600 (10 min)
DPYC_ENFORCE_MEMBERSHIPEnable registry enforcement at certification timetrue
DPYC_REGISTRY_CACHE_TTL_SECONDSHow long to cache the DPYC community registry300
Per-Operator Schema Isolation

Each registered operator receives an isolated Neon schema (op_{hash}) with a dedicated Postgres LOGIN role. The Authority schema (authority) holds the Authority's own ledger. Operator schemas are provisioned automatically when the owner approves an adoption and access is enforced via role-based grants -- no cross-operator data access is possible.

Development

bash
python -m venv venvsource venv/bin/activatepip install -e ".[dev]"pytest tests/ -q

Key Generation

Nostr Signing Key (Schnorr certificates)

The Authority signs certificates with a Nostr nsec/npub keypair. Generate one using any Nostr key generator (e.g., nak key generate). The nsec goes in TOLLBOOTH_NOSTR_OPERATOR_NSEC; the npub is surfaced via operator_status for tollbooth-dpyc verification.

DPYC Identity (Nostr npub)

Each Authority has a Nostr keypair that identifies it on the DPYC Certification Chain:

bash
pip install nostr-sdkpython -c "from nostr_sdk import Keys; k = Keys.generate(); print(f'npub: {k.public_key().to_bech32()}'); print(f'nsec (back up!): {k.secret_key().to_bech32()}')"

Further Reading

The Phantom Tollbooth on the Lightning Turnpike — the full story of how we're monetizing the monetization of AI APIs, and then fading to the background.

License

Apache License 2.0 — see LICENSE and NOTICE for details.


Because every turnpike needs an authority. Not to control the road — just to make sure the stamps are real and the fares are fair.

來源:README.md,提交 68519ad

工具

0
該伺服器需要登入,因此 SourceWeft 無法在沒有帳號的情況下讀取其工具,也未收錄。已連接帳號所能看到的內容可能因帳號及其權限而異。

版本歷史

2
  1. v0.12.0最新Oct 21, 2026
  2. v0.11.9Sep 16, 2026

評分

已滿足適用檢查項的 85%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Authority 整合