Thebrain MCP
TheBrain MCP Server - FastMCP Python implementation for TheBrain API integration with Claude
Ask AI about Thebrain MCP
Powered by Claude Β· Grounded in docs
I know everything about Thebrain MCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
thebrain-mcp
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.
The First City
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.
Tollbooth Credits
| Tier | Cost | Examples |
|---|---|---|
| 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 |
Auth, balance checks, and credit purchases are always free. First-time users receive a seed balance on registration β enough to explore without purchasing credits up front.
BrainQuery (BQL)
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.
MATCH (n {name: "Projects"})-[:CHILD]->(m) RETURN m
MATCH (n) WHERE n.name =~ "quarterly review" RETURN n
MATCH (p {name: "Ideas"}) CREATE (p)-[:CHILD]->(n {name: "New Concept"})
MATCH (root {name: "Company"})-[:CHILD*1..3]->(d) WHERE d.name CONTAINS "Budget" RETURN d
Variable-length paths, multi-hop chains, compound WHERE with AND/OR/NOT/XOR, similarity search, and property existence checks. Full grammar in python/BRAINQUERY.md.
Getting Started
Connecting via Horizon MCP
Connect any MCP-compatible client (Claude Desktop, Cursor, your own agent) to the live endpoint:
https://personal-brain.fastmcp.app/mcp
No configuration needed β Horizon OAuth handles authentication automatically.
First Connection Walkthrough
session_statusβ Check your current session state.- Get a TheBrain API key at api.bra.in and find your brain ID in TheBrain's settings.
register_credentials(api_key, brain_id, passphrase)β Encrypts your credentials in the operator's vault. 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 activate_session(passphrase) at the start of each session.
Self-Hosting
For local installation, configuration, and the full tool reference, see python/README.md.
To run your own instance, set these environment variables:
| Variable | Purpose | Example |
|---|---|---|
THEBRAIN_API_KEY | Operator's TheBrain API key (for vault access) | your-thebrain-key |
THEBRAIN_DEFAULT_BRAIN_ID | Default brain ID for STDIO mode | uuid-of-brain |
THEBRAIN_API_URL | TheBrain API base URL | https://api.bra.in (default) |
THEBRAIN_VAULT_BRAIN_ID | Brain ID for the encrypted credential vault | uuid-of-vault-brain |
BTCPAY_HOST | BTCPay Server URL for credit purchases | https://btcpay.example.com |
BTCPAY_STORE_ID | BTCPay store ID | AbCdEfGh1234 |
BTCPAY_API_KEY | BTCPay API key with invoice + payout permissions | your-btcpay-api-key |
BTCPAY_TIER_CONFIG | JSON string mapping tier names to credit multipliers | {"default": {"credit_multiplier": 1}} |
BTCPAY_USER_TIERS | JSON string mapping user IDs to tier names | {"user_01KGZY...": "vip"} |
SEED_BALANCE_SATS | Free starter balance for new users (0 to disable) | 500 |
Actor Protocol
The BrainOperator class (in actor.py) satisfies OperatorProtocol from tollbooth-dpyc. It's a thin delegation layer over existing server.py tool functions.
from thebrain_mcp.actor import BrainOperator
from tollbooth import OperatorProtocol
assert isinstance(BrainOperator(), OperatorProtocol)
The actor exposes:
slugβ returns"brain"for tool-name prefixingtool_catalog()β returnsOPERATOR_BASE_CATALOG(19ToolPathInfoentries) β the canonical tool surface from tollbooth-dpyc
| Path | Tools | Status |
|---|---|---|
| Hot (local ledger) | check_balance, account_statement, account_statement_infographic, restore_credits, service_status | Implemented β delegates to server.py |
| Hot (Secure Courier) | session_status, request_credential_channel, receive_credentials, forget_credentials | Implemented β Nostr credential delivery with credential card DM |
| Delegation (Authority) | purchase_credits, check_payment | Implemented β auto-certifies via MCP-to-MCP |
| Delegation (Authority) | certify_credits, register_operator, operator_status | Stub β connect to the Authority MCP directly |
| Delegation (Oracle) | lookup_member, how_to_join, get_tax_rate, about, network_advisory | Implemented β MCP-to-MCP via OracleClient |
Payment processing auto-certifies via the Authority (server-to-server OAuth). Secure Courier delivers encrypted credentials via Nostr DMs with automatic credential card (ncred1...) DM-back on first receipt. Oracle community tools route directly to the DPYC Oracle β free and unauthenticated.
Architecture
The Tollbooth ecosystem is a three-party protocol spanning three repositories:
| Repo | Role |
|---|---|
| tollbooth-authority | The institution β tax collection, Schnorr signing, purchase order certification |
| tollbooth-dpyc | The booth β operator-side credit ledger, BTCPay client, tool gating |
| dpyc-oracle | The concierge β community onboarding, tax rates, membership lookup |
| thebrain-mcp (this repo) | The first city β reference MCP server powered by Tollbooth |
See the Three-Party Protocol diagram for the full architecture. The operator-side flow is also available.
Project Structure
thebrain-mcp/
βββ python/ # FastMCP server package
β βββ src/thebrain_mcp/ # Server source, BQL engine, Tollbooth
β βββ tests/ # Test suite (525+ tests)
β βββ README.md # Install, config, tools, usage
β βββ BRAINQUERY.md # BQL grammar and reference
βββ docs/
β βββ diagrams/ # Architecture and protocol flow diagrams
βββ LICENSE # Apache License 2.0
βββ NOTICE # Attribution notice
Prior Art & Attribution
The methods, algorithms, and implementations contained in this repository may represent original work by Lonnie VanZandt, first published on February 16, 2026. This public disclosure establishes prior art under U.S. patent law (35 U.S.C. 102).
All use, reproduction, or derivative work must comply with the Apache License 2.0 included in this repository and must provide proper attribution to the original author per the NOTICE file.
How to Attribute
If you use or build upon this work, please include the following in your documentation or source:
Based on original work by Lonnie VanZandt and Claude.ai
Originally published: February 16, 2026
Source: https://github.com/lonniev/thebrain-mcp
Licensed under Apache License 2.0
Visit the technologist's virtual cafe for Bitcoin advocates and coffee aficionados at stablecoin.myshopify.com.
Patent Notice
The author reserves all rights to seek patent protection for the novel methods and systems described herein. Public disclosure of this work establishes a priority date of February 16, 2026. Under the America Invents Act, the author retains a one-year grace period from the date of first public disclosure to file patent applications.
Note to potential filers: This public repository and its full Git history serve as evidence of prior art. Any patent application covering substantially similar methods filed after the publication date of this repository may be subject to invalidation under 35 U.S.C. 102(a).
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.
Trademarks
DPYC, Tollbooth DPYC, and Don't Pester Your Customer are trademarks of Lonnie VanZandt. See the TRADEMARKS.md in the dpyc-community repository for usage guidelines.
License
Apache License 2.0 β see LICENSE and NOTICE for details.
Because in the end, the tollbooth was never the destination. It was always just the beginning of the journey.
