Repository navigation
MCP: add an ask tool that returns a grounded, cited answer #12
Description
Summary
Add an MCP `ask` tool that runs retrieve→synthesize and returns a grounded, citation-backed answer, instead of clients only getting raw search chunks.
Context
`journal search` already produces an optional grounded AI answer (`answerQuery` in `cmd/search.go`) using the configured synth provider. Over MCP, only the `search` tool exists and it returns chunks. An `ask` tool lets a connected agent (Claude Desktop/Cursor) get "what did I decide about X" answered directly — with citations — which is the "Claude just knows what I wrote last week" experience the author wants. Honors `synth_provider` (local/cloud) and `local_only`.
Acceptance Criteria
- New MCP `ask` tool: `query` + optional `k`/filters; returns the grounded answer text plus the source `path:line` citations.
- Uses the existing `answerClient`/`answerQuery` path; respects `synth_provider` and `local_only` (clear error/skip when synthesis is unavailable).
- Verified over the stdio JSON-RPC handshake; tests with a fake synth client.
- Passes linting (gofmt + vet; `make lint`); review approved.
Scope
In scope: `cmd/mcp.go` (register the tool + handler) reusing `cmd/search.go` answer logic.
Out of scope: streaming responses; new synthesis kinds; changing the `search` tool.
Technical Notes
Key files:
```
- cmd/mcp.go (mcp.AddTool registrations — add `ask`)
- cmd/search.go (answerQuery, answerClient, searchChunks to reuse)
- cmd/mcp_test.go (stdio handshake test; inject synth.Fake)
```
Dependencies: none new. Testing: `tools/call` round-trip asserting answer + citations; mind the wazero `-p 1` constraint.
Complexity
- `complexity:medium`
Agent Readiness
- bounded · [x] measurable · [x] context · [x] patterns linked · [x] no external blockers
Activity