Skip to content

Latest commit

 

History

History
63 lines (48 loc) · 1.88 KB

File metadata and controls

63 lines (48 loc) · 1.88 KB

MCP Client Setup (Claude Code)

How to wire Claude Code to the memex /mcp endpoint so it can use the 5 tools (capture_thought, semantic_search, get_thought, delete_thought, list_recent) directly from inside a session.

Prerequisites

~/.secrets exports these (already the case if you use scripts/memex.sh):

export MEMEX_URL=https://serverless-memex.mattjacobs.workers.dev
export MEMEX_CLIENT_ID=...      # Cloudflare Access service token client ID
export MEMEX_CLIENT_SECRET=...  # ... and its secret

Register

source ~/.secrets
claude mcp add --transport http --scope user \
  memex "$MEMEX_URL/mcp" \
  --header "CF-Access-Client-Id: $MEMEX_CLIENT_ID" \
  --header "CF-Access-Client-Secret: $MEMEX_CLIENT_SECRET"

--scope user writes to ~/.claude.json (mode 600), not a project-level config. The CLI expands the env vars at registration time and stores the literal values in ~/.claude.json — there's no env-var indirection in the config format. The tradeoff is acceptable for a personal machine since the file is user-private; on a shared host, prefer a per-machine service token bound to a stricter Access policy.

Smoke test

claude mcp list | grep memex
# expected: memex: <url> (HTTP) - ✓ Connected

Inside Claude Code, /mcp lists the connected servers and their tools. Expect five under memex.

Rotate the service token

  1. Refresh in CF dashboard (Access → Service Auth → memex-cli → Refresh).
  2. Update MEMEX_CLIENT_ID / MEMEX_CLIENT_SECRET in ~/.secrets.
  3. Re-register so the literal values in ~/.claude.json get updated:
claude mcp remove memex
source ~/.secrets
claude mcp add --transport http --scope user \
  memex "$MEMEX_URL/mcp" \
  --header "CF-Access-Client-Id: $MEMEX_CLIENT_ID" \
  --header "CF-Access-Client-Secret: $MEMEX_CLIENT_SECRET"

Remove

claude mcp remove memex