FastMCP server for TheBrain API โ AI access to a personal knowledge graph, Tollbooth-monetized
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ or use 1-click editor setup below.
๐ก Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
The first city on the Lightning Turnpike.
An MCP server that gives AI agents read-write access to a personal knowledge graph โ and pays for itself with Bitcoin Lightning micropayments.
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.
Every turnpike needs its first city. Before the booths can collect fares and the authority can stamp purchase orders, someone has to build a destination worth driving to.
thebrain-mcp is that city โ a FastMCP service deployed on Horizon that bridges AI agents to TheBrain, a personal knowledge graph of 9,000+ interconnected thoughts built over a decade. Every thought, link, attachment, and note operation maps directly to TheBrain's cloud API at api.bra.in.
It's also the proving ground for Tollbooth DPYCโข โ the first MCP server where every tool call is metered via Bitcoin Lightning micropayments. Pre-fund, use, top up. No subscriptions, no API keys tied to billing accounts, no fiat payment processors. The novel contribution: an MCP server architecture where the operator monetizes AI agent access through Lightning micropayments without ever pestering the client mid-conversation.
Connect any MCP-compatible client (Claude Desktop, Cursor, your own agent) to the live endpoint:
No configuration needed โ Horizon OAuth handles authentication automatically.
session_status โ Check your current session state.how_to_join() tool โ this is the npub you registered as a DPYCโข Citizen, your identity for credit operations.request_credential_channel(recipient_npub=<patron_npub>) โ opens a Secure Courier channel; sends a welcome DM to your Nostr client.{"api_key": "...", "brain_id": "..."}receive_credentials(sender_npub=<patron_npub>) โ vaults your credentials and activates the session. A seed balance is granted automatically.list_brains โ set_active_brain โ Select which brain to work with.brain_query โ Start exploring your knowledge graph.Returning users: call receive_credentials(sender_npub=<patron_npub>) โ vault-first lookup activates instantly, no relay I/O needed.
Credentials are delivered via encrypted Nostr DMs โ they never appear in the chat window. On first-time relay receipt, the service sends an ncred1... credential card back to the patron via DM for scan-and-paste reuse.
Human in the loop: The patron must consciously approve each credential delivery via their Nostr client. Never auto-poll or auto-retry receive_* calls โ each receive_credentials drains the relay destructively (NIP-09 deletion after pickup). Call it exactly once per credential delivery.
| Category | Pricing hint | Examples |
|---|---|---|
free | 0 sats | session_status, check_balance, check_price |
read | 1 sat | get_thought, search_thoughts, get_note |
write | 5 sats | create_thought, create_link, update_thought |
heavy | 10 sats | brain_query, get_modifications |
Actual prices are set dynamically by the operator's pricing model in Neon via api_sats per tool. Auth and balance tools are always free. First-time users receive a seed balance on onboarding โ enough to explore without purchasing credits up front.
Credits are issued as tranches with a tranche_lifetime (TTL). Tranches are consumed FIFO; expired tranches are pruned automatically. Use check_balance to see your balance, active tranches, and usage history. Top up via purchase_credits with Bitcoin Lightning.
npub (Nostr public key), not an email or username. The nsec (private key) stays with the patron โ never shared, never sent to a service.proof parameter. The proof is a JSON-serialized Nostr event signed by the patron's nsec, binding their npub to the specific tool call.A Cypher-subset query language purpose-built for TheBrain. Agents and humans express graph operations in the same formalism โ full CRUD via MATCH, CREATE, SET, MERGE, and DELETE.
Variable-length paths, multi-hop chains, compound WHERE with AND/OR/NOT/XOR, similarity search, and property existence checks. Full grammar in BRAINQUERY.md.
When a tool call fails, read the response โ it tells you what happened and what to do next. Credential lifecycle states are not errors; they are expected situations with clear guidance.
| Situation | What to do |
|---|---|
| proof is required | Call request_npub_proof then receive_npub_proof โ a fresh request/receive cycle. The cache expires after ~1 hour. |
| Insufficient credit balance | Call purchase_credits to top up. |
| Cold start / session not ready | Retry in 10-15 seconds. Inline retry is available in v0.13.5+. |
| Credentials not found | Follow the Secure Courier onboarding flow (step 3 above). |
| Upstream API error | Only if the error explicitly mentions TheBrain API failure. Not a credential or billing issue. |
Don't Pester Your Customer: Do NOT ask the patron to re-authenticate or re-do the Courier flow unless the error message specifically says credentials are missing or expired.
For local installation and setup, see INSTALL.md and QUICKSTART.md.
To run your own instance, set these environment variables:
| Variable | Purpose |
|---|---|
TOLLBOOTH_NOSTR_OPERATOR_NSEC | Operator's Nostr secret key -- the single bootstrap key for identity, Secure Courier DMs, and audit signing |
This is the only env var required to start. Certified operators bootstrap their Neon database URL from the Authority via encrypted Nostr DM -- NEON_DATABASE_URL is not read from the environment.
| Variable | Purpose |
|---|---|
TOLLBOOTH_NOSTR_RELAYS | Comma-separated relay URLs (overrides defaults) |
THEBRAIN_API_URL | TheBrain API base URL (default: https://api.bra.in) |
SEED_BALANCE_SATS | Free starter balance for new users (0 to disable) |
CREDIT_TTL_SECONDS | Tranche lifetime in seconds (default: 604800 = 7 days) |
DPYC_REGISTRY_CACHE_TTL_SECONDS | How long to cache the DPYC community registry (default: 300) |
CONSTRAINTS_ENABLED | "true" to enable constraint engine evaluation on tool calls |
All secrets flow through Secure Courier -- they never appear as environment variables:
| Credential | Delivery |
|---|---|
| TheBrain API key + brain ID | Patron delivers via encrypted Nostr DM |
BTCPay credentials (btcpay_host, btcpay_api_key, btcpay_store_id) | Operator delivers via Secure Courier |
Note:
THEBRAIN_API_KEYis not an environment variable. Patrons deliver their TheBrain API key and brain ID via Secure Courier (encrypted Nostr DM). Only the operator's nsec is configured as an env var.
The server exposes the standard Tollbooth DPYCโข operator surface via
register_standard_tools() from tollbooth-dpyc,
plus its domain tools. Tools fall into three paths in the DPYC three-actor
topology (Operator / Authority / Oracle):
No reviews yet โ be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/personalbrain-mcp)<a href="https://allmcps.com/mcp/personalbrain-mcp"><img src="https://allmcps.com/api/badge/personalbrain-mcp?style=directory" alt="Personalbrain MCP on AllMCPs" /></a>