exocortex-mcp

AlexHagemeister/exocortex-mcp Checked 5 hours ago

Remote MCP server for an exocortex vault — query your compiled knowledge and capture to its inbox from claude.ai, the Claude app, or any MCP client

Remote MCP server for an exocortex vault — your compiled knowledge, reachable from claude.ai, the Claude mobile app, and any MCP client, wherever you are. Three tools, preserving the vault's single-pipeline rule in infrastructure: Nothing here can edit your wiki, your notes, or your sources — captures enter through the same gate as everything else, and your vault's maintainer files them on the next process-inbox run.

Summary extracted from the README.

exocortex-mcp

CI Release License: MIT Ko-fi

Remote MCP server for an exocortex vault — your compiled knowledge, reachable from claude.ai, the Claude mobile app, and any MCP client, wherever you are.

Companion component, not a requirement. The vault works fully without this server. What it adds is the away-from-desk loop: query your wiki mid-conversation on your phone, and capture thoughts that land in your vault's normal ingest pipeline — the driving use case is talking to Claude while out, with your exocortex along for the ride.

What it does

Three tools, preserving the vault's single-pipeline rule in infrastructure:

Tool Kind What it does
query_wiki read Status-weighted search over wiki/ — verified pages rank above draft (×1.5 vs ×1.0), matching the vault's "readers weight by status" invariant.
get_page read Fetch any repo-relative file (or list a directory).
capture_to_inbox the sole write Writes a frontmattered markdown source into sources/inbox/ via a dedicated inbox-drops branch.

Nothing here can edit your wiki, your notes, or your sources — captures enter through the same gate as everything else, and your vault's maintainer files them on the next process-inbox run.

How it fits

claude.ai / Claude app / Claude Code ──HTTP──▶ exocortex-mcp (your cloud host)
                                                  │  clone + pull (read)
                                                  │  push inbox-drops (write)
                                                  ▼
                                   your vault's private GitHub repo
                                                  ▲
                                                  │  daily vault-snapshot
                                                  │  (commit + pull --rebase + push)
                                       your local vault (the working copy)
  • The data source is your vault's git remote, not the live working copy — the private repo you set up in the program's SETUP step 4. Staleness is bounded by your snapshot cadence; with the default daily snapshot that's accepted by design.
  • The server keeps a shallow working clone under DATA_DIR/mirror, pulling at most every SYNC_INTERVAL_SECONDS.

The capture return path

Captures go through a dedicated branch, never directly to main:

  1. The server commits each capture to the inbox-drops branch (based on main, so origin/main...inbox-drops is exactly the pending captures) and pushes it.
  2. On the machine that has the vault, scripts/consume-inbox-drops.sh copies pending captures into the vault's sources/inbox/ and force-resets the branch to main. Run it from your snapshot routine, or by hand.
  3. From there the vault's normal ingest pipeline takes over.

Why a branch: it keeps main single-writer from your own machine — no push races between the server and your snapshots — and remote surfaces stay on the inbox pipeline. A side store outside git was rejected to keep one data path and one credential.

Auth

claude.ai custom connectors currently support OAuth 2.1 (heavyweight for a personal server) or no auth; there is no static-header option in the connector UI. This server ships a middle path:

  • A single shared secret, EXOCORTEX_TOKEN (openssl rand -hex 32), compared timing-safely.
  • Accepted as Authorization: Bearer <token> — for Claude Code (claude mcp add --transport http exocortex <url>/mcp --header "Authorization: Bearer <token>") and the API's MCP connector.
  • Also accepted as a secret URL path segment — https://<host>/t/<token>/mcp — which is what you paste into the claude.ai custom-connector dialog (treat that URL as a credential).

This is personal-server auth: one user, one secret. If your deployment ever becomes multi-user, the upgrade path is a proper OAuth 2.1 authorization server per the MCP auth spec.

Guest access

Optionally, the same deployment can serve a second audience: trusted people you hand a guest URL to, so their Claude can query your exocortex. There is no manifest file anywhere — the manifest is what the server answers during the MCP handshake, and the token a connection authenticated with picks the answer. Your token sees the server above, unchanged. The guest token sees a different face:

  • Server name <owner>-exocortex, with instructions written for an agent that has never heard of your vault: what this is, that pages are a compiled record of your thinking (not you speaking), and how to weight verified vs draft.
  • query_wiki and get_page, scoped to wiki/ — never sources/, notes/, or the day logs (wiki/log/ and its derived index). Directory listings are filtered the same way, the checks are case-folded (a case-insensitive filesystem can't be used to sneak past the deny list), and a symlink committed under wiki/ is re-checked against where it actually resolves. Everything else under wiki/ is in scope by default — if your wiki has folders about people or your personal life, decide deliberately whether guests should read them. EXOCORTEX_GUEST_DENY adds comma-separated prefixes to the deny list (e.g. wiki/people/,wiki/life/).
  • leave_note_for_<owner> instead of capture_to_inbox: guests can drop a note into your review inbox, but the server composes the provenance itself (guest connector: Anna (via their Claude), <date> — the marker leads, so no self-reported name can make it read like your own provenance), and the file is named <date>-guest-note-<slug>.md so drops are recognizable at a glance.
  • Every guest tool requires a from field naming the person, and each call is logged ([guest] Anna: query_wiki "..."), so your host's logs are the query log.

Enable it by setting EXOCORTEX_GUEST_TOKEN (a second openssl rand -hex 32 — the server refuses to boot if it equals EXOCORTEX_TOKEN, since that would silently make every guest an owner) and EXOCORTEX_OWNER_NAME (e.g. Alex). Then hand each trusted person https://<host>/t/<guest-token>/mcp to paste into Settings → Connectors → Add custom connector. The URL is the credential: everyone holding it is "a trusted friend" to the server, and rotating the env var revokes them all. If you ever want per-person revocation or real (non-self-reported) attribution, that's the moment to mint per-person tokens — or graduate to OAuth.

Public access

A third face, for an audience you do not know: a token you embed server-side on your own website (a chatbot that answers questions about you, say), never in a browser. Same server, same mechanism as the guest tier (the token picks the manifest), with the opposite trust posture:

  • Server name <owner>-exocortex-public, with instructions for a client talking to strangers: speak about you in the third person and never as you, weight verified over draft, and treat anything it cannot find as simply not public, with no guessing about why.
  • query_wiki and get_page only. There is no write tool of any kind, no from field, and no note drop: the public is anonymous by design, and abuse control (rate limits, bot checks) belongs to the site that holds the token, not to this server.
  • Scope is allowlist-first: a path is readable only when it sits under an entry of EXOCORTEX_PUBLIC_ALLOW (default wiki/) and under no entry of EXOCORTEX_PUBLIC_DENY, on top of the built-in denials of wiki/log/ and wiki/log.md, wiki/chronicle/, wiki/connections/, and wiki/people/. Deny always wins, so EXOCORTEX_PUBLIC_ALLOW=wiki/life/ with EXOCORTEX_PUBLIC_DENY=wiki/life/health/ does what it reads like. Entries are comma-separated folder prefixes, or single files when they end in .md. Changing the scope is an env change and a restart, no code.
  • Anything outside the scope answers Not found: <path>, byte for byte what a nonexistent path returns, so a probe cannot map the deny list. Search never surfaces excluded pages, directory listings omit them, the checks are case-folded, traversal and dot segments are refused, and symlinks are checked where they resolve (both for reads and before a name appears in a listing).
  • A second layer under the path scope, because a denied topic still gets mentioned in passing on allowed pages: EXOCORTEX_PUBLIC_REDACT is a comma-separated list of blocked terms (list the variants yourself: take3, take 3, take three). On the public token, a page whose path, title, or description mentions a term is not-found and absent from search and listings; on every other page the paragraph, list item, table row, quote line, fenced block, or titled section (heading through the next heading at its level) that mentions a term is dropped before the page is served, and search neither matches on the term nor shows it in a snippet. Nothing marks a removal. Matching is case-insensitive on whole words, so trep never fires inside entrepreneur. The model only says what it reads, which is why the filter sits here and not on the model's output.
  • Each call is logged ([public] query_wiki "..."), so your host's logs are the query log. Nothing identifies the visitor.

Enable it with EXOCORTEX_PUBLIC_TOKEN (a third openssl rand -hex 32; the server refuses to boot if it equals either other token or is too short) and EXOCORTEX_OWNER_NAME. The owner and guest tiers are unchanged whether or not it is set. Hand your server-side client https://<host>/mcp with Authorization: Bearer <public-token> (the AI SDK's createMCPClient with an http transport takes exactly that). The /t/<token>/mcp form works too, but a URL that is a credential has no business in a public site's config.

Two things this tier deliberately does not do, and where they live instead: it does not understand topics beyond the term list (a page can talk around a blocked name without using it; the calling site's system prompt and its own tests own that seam), and it does not rate-limit (the site's edge does).

Deploy your own (Railway, ~10 minutes)

Any Node host works; Railway is what the reference deployment uses.

  1. Create a fine-grained GitHub PAT scoped to your vault repo only, with Contents: Read and write (write is needed for inbox-drops pushes).
  2. New Railway service from your clone of this repo. Nixpacks detects Node; it runs npm run build then npm start.
  3. Set variables:
    • MIRROR_REPO_URL=https://x-access-token:<PAT>@github.com/<you>/<your-vault-repo>.git
    • EXOCORTEX_TOKEN=<openssl rand -hex 32>
  4. Note the service's public domain, then add the connector in claude.ai: Settings → Connectors → Add custom connector with https://<domain>/t/<token>/mcp.

The clone lives on the ephemeral filesystem and is re-cloned on each deploy — fine, since your git remote is the source of truth.

Make it Claude's primary memory

The connector gives Claude the tools; this tells Claude to reach for them. Paste the block below into claude.ai Settings → Profile → personal preferences (it applies across all your chats), editing to taste:

MEMORY

My personal knowledge base is the exocortex-mcp connector (tools: query_wiki, get_page, capture_to_inbox). It is the canonical store for who I am, my projects, people in my life, past decisions, and preferences. Treat it as your primary memory, ahead of your built-in memory.

Retrieval. When a question touches my life, work, projects, people, or history, or when context about me would change your answer, search the exocortex with query_wiki before answering from your built-in memory or general knowledge. Use get_page to read full pages from hits, and mention which page you are drawing from (for example, "per wiki/projects/my-project.md"). Results carry a status field. Verified pages are human-confirmed. Draft pages are machine-written and may contain inference, so calibrate your confidence accordingly. If the exocortex and your built-in memory disagree, the exocortex wins. If the exocortex and I disagree in chat, I win, and that is worth capturing as a correction.

Capture. When I say "remember this," state a decision, correct something you got wrong about me, or share something durably worth keeping (a preference, a plan, a fact about my life), save it with capture_to_inbox. Give it a clear title, the substance in markdown, and provenance like "the user, in conversation, [date]". Corrections to existing knowledge are new capture entries, never described as edits. Do not capture small talk or transient logistics. Capture what would matter in a month. Tell me in one line when you have captured something.

Limits. Captures reach the vault only when the consumer job runs on the machine that owns it. Check your own schedule and state it here, since the honest cadence is what stops an agent hedging wrongly: the reference deployment consumes inside an hourly job that only fires while the laptop is awake, so a capture from minutes ago may not be searchable yet and recent events may be missing entirely. Say so rather than concluding something does not exist. If the connector is unavailable in a chat, say so and fall back to built-in memory rather than guessing.

Why "primary, ahead of built-in" rather than "instead of": precedence plus capture is enforceable by prompt; actually disabling built-in memory is a claude.ai settings toggle, not something a prompt can do.

Monitoring

GET /healthz is shallow liveness. GET /healthz/deep is the monitoring endpoint: it exercises the mirror sync and inspects the inbox-drops backlog, returning 503 when sync fails or captures sit undrained for more than 36 hours (two missed nightly consumer runs). One probe therefore catches process-down, sync-broken (bad PAT, GitHub unreachable), and consumer-not-running. It exposes counts and ages only, never vault content.

.github/workflows/healthcheck.yml probes it every 15 minutes; set the HEALTHCHECK_URL repository secret to your deployment's /healthz/deep URL and GitHub emails you on failure (a secret so your endpoint stays out of publicly readable run logs; the probe skips quietly when it's unset, so forks don't get failure spam). Caveats: cron runs can be delayed, and GitHub pauses scheduled workflows after ~60 days of repo inactivity (it emails first — one click keeps it alive).

Local development

cp .env.example .env   # point MIRROR_REPO_URL at a local vault path, set a token
npm install
npm run dev

Smoke test:

curl -s localhost:3000/healthz
curl -s localhost:3000/mcp \
  -H "Authorization: Bearer $EXOCORTEX_TOKEN" \
  -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Design notes

  • Data source is the vault's git remote (clone + pull), not a live mount; snapshot-bounded staleness is accepted.
  • Three tools; capture_to_inbox is the only write, and it writes to the inbox, not the wiki.
  • One data path, one credential: everything rides the vault repo and one scoped PAT.