Skip to content

Integration: Claude Code

PathStatusNotes
MCP server✅ SupportedClaude Code has first-class MCP support via CLAUDE.md
Harness✅ SupportedANTHROPIC_BASE_URL proxy for full turn capture
ExtensionClaude Code is a CLI; no browser surface

Confidence: High. Claude Code’s MCP integration is the primary use case MemStrata was designed around. Both paths are tested on every release.


Claude Code reads MCP server configuration from CLAUDE.md or ~/.claude/settings.json.

1. Start the MemStrata MCP server

Terminal window
memstrata serve --port 8080

2. Register in Claude Code

Add to your project’s CLAUDE.md or ~/.claude/settings.json:

{
"mcpServers": {
"memstrata": {
"command": "memstrata",
"args": ["mcp"],
"env": {}
}
}
}

Or use the stdio transport (recommended — no separate port needed):

Terminal window
memstrata mcp --stdio

Claude Code will launch MemStrata as a subprocess and communicate via stdin/stdout. This is the cleanest setup — no port to manage.

3. Verify

In a Claude Code session, run:

/mcp

You should see memstrata listed as a connected server with its available tools (context_query, index_status, savings_summary).


The harness proxies all Anthropic API calls, compressing context before each request.

1. Start the harness

Terminal window
memstrata serve --port 8080

2. Set the API base URL

Terminal window
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic

Add this to your shell profile so Claude Code picks it up automatically.

3. Verify

Run claude and ask: “What are the main modules in this codebase?” The harness log (memstrata logs --tail 10) should show compression stats.


SignalCaptured?Notes
Claude Code chat turns✅ YesFull context compression via MCP or harness
Agent mode (multi-turn)✅ YesEach sub-turn is captured and compressed
Tool calls (Bash, Edit, Read)✅ YesTool results are included in context accounting
/compact command✅ YesMemStrata’s savings are additive with compaction
Thinking tokens (extended thinking)⚠️ MonitoredToken counts tracked; thinking blocks not compressed (they’re generated, not input)
File reads from the AI✅ YesMemStrata intercepts Read tool context before it’s sent

MemStrata exposes three tools to Claude Code via MCP:

ToolDescription
context_queryReturns a compressed context slice for a given query. Claude Code calls this when it needs codebase context.
index_statusReturns the current index state (file count, last updated, coverage).
savings_summaryReturns the session’s token savings and dollar estimate so far.

memstrata not showing in /mcp
Check that the MCP config is in the right file and that memstrata mcp --stdio runs without error.

Harness returns 502 Bad Gateway
The harness is running but can’t reach Anthropic. Check ANTHROPIC_API_KEY is set and that https://api.anthropic.com is reachable.

Context feels wrong or hallucinated
Run memstrata status to verify the project index is fresh. If the last indexed time is stale, run memstrata index.