Documentation

Docs / Reference

Claim contract: MCP server

The claim contract of the read-only MCP server (graphvein mcp, ADR 0082): what each tool and each part of the response envelope may state, which existing read path it comes from, and when it must refuse or say unknown. internal/mcp keeps its row table (claimRows, internal/mcp/claims.go) 1:1 with the table below (TestClaimContract), and the session goldens (TestSessionGoldens, internal/mcp/testdata/session-*.golden.json) reach every row.

Every tool reuses an existing read path: internal/query for find, callers and impact in one repository, the HTTP API v0 views (server.Reader, the same handlers graphvein serve registers, without a listener) for the rest and for project mode, and internal/changes for the table access entries and the sites that may also use a table. The MCP layer adds no rule of its own about the code; it maps the answers into one envelope and keeps their labels. Rows MC-33 to MC-99 are free for later tools.

Envelope

Every tool answers with one object (structuredContent, and by default the same minified JSON as the one text block):

tool, envelope (1), repository or project, error on a refusal (isError: true), freshness, request, bounds, page, summary, results, unknowns, assumptions, labels and omitted (each entry {field, how}: what was left out and how to get it), in that order, so a client that cuts a long text still has the refusal, the caps that bound and the paging. Lists are always present: an empty list means the reused code reported nothing of that kind, never that nothing exists. A list an unknown carries (possibly missing call sites, sites that may also use a table, external stubs, not-proven entries, blind spots) is {items, total, more, next_cursor}: on the tools that take unknowns_limit (default 20, at most 500) and unknowns_cursor, at most that many items with the exact total; the rest by cursor.

Claim contract

id part may state source (reused code) refusal or unknown condition
MC-1 envelope freshness state fresh, stale, not_indexed or unknown as /api/v0/status computes it, checked once per call batch (a check serves the calls that start within 2 s of it while the latest stored run of every repository it covers is the one it saw; those calls say reused: true and keep that check's checked_at; status always checks), checked_at, the exact changed_count, the first 50 changed files with changed_more, the last run (finish time, indexer, contract version, commit when recorded, extractor current and match); project mode: every member's freshness and index, the link pass (state none, fresh, stale, stale reasons), and the weakest member state as the project state statusHandler.compute through /api/v0/status; project: /api/v0/project members and link_pass; the latest runs from store.Runs A failed check is unknown with its error; a state the view serves that this table does not name is unknown (MC-D). A stale index still answers and is never called fresh: when a served node's file_state is not unchanged under a fresh check, a reused check is replaced by a new one (freshness_rechecked), and a mismatch that remains is an unknown (freshness_mismatch).
MC-2 envelope request every parameter after defaults: target and the identity it resolved to, depth (and a route's raise to 2 with its note), scope, limit, cursor, repository the tool's own argument handling Echoed even on a refusal, as far as the arguments were read. callers and impact echo the test scope they filtered by (MC-31).
MC-3 envelope bounds for every cap the reused code reports as bound: the cap (depth, reached_nodes, members, fan_out, changed_files, cut_lines, lines, neighbours), its limit (the reused code's own constant, never restated), the step, how many lie beyond (null when the reused code names the cap without a count, as change impact does), and a sentence ("depth cap reached (N): B beyond step N", with a larger depth as the way on only below the maximum) traverse bounds from query.Execute, the project query view and the chain view's step bounds; change impact's caps; /api/v0/status changed_files_truncated; /api/v0/source cut_lines, truncated; /api/v0/schema/table truncated A bound cap is never "nothing beyond": results stop at the cap; an uncounted bound says "may lie beyond, uncounted".
MC-4 envelope page returned, total, more, next_cursor and "N more not shown; call again with cursor" over a complete list the reused code returned; default 50 (table users 20), at most 500; the lists unknowns carry, paged by unknowns_limit and unknowns_cursor (default 20) with their exact totals the tool's own paging A list is never cut without page.more (or the list's more). A limit outside 1..500 or a cursor that is not a non-negative offset is refused (bad_request); an offset past the end answers an empty page with more 0.
MC-5 envelope labels the meaning of each label value the response uses, and only those: freshness, link pass, provenance, confidence rule (weakest edge on the shortest path), claim wording, precision (precise, best_effort), file state, match tier, handler state, shape section state, shape item kind, near-miss relation, source state, endpoint flag, bound cap, verification (oracle, mapped, unknown), chain tier, table completeness, change, link cell state, component state, call status the legend in internal/mcp/labels.go, worded from the views' documented values A value the legend does not name is listed as "not modelled by the MCP server" and reported as an MC-D unknown, never explained by a guess. A scope label never replaces a fact label; with an extractor mismatch nothing is precise (the view's own refusal).
MC-6 envelope omitted each field left out of the views' objects with how to get it: editor links (ide, shape_links, link), raw stored attributes, content_hash, record type and level, evidence spans past the first location, the chain's map hint, the overview's link members, methods, origins and cell sources, precision rule texts and per-language counts, and the parts compact detail leaves out (MC-29) the views' answers Only fields that carry no claim of their own, or whose claim another tool or the full detail returns, are left out, and each is named with a way back that exists; every mapper keeps a known-key list (kept, or left out with its way back) and passes any other key to MC-D. source shows the lines.
MC-7 target resolution the one node a target names, by one rule in every tool (request.match says which tier resolved it): a canonical identity as given; a name or a qualified-name suffix that starts at a name boundary (the rule of graphvein callers and impact); for callers, impact, chain, source and endpoint a "METHOD /path" target names the HTTP routes served at that path first (every composed path in the tool's scope, not only the one the endpoints rows show; a test-only mount is not a production path); table resolves tables only; endpoint endpoint rows only; chain also a component directory the architecture view lists (component:DIR names it alone) query.TargetFilter, query.Resolve; /api/v0/api/endpoints rows and server.ServedPaths; /api/v0/architecture components Several matches (a component and a node included): ambiguous with every candidate and no results; none: not_found naming the tool's lookup. A suffix inside a name, a node of another kind than the tool reads and, for a "METHOD /path" target, a node that is not a route (an OpenAPI operation, a client call) are candidates of the refusal only, never resolved. A target is never guessed; an OpenAPI operation named by its identity says so in callers, impact and chain (target_is_spec_operation).
MC-8 refusals an error result with the envelope (freshness included): not_indexed, not_found, ambiguous (with candidates), bad_request, repository_required, no_checkout, index_changed, store_error, and the change views' own codes (would_index, base_unknown, base_expired, reindex_needed, git_unavailable, ref_objects_missing; MC-30) and project_only (MC-32) the views' error answers (server.ReadError) and the tool's own checks Every tool but status refuses not_indexed in a repository with no stored run.
MC-9 status the freshness of MC-1 with every changed file (paged), whether the repository is indexed, the precision view's run refusal; project mode: one result per member and the link pass /api/v0/status, /api/v0/precision run, /api/v0/project A run that recorded no commit, an extractor mismatch and a precision refusal are unknowns; a stale link pass is an MC-18 unknown.
MC-10 find stored nodes matching the term (identity, exact name or any qualified-name suffix: a search, not a resolution), optionally by kind and file, with file, line and file_state (query.Presenter.FileState, as the views), in store order, with the exact total query.Execute (query, every match read, G1) Zero matches: "no stored node matches", never "does not exist" (ignored files, files with gaps and languages not read have no nodes). Project mode needs repository and a member checkout.
MC-11 endpoints the rows of the API view for one transport (default http) filtered by method and path prefix (a row matches when any path its route is served at in the request's scope starts with the prefix; served_paths lists them with their scope, production or test, when there are several), with the declaration's file and line, caller counts and flags (compact, MC-29) or every row field with the per-route shape summary (detail full); the transport summary (counts, frameworks, precision labels) A route whose prefix the code does not fix (T033 row UP-36) keeps path null with prefix_unknown (the known part with … for the prefix, its reason and hop; flag prefix_unresolved, label path:prefix_unknown), never a served path; the path prefix filter matches it by its known part (the part above the unknown prefix when there is one, else the proven path below it) and the row keeps prefix_unknown. A route whose every path an earlier mount takes has flag shadowed, not unmounted; a route registration whose path the Go linker withholds (couldn't-read CR-44) has flag path_withheld, not unmounted, and unmounted is labelled "the path is not known", never proof that the route is unreachable (ADR 0089 Revision 5); a route with a served path that rests on an assumption has flag path_assumed. computeEndpoints through /api/v0/api/endpoints; server.ServedPaths caller_count 0 is "no stored caller", never "dead" or "not called"; unread_use is "may be called"; a filter no row matches is an unknown ("not proof that no such endpoint exists").
MC-12 endpoint the route (or command, server action): handler with its state and stored edge, request and response shape by section state (compact: each item's name or status, presence, access, type and kind; detail full: as the view serves it), shape depth-cap stops as unknowns, OpenAPI operations, model tables, callers with their stored edges and match (paged; a caller linked under an origin assumption, LF-1 of docs/extract/clients.md, carries it as origin_assumptions and as an envelope assumption origin_assumed), near misses with their relation and candidate counts; project mode: callers and operations of other members through project links A route whose prefix the code does not fix keeps path null and adds prefix_unknown_paths (each … form with its reason and hop); a caller linked through the unknown-prefix tier (or to a Next.js route whose basePath is not read) carries prefix_assumptions (UP-V1, UP-V2) with their texts in the envelope assumptions (UP-36); a caller whose matched route path entry rests on a path assumption (GR-V5, RO-V1, RO-V2) carries route_path_assumptions with their texts in the envelope assumptions. A served path that rests on an assumption (GR-V5; RO-V1 "a mount at an unknown prefix may answer first"; RO-V2 "a mounted app's catch-all may answer first") is listed in path_assumptions (path, scope, ids, the wrappers or earlier mounts named) with each text in the envelope assumptions. computeEndpoint through /api/v0/api/endpoint Near misses are candidates, never callers; candidate_count_exact: false is a lower bound; a partial shape section is an unknown and a not_read one claims nothing; no caller in this scope (and no project caller) is "no stored caller", not proof that nothing calls it.
MC-13 source the node's current lines around its span (context default 8, at most 50), the file's precision label and the code calls label, highlighted only when the source state says so computeSource through /api/v0/source Any state other than exact or text_match is shown with its reason and without a highlight, as an unknown; a member without a checkout refuses (no_checkout).
MC-14 callers "called by" for each node with a stored path to the target up to the depth (default 1, at most 10; project at most 10), its file_state, its distance, provenance (fact, or inferred with confidence = the weakest edge of the shortest path) and the path's steps; a calls_route step linked under an origin assumption (LF-1) carries it as origin_assumptions on the step and the result and as an envelope assumption origin_assumed A calls_route step of the unknown-prefix tier carries prefix_assumptions (UP-V1, UP-V2), their texts in the envelope assumptions (T033 UP-36); a step whose matched route path entry rests on a path assumption (GR-V5, RO-V1, RO-V2) carries route_path_assumptions, their texts in the envelope assumptions. query.Execute (callers) on the shared traversal caps (D2); project: /api/v0/project/callers (query.ExecuteProject) No result is "no stored caller within the depth", never "not called", with the bounds, ends and near misses that apply.
MC-15 callers of a route the route's client calls (step 1) and the code that makes them (step 2: depth raised to 2), plus the endpoint view's near misses of the route as unknowns as MC-14, plus computeEndpoint near misses in scope all (G3) A near miss is "may call this route", never a caller; near_misses_incomplete counts calls whose candidate lists were cut upstream.
MC-16 impact "depends on" (every edge of the path a stored fact) or "may depend on" (an inferred edge) for each node reached up to the depth (default 3, at most 10; project at most 10), never "breaks", with the origin assumptions of its calls_route steps as in MC-14; blind spots: possibly missing callers (name-matched unresolved call sites, the exact count and the sites paged as an unknown's list) and unresolved calls in the result files A calls_route step of the unknown-prefix tier carries prefix_assumptions (UP-V1, UP-V2), their texts in the envelope assumptions (T033 UP-36); a step whose matched route path entry rests on a path assumption (GR-V5, RO-V1, RO-V2) carries route_path_assumptions, their texts in the envelope assumptions. query.Execute (impact) on the shared traversal caps; project: /api/v0/project/impact Blind spots are unknowns, never results; blind_spot_data: false is "unavailable", never zero.
MC-17 walk ends "? not modelled", one unknown per distinct end line listing the ends among the target and this page's results with the exact total of that line (the other results' ends are on their pages), for each reached function or method with no stored edge the walk follows: dependency injection, framework callbacks, JSX renders, passed callbacks and dynamic calls are not followed by callers and impact query.Execute and query.ExecuteProject ends (G10) An end is an unknown: the walk stops because nothing is modelled, never because nothing calls the function. The chain tool follows the bridges callers and impact do not (MC-21).
MC-18 project links a step through a stored project link as "may" (inferred, at most the link's confidence) with the assumption it rests on (an envelope assumption) and, when stale, its stale reasons; possible callers of other members as unknowns query.ExecuteProject through the project query views; /api/v0/api/endpoint project; /api/v0/project link_pass With no link pass nothing crosses repositories (link_pass.state none); a stale link is followed and reported stale; a possible caller is "may be called by", never a caller.
MC-19 read only answers only; every tool is annotated read-only, idempotent and closed-world server.Reader serves only the GET views in server.ReadPaths No tool writes: re-index, pins, ref snapshots, manifest edits and try-it are not reachable from the MCP server. The server speaks stdio only; it never listens and never dials.
MC-20 chain the members of the architecture chain from a node or component up, down or both (depth default 6, at most 10; scope production or all), per direction and step: identity, location, component, the chain row that reached it, its tier (fact, or inferred with the weakest edge confidence on its first path) and parents, and the edges that reach it with their wording, row, tier, first evidence location and, on a table edge (CH6), the owner's table access (tool, role, operations, rows, verification, assumes), paged; project mode: CH13 steps into other members A route member without a full path has prefix_path (the … form, T033 UP-33); a CH3 edge whose link rests on assumptions carries origin_assumptions (texts), prefix_assumptions (UP-V1, UP-V2) and route_path_assumptions (GR-V5, RO-V1, RO-V2), the texts in the envelope assumptions. computeArchitectureChain through /api/v0/architecture/chain; CH6 access from changes.AccessEntry A member is reached through stored edges only; a step's cut is a bound (MC-3), never "nothing beyond".
MC-21 chain unknowns the chain's CH11 end lines ("? not modelled"), one per distinct line with its members; edges not followed by kind (CHD); test-scope members kept out per step (CH10); no member beyond the start as "not proof that nothing calls or is called by it" the chain view's ends, not_followed, hidden_test An end is never "unused"; a CH13 end ("continues in member") is an MC-18 unknown.
MC-22 table schema with include both (default) or schema: the table's stored facts (its attributes as stored, the claim list folded), set, dialect, completeness, precision label, columns and indexes with their stored facts, default state and foreign keys, the column claims counted by verification with every claim that is not oracle named (compact) or each claim with its row and span (detail full), history, unresolved and external references, opaque sites, overlaps, foreign-key neighbours, the model's routes, and the assumptions the facts rest on with their catalogue text computeSchemaTable through /api/v0/schema/table; texts from /api/v0/schema/assumptions A completeness other than complete or complete_in_source, table reasons and routes not fully read are unknowns: no absence is claimed. mapped is "mapped, not verified".
MC-23 table users with include both (default) or users: the code that reads, writes or builds a query on the table: the chain's first upstream step (CH6) with each use's wording, tier, operations, rows, verification and assumptions (envelope assumptions with their text), paged (default 20); "N uses found (a lower bound)" /api/v0/architecture/chain (direction up, depth 1); changes.AccessCovered; changes.ReadUnknownUses and UnknownUses.MayAlsoUse (the rule of change impact's I8) Never "no users": a table no code-to-table row covers is "users not extracted" (unknown, not zero); the sites whose candidates name the table and the unbound sites that may reach it are "may also be used by" unknowns (paged lists), and test-scope users kept out are counted.
MC-24 changes the comparison of a stored base with the current index: both sides (run, time, extractor, partial, gaps), the group counts, and one page of items with id, group, change, row, kind, name, location, cause, reason, wording, labels, provenance, precision and the changed fields by name (compact) or with their before and after values (detail full), paged by the view's cursor changes.Compare, Comparison.Items through /api/v0/changes/summary and /api/v0/changes/items Gaps on either side, an extractor change, a head commit that differs, kinds not compared and hidden test items are unknowns; no item is "no changed item in this filter", never "nothing changed".
MC-25 change_impact the paths from a changed item or group (depth default 3, at most 10) with their claim ("depends on" for a fact path, "may depend on" otherwise, never "breaks"), wording, relation, provenance, confidence (the weakest inferred step) and steps (first evidence location, an I8 step's access, a project link's assumption and stale reasons), paged by the view's cursor; project mode across members through stored links A path that reaches a route below an unknown prefix has prefix_unknown_paths; one that reaches a route whose every path an earlier mount takes has route_shadowed (flag shadowed); a calls_route step carries its link assumptions as origin_assumptions, prefix_assumptions (T033 UP-32, UP-36) and route_path_assumptions. changes.Impact through /api/v0/changes/impact or /api/v0/project/changes/impact Blind spots, near misses, gap nodes, untraversed edges, relations not extracted, table uses (a lower bound) with their "may also be used by" sites (named and unbound), possible dependents of other members and a rule-only confidence are unknowns, never paths; their site lists are paged.
MC-26 unresolved calls the calls of one transport whose status is not linked (default: every other status the transport's summary counts), each with its location, owner, status, its stored call facts (method or its expression, URL and base expression, library, wrapper, command, ...), paths with candidates, match, origin and origin assumption, targets and the view's reasons; a generated call (committed bundler output, ADR 0085) is listed and counted with its generated_output row and reason, worded as not linked by design, never as a missing link; the transport's call counts computeCalls through /api/v0/api/calls; the counts of /api/v0/api/endpoints An unlinked call is never a link; only calls the extractors recognise are listed, which is said in every answer.
MC-27 endpoints without a stored caller each endpoint row the API view counts with caller_count 0 (in project mode also with no project caller), worded "no stored caller", or "may be called" when an unread use may reach it or another member may call it A route without a full path keeps prefix_unknown (T033 UP-36). computeEndpoints rows through /api/v0/api/endpoints Never "dead" or "not called": that an endpoint with no stored caller may still be called is said in every answer.
MC-28 overview the architecture view's components (paged: state, kinds, frameworks, counts, manifests), its links by family with count, tiers, weakest tier and cell states, databases with engine and accessors, hidden and not-drawn counts; the schema summary; the precision view's run, rules (label, scope, fact total), default families and file labels by language computeArchitecture, computeSchemaSummary, computePrecision through their views Unread or unassigned components, unknown cells, external stubs, unlinked calls, everything the view lists as not proven (lists paged), schema sets that failed or tools not read and a precision refusal are unknowns.
MC-29 compact detail the compact form of endpoints (rows without the shape summary, and without the name, pattern and default-valued fields where they repeat other fields), endpoint (shape items as name, presence, access, type and kind; models and security schemes by name and type; follow stops counted), table (claims counted, null or empty facts left out) and changes (changed fields by name) the same views as the full form Everything compact detail leaves out is named in omitted with how to get it (detail full or another tool); an unknown type is written out ("unknown (reason)", "not read"), never dropped.
MC-30 change bases the bases the change views read without writing: previous, run:ID, pin:NAME and ref:BASE[..HEAD] whose snapshots are stored; a refused base lists the stored bases as candidates changes.ParseBase, the change views' refusals, /api/v0/changes/bases A ref: base whose snapshot is not stored is refused (would_index) with how to store it: the MCP server never indexes. Project change impact refuses ref: bases.
MC-31 callers and impact scope scope production (default) or all: in production scope the results and "? not modelled" ends whose node is test code by the code views' one rule (server.TestScoped, the chain's CH10 test: scope attribute test, or a file the repository's test rules classify as test, built-in names and the tests section of graphvein.yaml; built-in names only for a project member without a checkout) are left out and counted in one unknown (test_scope_hidden: results, ends, how to get them); every production-scope answer carries one unknown naming the parts the scope does not filter (test_scope_unfiltered: bounds, possibly missing callers, near misses, possible callers); in scope all a result in test code has test_code: true, and in either scope a near miss, a possible caller of another member or a possibly missing call site in test code (its node, or a site's caller, by the same rule; a site without a caller by its file) has test_code: true; a kept result whose stored path passes through test code (the target and the result itself excepted) has via_test_code: true; both marks are in the legend (family test_scope); when results were left out, impact's count of unresolved call sites in the files of the results (unknown_calls_in_result_files, MC-16) counts the shown results' files only; request.scope echoes the scope used server.TestScoped over the nodes query.Execute or the project query views return and the stored nodes of the unfiltered items; the file nodes' unresolved_calls_unknown for the shown results' files The filter applies to the walk's results, not the walk: caps, bounds, blind spots (possibly missing call sites), near misses and possible callers of other members count test code too, as test_scope_unfiltered says. via_test_code describes the stored shortest path: a longer production-only path may exist. A left-out result is "in test code, not shown", never "no caller"; no result in production scope with left-out results says so.
MC-32 link_changes project mode: the cross-repository links added, removed or changed (same kind and ends, different stored payload; the endpoints' runs left out) between a kept link pass (base previous, the pass before the newest, or pass:N) and the newest, each with its change, kind and ends, paged; the summary: the view's state (compared, same_pass, no_comparison; only compared lists changes, a state the tool does not know is an MC-D unknown), the passes compared, the counts per change, whether the manifest changed and the members and runs each pass linked changes.DiffProjectLinks through /api/v0/project/links/changes A single-repository server refuses (project_only: no project links). Fewer than two kept passes is an unknown (no_comparison, the view's note), never "no change"; a base that is the newest pass is an unknown (same_pass: nothing compared), never a comparison with zero changes; an unknown pass is refused (base_unknown), another base bad_request. A stale newest pass is an MC-18 unknown. The payload of a changed link is not kept by the journal (omitted). The tool never links or indexes.
MC-33 status settings whether graphvein.yaml's index inputs changed since the last index run (the settings claim contract, ST-43..ST-46): settings with state (unchanged, changed, unknown, not_indexed), changed_keys, unknown_keys and reason on the status tool's index result, and in project mode on each member result freshness.settings of /api/v0/status and of each member of /api/v0/project changed is an unknown (settings_changed: the facts may differ after a re-index) and so is unknown (settings_unknown, with the reason): an unknown comparison is never restated as unchanged. Only the status tool reports it; other tools' envelopes do not carry it.
MC-D default nothing n/a Any field, label value or form this table does not name is passed on as an unknown (not_modelled_by_mcp) with its value, never dropped and never restated as a fact.

Encoding

A tool result carries the envelope as structuredContent (with an outputSchema naming the envelope's fields) and, by default, the same minified JSON as its single text block, as the MCP specification advises for clients that read only text. graphvein mcp --structured-only replaces the text copy with a one-line summary that names the first bound cap or the error first; the envelope is built in one place, so the choice per client changes no claim.

Report a problem with this pageSource: docs/contract/claims/mcp-server.md