This guide explains how to connect the Neotoma MCP server to Claude Code for localhost agent integration.
For other integrations, see:
mcp_cursor_setup.md- Cursor integrationchatgpt_actions_setup.md- ChatGPT Custom GPT setup
Use stdio when Claude Code runs on the same machine as the Neotoma repo. Claude Code spawns the server; no separate HTTP process. Use HTTP for remote access or when connecting to a tunnel/deployed server.
| Criterion | Stdio | HTTP |
|---|---|---|
| Use case | Claude Code on same machine | Remote, tunnel, deployed |
| After sleep | Toggle off/on; client re-spawns | Restart HTTP server, then toggle |
| Unified config | .cursor/mcp.json + npm run sync:mcp propagates to .mcp.json and Codex |
Separate config per client |
Recommendation: Use stdio for local Claude Code. See agent_cli_configuration.md for the unified .cursor/mcp.json + sync workflow shared with Cursor and Codex.
Claude Code represents a new paradigm of localhost AI agents that run on your computer with private environment, data, and context, as Karpathy describes. Neotoma aligns perfectly with this architecture:
- Privacy-First: Both Claude Code and Neotoma prioritize user-controlled, private data
- Localhost Architecture: Agents access structured memory locally, not through cloud APIs
- Cross-Platform: Neotoma's MCP integration works seamlessly with Claude Code's localhost approach
- Structured Memory: Claude Code can leverage Neotoma's deterministic extraction and entity resolution for reliable context
This integration validates the localhost agent paradigm: agents running on your computer, hand-in-hand with your private data substrate.
- Claude Code installed - Desktop application with MCP support
- Node.js v18.x or v20.x installed
- Local storage initialized (see
docs/developer/getting_started.md) - Environment variables configured in
.env
The MCP server needs to be built before Claude Code can use it:
npm run build:serverThis compiles TypeScript to JavaScript in the dist/ directory.
Note: For active development, use npm run dev:server:tunnel to run the server and tunnel together.
Create .env in the project root if needed. For local storage, no env vars are required (defaults: ./data, ./data/neotoma.db, ./data/sources). See Getting started for optional overrides.
Security Note: Never commit .env to git. It's already in .gitignore.
IMPORTANT: Authentication is required. MCP connections must authenticate using OAuth (recommended) or session tokens (deprecated).
- Sign in to the Neotoma web UI (http://localhost:5195)
- Navigate to MCP Setup page
- Go to "OAuth Connection" tab
- Enter a connection ID (or click "Generate"):
- Example:
claude-2025-01-21-abc123
- Example:
- Click "Start OAuth Flow"
- Click "Open Authorization Page" to open browser
- Approve the connection in your browser
- Wait for confirmation that connection is active
- Copy your
connection_idfor use in MCP configuration
Benefits:
- Tokens automatically refresh (no manual updates)
- More secure than session tokens
- Connections persist until revoked
Will be removed in a future version. Use OAuth instead.
- Sign in to the Neotoma web UI (http://localhost:5195)
- Click "MCP Setup" button
- Go to "Session Token (Deprecated)" tab
- Copy your session token
Use the same stdio config as Cursor and Codex. Add to .cursor/mcp.json in the Neotoma repo, then sync:
cd /path/to/neotoma
# Add neotoma-dev and neotoma to .cursor/mcp.json (see mcp_cursor_setup.md Option A)
npm run sync:mcpThe sync updates .mcp.json, which Claude Code may use when opening the Neotoma project. If Claude Code uses user-level config only, copy the synced entries from .mcp.json into your Claude config (see Option B).
Claude Code config location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Stdio with wrapper scripts (recommended):
{
"mcpServers": {
"mcpsrv_neotoma_dev": {
"command": "/absolute/path/to/neotoma/scripts/run_neotoma_mcp_stdio.sh"
},
"mcpsrv_neotoma": {
"command": "/absolute/path/to/neotoma/scripts/run_neotoma_mcp_stdio_prod.sh"
}
}
}Replace /absolute/path/to/neotoma with your repo path. No cwd or args needed. Claude Desktop requires local MCP server IDs to use the mcpsrv_* format; neotoma mcp config migrates legacy neotoma-dev / neotoma keys in claude_desktop_config.json. When encryption is off (default), no connection ID required. When encryption is on, set NEOTOMA_CONNECTION_ID in .env.
Alternative (command + args + cwd):
{
"mcpServers": {
"mcpsrv_neotoma_dev": {
"command": "/absolute/path/to/node",
"args": ["/absolute/path/to/neotoma/dist/index.js"],
"cwd": "/absolute/path/to/neotoma",
"env": {
"NEOTOMA_ENV": "development",
"NEOTOMA_CONNECTION_ID": "claude-2025-01-21-abc123"
}
}
}
}Use which node for the node path. For prod, set NEOTOMA_ENV": "production".
After configuring the MCP server:
- Quit Claude Code completely (not just close the window)
- Restart Claude Code
- Verify connection in a new conversation
Once connected, test the available Neotoma actions:
submit_payload- Store structured data from conversationsretrieve_records- Query records with filtersretrieve_entities- Find entities (companies, people, locations)get_entity_snapshot- Get current state of an entitylist_timeline_events- Get chronological eventsget_graph_neighborhood- Explore relationshipsupload_file- Upload and extract data from filesget_file_url- Get signed URL for a file
Store contextual data:
Remember that I met with Acme Corp today to discuss the Q4 budget. The meeting was productive and we agreed on $50,000 allocation.
Query records:
What companies have I mentioned in my records?
Retrieve entities:
Show me all the people I've referenced recently.
Upload a file:
Can you upload this invoice PDF and extract the structured data?
Neotoma includes project-specific instructions for Claude Code that ensure consistent agent behavior with repository conventions and constraints.
Generated files:
.claude/CLAUDE.md— Primary entrypoint with document loading order, core constraints, and quick reference.claude/rules/— ~45 modular instruction files (foundation + repository rules).claude/skills/— Slash-invokable workflows (e.g./release,/fix_feature_bug).claude/settings.json— Permissions and autonomous execution config
Sources:
foundation/agent_instructions/cursor_rules/— Foundation-level rulesfoundation/agent_instructions/cursor_commands/— Foundation-level commandsdocs/**/*_rules.mdc— Repository-specific rules
Instructions are generated from sources via scripts/setup_claude_instructions.sh. They sync automatically on git commit when sources change, but you can manually sync:
./scripts/setup_claude_instructions.shWhen to sync:
- After pulling foundation updates
- After editing rule sources in
docs/orfoundation/ - When adding new repository-specific rules
Auto-sync: Pre-commit hook automatically syncs .claude/ when rule/command sources are staged.
1. Autonomous execution:
- Claude proceeds without asking for routine implementation, tests, docs, lint fixes
- Stops only for high-stakes architectural/design ambiguity that could lead to wrong assumptions
- See
.claude/rules/autonomous_execution.mdfor details
2. Permissions:
defaultMode: acceptEdits— File edits auto-accepted- Broad
allowrules for npm, git, and project scripts denyrules for.env,docs/private/, and other sensitive paths
3. Document loading order:
- Every session loads
docs/context/index_rules.mdcfirst (documentation map) - Then foundation docs from
docs/foundation/ - Then task-specific docs (architecture, subsystems, testing)
4. Core constraints:
- State Layer boundaries (no strategy/execution logic)
- Determinism (hash-based IDs, no randomness, stable sorting)
- Immutability (observations/source never modified after creation)
- Schema-first processing
- Full constraint list in
.claude/CLAUDE.md
NEVER edit files in .claude/ directly — they are generated and will be overwritten.
To modify instructions:
- Edit source files:
- Foundation rules:
foundation/agent_instructions/cursor_rules/*.mdc - Foundation commands:
foundation/agent_instructions/cursor_commands/*.md - Repository rules:
docs/**/*_rules.mdc
- Foundation rules:
- Run sync script:
./scripts/setup_claude_instructions.sh - Commit changes (auto-syncs via pre-commit hook)
Claude Code supports skills that work like slash commands:
Available skills:
/release— Create a new release following release workflow/fix_feature_bug— Fix a bug in a feature unit with error classification/create_feature_unit— Create a new feature unit with spec and manifest/setup_symlinks— Set up project symlinks/pull— Pull foundation submodule updates/commit— Create a git commit following conventions
Skills are generated from foundation commands. To add repository-specific skills, add markdown files to foundation commands or document workflows in rules.
.claude/settings.json configures:
Permissions:
- Allow: npm scripts, git commands, project scripts, file edits/reads
- Deny:
.envfiles,docs/private/, destructive commands - DefaultMode:
acceptEdits(auto-accept file edits)
Local overrides:
- Create
.claude/settings.local.jsonfor user-specific settings - Already gitignored (Claude creates this automatically)
No secrets in settings: Environment variables go in .env, not in .claude/settings.json.
Claude Code's localhost architecture aligns perfectly with Neotoma's privacy-first design:
Privacy-First Integration:
- All data stays on your computer
- No cloud intermediary for memory access
- User-controlled memory with end-to-end encryption
- Never used for training or provider access
Deterministic Context:
- Claude Code accesses Neotoma's deterministic extraction
- Same queries return consistent, reproducible results
- Verifiable domain for stored data
- Compensates for LLM "jagged intelligence"
Cross-Platform Memory:
- Same Neotoma memory works with Cursor, ChatGPT, and Claude Code
- No platform lock-in
- Memory persists across all AI tools
This represents a new paradigm: localhost agents with private data substrates, not cloud deployments with platform-locked memory.
This error means the MCP server didn't receive valid authentication during initialization.
Solutions (OAuth - Recommended):
-
Verify connection is active:
- Sign in to Neotoma web UI (http://localhost:5195)
- Go to MCP Setup → OAuth Connection tab
- Check that your connection ID shows "active" status
- If not active, create a new connection (see Step 3 above)
-
Check environment variable in config:
# macOS cat ~/Library/Application\ Support/Claude/claude_desktop_config.json | grep NEOTOMA_CONNECTION_ID # Linux cat ~/.config/Claude/claude_desktop_config.json | grep NEOTOMA_CONNECTION_ID
Should show:
"NEOTOMA_CONNECTION_ID": "your-connection-id" -
Verify connection ID matches:
- Connection ID in config must match the active connection in web UI
- Connection IDs are case-sensitive
-
Create new connection if needed:
- If connection was revoked or expired, create a new one via web UI
- Update config file with the new connection ID
-
Restart Claude Code completely (quit and reopen, not just reload)
If using Session Token (Deprecated - Not Recommended):
- Switch to OAuth (strongly recommended) - more reliable and secure
- Or get a fresh session token:
- Sign in to the Neotoma web UI
- Click "MCP Setup" → "Session Token (Deprecated)" tab
- Copy your session token
- Update
NEOTOMA_SESSION_TOKENin config file - Restart Claude Code
The OAuth connection doesn't exist, was revoked, or the connection ID is incorrect.
Solutions:
-
Verify connection exists:
- Sign in to Neotoma web UI (http://localhost:5195)
- Go to MCP Setup → OAuth Connection tab
- Check if your connection ID appears in the list
- Status should be "active" (not "pending" or "expired")
-
If connection doesn't exist or was revoked:
- Create a new connection via web UI (MCP Setup → OAuth Connection tab)
- Follow OAuth flow: enter connection ID → Start OAuth Flow → Approve in browser
- Wait for "active" status confirmation
-
Update config file with the correct connection ID
-
Restart Claude Code completely
The session token is invalid or expired. OAuth is recommended to avoid this issue.
Solutions:
-
Switch to OAuth (strongly recommended):
- Follow Step 3 above to create an OAuth connection
- Update config to use
NEOTOMA_CONNECTION_IDinstead ofNEOTOMA_SESSION_TOKEN - OAuth tokens automatically refresh and don't expire
- Restart Claude Code
-
If you must use session token (deprecated):
- Sign out and sign back in to the Neotoma web UI to get a fresh token
- Copy the new token from the MCP Setup → "Session Token (Deprecated)" tab
- Update config file with the new token
- Restart Claude Code
- Note: Session tokens expire when you sign out or after inactivity
Solutions:
- Ensure
npm run build:servercompleted successfully - Verify
dist/index.jsexists - Use absolute paths in config (not
~or relative paths) - Check node executable:
which node - Verify
cwdpoints to Neotoma project root
Solutions:
- Verify
.envfile exists in project root (not indist/) if using custom paths - Check
cwdin config points to project root (where.envis) - Run
neotoma initto create data directory and database - Test connection:
npm test
Solutions:
- Completely quit and restart Claude Code (not just reload)
- Check config file syntax (valid JSON)
- Verify MCP server is running in background
- Try rebuilding:
npm run build:server - Check Claude Code logs for errors
This means Claude Code can't find the node executable.
Solutions:
- Use absolute path to node:
which node(macOS/Linux) - If using nvm, use the full nvm path (e.g.,
/Users/username/.nvm/versions/node/v20.10.0/bin/node) - Avoid shell aliases or symbolic links
Solutions:
- Ensure dependencies installed:
npm install - Rebuild:
npm run build:server - Check
dist/directory contains all necessary files
If you're actively developing the MCP server:
-
Run automatic rebuild in watch mode:
npm run dev:server:tunnel
This runs
tsc --watchand automatically rebuildsdist/on file changes. -
Restart Claude Code after code changes to reload the MCP server
- Make code changes
- Rebuild:
npm run build:server - Restart Claude Code to pick up changes
If you use Claude Code from different machines or profiles:
-
Build once in the Neotoma project:
cd /path/to/neotoma npm run build:server -
Configure each Claude Code instance with the same MCP server path
-
For auto-rebuild (development):
npm run dev:server:tunnel
Keep this running to watch for changes.
All instances will share the same Neotoma database (local SQLite).
Localhost Advantages:
- All MCP communication happens locally via stdin/stdout
- No network requests for memory access
- User-controlled memory with encryption
- Data stays on your computer (local storage)
Security Best Practices:
- Use environment variables for credentials when needed
- Keep
.envout of version control
- MCP Specification:
docs/specs/MCP_SPEC.md - Getting Started Guide:
docs/developer/getting_started.md - Cursor MCP Setup:
docs/developer/mcp_cursor_setup.md - ChatGPT Setup:
docs/developer/chatgpt_actions_setup.md - Claude Code Documentation: https://docs.anthropic.com/claude-code
# Build MCP server (one-time)
npm run build:server
# Auto-rebuild on code changes (for development)
npm run dev:server:tunnel
# Get node path
which node # macOS/Linux
where node # Windows
# Verify build
ls -la dist/index.js
# Test database connection
npm testConfig file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Note: Claude Code runs the MCP server as a child process, communicating via stdin/stdout using the Model Context Protocol JSON-RPC format. This localhost architecture ensures privacy and user control.