Expand description
mimir-mcp — Mimir MCP (Model Context Protocol) server library.
Exposes Mimir’s current workspace-local canonical store to Claude (Claude Desktop and Claude Code) via stdin/stdout transport. Per Mimir’s 2026-04-24 mandate, Claude and Codex are the first target surfaces and future agents integrate through draft/retrieval adapters. This crate remains the Claude MCP surface until scope-aware adapters are specified; other MCP clients may technically connect because the protocol is standard, but they are out of scope for testing, support, and design tuning here.
The library surface (MimirServer) is reusable in tests with the
in-memory tokio::io::duplex transport; the binary at src/main.rs
is a thin wrapper that wires MimirServer to stdio and a
tracing-to-stderr subscriber.
§Tools
Phase 2.3 ships nine tools across three layers:
Status:
mimir_status— server health, store-open + lease-held flags.
Read (workspace-required):
2. mimir_read — Lisp (query …) execution; matched records
rendered as data-marked Lisp payloads.
3. mimir_verify — read-only integrity check on a canonical log.
4. mimir_list_episodes — paginated episode metadata.
5. mimir_render_memory — single-record data-marked render.
Write + lifecycle (lease-required):
6. mimir_open_workspace — opens a Store and mints a write lease.
7. mimir_write — commits a Lisp batch.
8. mimir_close_episode — convenience wrapper for (episode :close).
9. mimir_release_workspace — drops the lease; reads continue to work.
Read tools require an opened workspace store (set
MIMIR_WORKSPACE_PATH at startup, or call mimir_open_workspace).
Write tools additionally require a valid lease token returned by
mimir_open_workspace. See crate::server module docs for the
lease state machine.
§Stability
The library API will move freely until mimir-mcp cuts a 1.0
release alongside the rest of the workspace. The on-wire MCP tool
surface (tool names, input schemas, output shapes) is what
agent-side prompts depend on; that surface gets a drift gate at
Phase 2.4 (tool_catalog_drift) and stricter SemVer commitments
once v0.1.0-alpha.1 ships.
Structs§
- Close
Episode Args - Input shape for
mimir_close_episode. Convenience wrapper that emits(episode :close)as a write batch. The Mimir grammar does not currently accept any keyword args on(episode :close)— labels and parents are set on(episode :start …). If post-close labelling is needed, file a spec follow-up. - Episode
Row - One row of
mimir_list_episodes’s response. - List
Episodes Args - Input shape for
mimir_list_episodes. Pagination defaults tolimit = 50, offset = 0if both are omitted. - Memory
Boundary - Boundary metadata for retrieved governed memory records.
- Mimir
Server - Mimir MCP server. Holds workspace context (computed at server
startup, not per-call), an optional opened
Store(required for read tools), and the rmcpToolRouterthat dispatches incoming tool calls to the#[tool]-annotated methods below. - Open
Workspace Args - Input shape for
mimir_open_workspace. - Open
Workspace Response - JSON shape of
mimir_open_workspace’s response — the lease info the caller must echo back to write tools. - Read
Args - Input shape for
mimir_read. Single field — the Lisp query source. - Read
Response - JSON shape of
mimir_read’s response. Records are rendered as canonical Lisp payloads inside an explicit data boundary, so consumer agents do not confuse retrieved memory with instructions. - Release
Workspace Args - Input shape for
mimir_release_workspace. - Release
Workspace Response - JSON shape of
mimir_release_workspace’s response. - Render
Memory Args - Input shape for
mimir_render_memory. Takes a Lisp(query …)expected to match a single record; renders that record as Lisp. - Render
Memory Response - JSON shape of
mimir_render_memory’s response. - Rendered
Memory Record - One retrieved governed memory record rendered for MCP consumers.
- Status
Report - JSON shape of the
mimir_statustool’s response payload. - System
Clock - Production clock — delegates to
SystemTime::now. Zero-sized. - Verify
Args - Input shape for
mimir_verify. Thelog_pathfield is optional — when omitted, the server’s configured workspace log is used. - Verify
Report Json - JSON-friendly mirror of
mimir_cli::VerifyReport. The upstream type doesn’t deriveSerialize(it’s an internalmimir-clitype); we transcribe to a flat JSON shape here to keep the protocol surface stable across mimir-cli refactors. - Write
Args - Input shape for
mimir_write. The batch is a Lisp string with one or more memory forms (sem/epi/pro/inf), optionally preceded by an(episode :start …)directive. - Write
Response - JSON shape of
mimir_write’s response.
Constants§
- DEFAULT_
LEASE_ TTL_ SECONDS - Default workspace-lease TTL when neither the
ttl_secondsargument nor theMIMIR_MCP_LEASE_TTL_SECONDSenv var is set. 30 minutes is long enough for an interactive Claude session and short enough that a forgotten release doesn’t permanently lock the workspace from a future restart. - MAX_
LEASE_ TTL_ SECONDS - Hard cap on
ttl_seconds. Prevents a misconfigured client from holding a workspace effectively forever.
Traits§
- Clock
- Injectable wall-clock source for the lease state machine.