1.7 KiB
1.7 KiB
Using Save/Recall Context Tools
The Kompanion MCP backend exposes kom.memory.v1.save_context and kom.memory.v1.recall_context so editor-embedded agents can persist and retrieve working memory.
Registering the tools
- Ensure the MCP client loads the server manifest (see
src/mcp/ToolSchemas.json). - Add both tool names to the capability list you pass into the MCP handshake.
- When the client calls
register_default_tools, they become available to dispatch viaKomMcpServer::dispatch.
Client adapter hints
- Codey (Google) – map Codey’s
tool_invocationhooks to MCP calls. Persist summary/state blobs after each completion:
On session start, call{ "tool": "kom.memory.v1.save_context", "arguments": { "key": "codey/session", "content": {"summary": "Refactored PgDal for TTL support"}, "tags": ["codey", "memory"] } }kom.memory.v1.recall_contextwith the namespace/key to warm the local context buffer. - Claude Code (Anthropic) – use the
tool_useevent to flush conversational checkpoints:
Feed the returned snippets back into Claude’s prompt so follow-up completions have grounding data.{ "tool": "kom.memory.v1.recall_context", "arguments": { "limit": 5, "tags": ["task"] } }
Response fields
save_contextreturns{ "id": string, "created_at": ISO8601 }.recall_contextreturns{ "items": [{ "id", "key?", "content", "tags", "created_at" }] }.
Testing locally
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure
These commands build kom_mcp plus the test harness that exercises the new context tools.