Skip to main content

Crate trusty_memory

Crate trusty_memory 

Source
Expand description

MCP server (HTTP/SSE + UDS) for trusty-memory.

Why: Claude Code and other MCP-aware clients integrate with trusty-memory through the standardized Model Context Protocol; we expose memory + KG tools so they can be called by name. Claude Code itself speaks stdio, but the in-process serve --stdio path was removed in issue #150 because it deadlocked on the redb exclusive write lock whenever a long-lived daemon was already running — the canonical stdio integration is now the trusty-memory-mcp-bridge binary (PR #149), which pipes Claude Code’s stdio over a Unix domain socket to the daemon. What: Provides run_http / run_http_dynamic / run_http_on (axum HTTP/SSE + REST + UI) and the transport::uds module (Unix-domain socket transport for the MCP bridge), plus an AppState that carries the shared PalaceRegistry, on-disk data root, and a lazily-initialized embedder. Test: cargo test -p trusty-memory validates handshake + dispatch via the in-process handle_message unit tests and the tests/uds_roundtrip.rs end-to-end harness.

Re-exports§

pub use activity::ActivityEntry;
pub use activity::ActivityFilter;
pub use activity::ActivityLog;
pub use activity::ActivitySource;
pub use attribution::CreatorInfo;
pub use attribution::CreatorSource;
pub use mcp_service::MemoryMcpService;
pub use tools::MemoryMcpServer;

Modules§

activity
Persistent activity log for the trusty-memory daemon (issue #96).
attribution
Drawer creator-attribution tag helpers.
bm25_supervisor
Per-palace trusty-bm25-daemon spawn supervisor (issue #193).
bootstrap
Knowledge-graph bootstrap helpers.
chat
Chat HTTP surface for trusty-memory: OpenRouter/Ollama SSE chat, tool dispatch, chat-session CRUD, and inter-project messaging endpoints.
commands
Per-subcommand handlers for the trusty-memory binary.
discovery
Automatic project alias discovery.
hook_emit
Cross-process hook activity emit.
kg_extract
Deterministic KG triple extraction from drawer content.
mcp_service
ServiceDescriptor impl for the trusty-memory MCP service.
messaging
Inter-project messaging primitive (issue #99).
openrpc
OpenRPC 1.3.2 service description for trusty-memory-mcp.
project_root
Issue #88: project-root detection and palace-slug enforcement.
prompt_facts
Prompt-facts surface: hot KG predicates exposed via a per-message tool.
prompt_log
Enriched-prompt logger for the UserPromptSubmit / SessionStart hooks (issue #105).
service
MemoryService — pure business-logic facade over AppState.
tools
MCP tool surface for trusty-memory.
transport
Transport-layer infrastructure for the trusty-memory daemon.
web
HTTP API + embedded SPA shell for the trusty-memory admin UI.

Structs§

AppState
Shared application state passed to every request handler.

Enums§

DaemonEvent
Live daemon events broadcast to connected SSE subscribers.
HookType
Hook type — labels the Claude Code hook that triggered a submission.
InjectionKind
Injection kind — labels what the hook actually injected (or attempted).

Constants§

DEFAULT_HTTP_PORT
Preferred starting port for the trusty-memory HTTP daemon.
HOOK_PROMPT_EXCERPT_CHARS
Maximum bytes retained in the trigger-prompt excerpt embedded on a HookFired event.

Functions§

bind_dynamic_port
Bind a TcpListener to 127.0.0.1, dynamically selecting a port.
handle_message
Handle a single MCP JSON-RPC message and produce its response.
hook_prompt_excerpt
Reduce a triggering prompt to the short excerpt embedded on a HookFired activity event.
http_addr_path
Path to the canonical address-discovery file for the trusty-memory daemon.
resolve_palace_registry_dir
Resolve the directory that actually holds the per-palace subdirectories.
run_http
Convenience: bind addr and serve via run_http_on.
run_http_dynamic
Convenience: bind dynamically (7070..=7079, OS fallback) and serve.
run_http_on
Run the optional HTTP/SSE + web admin server.