feat(grounding-mcp): add ledger_status no-arg health verb#73
Merged
Conversation
Add a `ledger_status` MCP tool that takes no arguments and returns ledger reachability + lightweight stats (db path, entry count, last-write timestamp). Backs a `ledgerStatus()` helper in `ledger-bridge.ts` that wraps the two read-only queries in a try/catch so an unreachable ledger does not crash the server. Designed to satisfy harness's `harness doctor` MCP probe, which calls `tools/call` with empty `arguments` against a server's health verb. Today every other grounding-mcp tool requires a sessionId or some other arg, so an empty-args probe always failed validation. With `ledger_status` the example manifest in harness can now register a working health verb for grounding-mcp. Vitest covers happy path (counts + dbPath echo) and the unreachable case (corrupt file → structured error response, not a throw). Closes agent-tasks 453d86f4. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
ledger_statusMCP tool togrounding-mcpso harness's MCP doctor can probe it with an empty-argstools/call.Why
Every existing grounding-mcp tool requires a
sessionId(or other args). Calling any of them with{}returns a JSON-RPC validation error, which harness's MCP probe treats as unhealthy. The example manifest in harness therefore cannot register grounding-mcp with a working health verb today (harness taskbd4ee1c9).What
packages/grounding-mcp/src/ledger-bridge.ts: newledgerStatus()helper. Read-only queries (SELECT COUNT(*),SELECT MAX(created_at)) wrapped in try/catch, returns a discriminated union{ status: 'ok', dbPath, entryCount, lastWriteAt } | { status: 'error', message }.packages/grounding-mcp/src/server.ts: registerledger_statustool with no input schema, delegates toledgerStatus().packages/grounding-mcp/tests/roundtrip.test.ts: two new Vitest cases.status=ok,entryCount=2,dbPathechoes the env var,lastWriteAtis a string.EVIDENCE_LEDGER_DBat it, assertsstatus=errorwith a non-empty message. (First attempt used a missing parent dir but evidence-ledger'sgetDbauto-mkdirs, so the corrupt-file approach was needed.)Dogfood
Confirms harness's probe contract (
tools/callwith empty arguments) is satisfied.Out of scope
server.tool(name, description, schema, cb)— every existing tool emits them; not introduced by this PR.Evidence
.agent-grounding/evidence/feat/grounding-mcp-ledger-status.jsonlcommitted for the review-claim-gate auto-detect path.Closes agent-tasks task
453d86f4.