47 lines
1.7 KiB
Markdown
47 lines
1.7 KiB
Markdown
# 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
|
||
1. Ensure the MCP client loads the server manifest (see `src/mcp/ToolSchemas.json`).
|
||
2. Add both tool names to the capability list you pass into the MCP handshake.
|
||
3. When the client calls `register_default_tools`, they become available to dispatch via `KomMcpServer::dispatch`.
|
||
|
||
## Client adapter hints
|
||
- **Codey (Google)** – map Codey’s `tool_invocation` hooks to MCP calls. Persist summary/state blobs after each completion:
|
||
```json
|
||
{
|
||
"tool": "kom.memory.v1.save_context",
|
||
"arguments": {
|
||
"key": "codey/session",
|
||
"content": {"summary": "Refactored PgDal for TTL support"},
|
||
"tags": ["codey", "memory"]
|
||
}
|
||
}
|
||
```
|
||
On session start, call `kom.memory.v1.recall_context` with the namespace/key to warm the local context buffer.
|
||
- **Claude Code (Anthropic)** – use the `tool_use` event to flush conversational checkpoints:
|
||
```json
|
||
{
|
||
"tool": "kom.memory.v1.recall_context",
|
||
"arguments": {
|
||
"limit": 5,
|
||
"tags": ["task"]
|
||
}
|
||
}
|
||
```
|
||
Feed the returned snippets back into Claude’s prompt so follow-up completions have grounding data.
|
||
|
||
## Response fields
|
||
- `save_context` returns `{ "id": string, "created_at": ISO8601 }`.
|
||
- `recall_context` returns `{ "items": [{ "id", "key?", "content", "tags", "created_at" }] }`.
|
||
|
||
## Testing locally
|
||
```bash
|
||
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.
|