Skip to main content

Crate mimir_mcp

Crate mimir_mcp 

Source
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:

  1. 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§

CloseEpisodeArgs
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.
EpisodeRow
One row of mimir_list_episodes’s response.
ListEpisodesArgs
Input shape for mimir_list_episodes. Pagination defaults to limit = 50, offset = 0 if both are omitted.
MemoryBoundary
Boundary metadata for retrieved governed memory records.
MimirServer
Mimir MCP server. Holds workspace context (computed at server startup, not per-call), an optional opened Store (required for read tools), and the rmcp ToolRouter that dispatches incoming tool calls to the #[tool]-annotated methods below.
OpenWorkspaceArgs
Input shape for mimir_open_workspace.
OpenWorkspaceResponse
JSON shape of mimir_open_workspace’s response — the lease info the caller must echo back to write tools.
ReadArgs
Input shape for mimir_read. Single field — the Lisp query source.
ReadResponse
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.
ReleaseWorkspaceArgs
Input shape for mimir_release_workspace.
ReleaseWorkspaceResponse
JSON shape of mimir_release_workspace’s response.
RenderMemoryArgs
Input shape for mimir_render_memory. Takes a Lisp (query …) expected to match a single record; renders that record as Lisp.
RenderMemoryResponse
JSON shape of mimir_render_memory’s response.
RenderedMemoryRecord
One retrieved governed memory record rendered for MCP consumers.
StatusReport
JSON shape of the mimir_status tool’s response payload.
SystemClock
Production clock — delegates to SystemTime::now. Zero-sized.
VerifyArgs
Input shape for mimir_verify. The log_path field is optional — when omitted, the server’s configured workspace log is used.
VerifyReportJson
JSON-friendly mirror of mimir_cli::VerifyReport. The upstream type doesn’t derive Serialize (it’s an internal mimir-cli type); we transcribe to a flat JSON shape here to keep the protocol surface stable across mimir-cli refactors.
WriteArgs
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.
WriteResponse
JSON shape of mimir_write’s response.

Constants§

DEFAULT_LEASE_TTL_SECONDS
Default workspace-lease TTL when neither the ttl_seconds argument nor the MIMIR_MCP_LEASE_TTL_SECONDS env 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.