Documentation

Docs / Reference

ADR 0082 - Read-only MCP server

Status: Accepted (delegated review, 2026-11-23)

Context

Milestone M3 asks for a read-only MCP server over the deterministic facts, so a coding agent can ask Graphvein what a person asks the web UI: where something is defined, which routes exist, what a route does, who calls a function and what depends on it. The answers must carry the same honesty as the UI: verification and precision labels, unknowns, assumptions, the confidence with its rule, index freshness on every response and every traversal cap that bound ("depth cap reached" is never "nothing beyond"). Depth parameters use the shared caps, project mode works where the CLI and HTTP API already have it, and only internal/egress may open network connections (ADR 0040).

The design inventory (T030 task record, internal) found the read paths to reuse: the query package (query.Execute, query.ExecuteProject) for callers, impact and term lookup, and the HTTP API v0 views (internal/server), which carry almost all of the honesty labels but are unexported compute* functions behind the HTTP handler map. It also listed gaps an MCP answer would expose: query truncation unreported (G1), callers and impact unbounded and without cap reports (G2), route callers without the endpoint view's near misses (G3), most views without freshness (G6), no paging of endpoint lists (G7) and a silent end where the chain prints "? not modelled" (G10).

Options considered

Protocol implementation.

  1. The official Go SDK, github.com/modelcontextprotocol/go-sdk v1.8.0 (Apache-2.0 for new code, MIT for older code; needs go 1.25 or later). It gives typed tools with input schemas inferred from Go structs, structuredContent, protocol-version negotiation (2024-11-05 to 2026-07-28), cancellation and upstream conformance tests. Cost: six SDK and OAuth packages that import net, net/http or os/exec for the client, HTTP, SSE and command transports, about 2 MB of binary, and one package (oauthex) that captures http.DefaultTransport at init, which the runtime tripwires cannot see.
  2. Hand-written JSON-RPC 2.0 over stdio: no new module and no network import by construction, but the team tracks the protocol (five versions in two years) and loses upstream conformance testing.

Reuse of the views.

  1. An exported in-process reader in internal/server that runs the registered view handlers (with their consistency check) without a listener and without the browser guards.
  2. Moving every compute* view into an exported package.
  3. Calling the HTTP handler on a recorder from internal/mcp.

Encoding.

  1. structuredContent with an outputSchema, plus the same object as minified JSON in the one text block (the specification's advice for clients that read only text).
  2. Compact text only.
  3. JSON plus a prose summary (a second wording of every claim).

Decision

Consequences

Measured cost

See the MCP-1 and MCP-2 measurements in the T030 task record (internal): freshness per call and answer sizes, compact and full, on the fastapi and langflow corpora.

Known gaps

Review notes (2026-11-23)

Status: Accepted (delegated review, 2026-11-25)

Two additions after review, recorded in the T043 task record (internal). They close two of the known gaps above ("callers and impact do not filter test code"; "project link changes are not a tool"). The server now has fourteen tools.

Review notes for Revision 1 (delegated review, 2026-11-25, T043)

Accepted after gate 1 (CI run 45612588023: changes and postgres green; postgres log 0 FAIL, 254 /postgres PASS). One independent review (the T043 review notes, internal): A1 (unknown_calls_in_result_files counted the files of hidden test results), B1-B4 (unfiltered parts unlabelled, test_code/via_test_code unexplained, link_changes comparing the newest pass with itself, a member without a checkout reading another graphvein.yaml) and the docs points were fixed before the gate; the link changes state (compared / same pass / no comparison) is shared with the server endpoint and the CLI. MCP goldens changed only as explained in the task summary. 14 tools. Known gaps: the test-code filter applies to results, not to the walk (caps and blind spots still count test code; via_test_code marks nodes reached only through it); link_changes names a changed link but not what changed in it.

Report a problem with this pageSource: docs/adr/0082-mcp-server.md