Skip to main content

mimir_mcp/
lib.rs

1//! `mimir-mcp` — Mimir MCP (Model Context Protocol) server library.
2//!
3//! Exposes Mimir's current workspace-local canonical store to
4//! **Claude** (Claude Desktop and Claude Code) via stdin/stdout
5//! transport. Per Mimir's 2026-04-24 mandate, Claude and Codex are
6//! the first target surfaces and future agents integrate through
7//! draft/retrieval adapters. This crate remains the Claude MCP surface
8//! until scope-aware adapters are specified; other MCP clients may
9//! technically connect because the protocol is standard, but they are
10//! out of scope for testing, support, and design tuning here.
11//!
12//! The library surface ([`MimirServer`]) is reusable in tests with the
13//! in-memory `tokio::io::duplex` transport; the binary at `src/main.rs`
14//! is a thin wrapper that wires `MimirServer` to stdio and a
15//! tracing-to-stderr subscriber.
16//!
17//! ## Tools
18//!
19//! Phase 2.3 ships **nine** tools across three layers:
20//!
21//! Status:
22//! 1. `mimir_status` — server health, store-open + lease-held flags.
23//!
24//! Read (workspace-required):
25//! 2. `mimir_read` — Lisp `(query …)` execution; matched records
26//!    rendered as data-marked Lisp payloads.
27//! 3. `mimir_verify` — read-only integrity check on a canonical log.
28//! 4. `mimir_list_episodes` — paginated episode metadata.
29//! 5. `mimir_render_memory` — single-record data-marked render.
30//!
31//! Write + lifecycle (lease-required):
32//! 6. `mimir_open_workspace` — opens a `Store` and mints a write lease.
33//! 7. `mimir_write` — commits a Lisp batch.
34//! 8. `mimir_close_episode` — convenience wrapper for `(episode :close)`.
35//! 9. `mimir_release_workspace` — drops the lease; reads continue to work.
36//!
37//! Read tools require an opened workspace store (set
38//! `MIMIR_WORKSPACE_PATH` at startup, or call `mimir_open_workspace`).
39//! Write tools additionally require a valid lease token returned by
40//! `mimir_open_workspace`. See `crate::server` module docs for the
41//! lease state machine.
42//!
43//! ## Stability
44//!
45//! The library API will move freely until `mimir-mcp` cuts a 1.0
46//! release alongside the rest of the workspace. The on-wire MCP tool
47//! surface (tool names, input schemas, output shapes) is what
48//! agent-side prompts depend on; that surface gets a drift gate at
49//! Phase 2.4 (`tool_catalog_drift`) and stricter `SemVer` commitments
50//! once `v0.1.0-alpha.1` ships.
51
52#![cfg_attr(not(test), forbid(unsafe_code))]
53
54mod server;
55
56pub use server::{
57    Clock, CloseEpisodeArgs, EpisodeRow, ListEpisodesArgs, MemoryBoundary, MimirServer,
58    OpenWorkspaceArgs, OpenWorkspaceResponse, ReadArgs, ReadResponse, ReleaseWorkspaceArgs,
59    ReleaseWorkspaceResponse, RenderMemoryArgs, RenderMemoryResponse, RenderedMemoryRecord,
60    StatusReport, SystemClock, VerifyArgs, VerifyReportJson, WriteArgs, WriteResponse,
61    DEFAULT_LEASE_TTL_SECONDS, MAX_LEASE_TTL_SECONDS,
62};