The agda-mcp interaction lane¶
File: agda-native-air/docs/agda-mcp/agda-mcp-interaction-lane.md
Purpose: the design record for issue #75 — the second lane of the agda-mcp server, a persistent agda --interaction-json child per resolved project root, serving live scope, type, and definition queries as structured data. This document states the two-lane policy, the wire protocol as observed under the pinned Agda 2.8.0 (probed 2026-08-19/20 inside nix develop .#backend; every exchange quoted below was captured from a live process, not transcribed from Agda's source), the process lifecycle, and what each existing module becomes. It is written before the Haskell, and the implementation is expected to cite it rather than restate it.
1. The two-lane policy¶
This is policy, not suggestion; tool descriptions and reviews should hold changes to it.
- Batch lane — verdicts.
check_file,check_project, andfill_hole'sstatuskeep their issue-#72 contract unchanged: the verdict is read from batchagda's exit code, never from the interaction lane. Interaction mode is tolerant by design —Cmd_loadon a file with open holes succeeds and reports interaction points (§ 3.2 below), where batchagdaexits 42 — which is precisely why the interaction lane must never decide a verdict. The new tools' descriptions say this boundary out loud: they inform, and never decide a build verdict. - Interaction lane — knowledge. A persistent
agda --interaction-jsonchild per resolved project root, speaking IOTCM commands, serving read-only queries: what is this expression's type, what does this name resolve to and why, where is it defined, what does this module export, what does this hole want. None of these questions has an exit code, and none requires editing the file first — the "check a term without committing to it" property that § 3.3 of the feedback document names as what makes them worth a call. - Lexical layer — demoted, not deleted.
AgdaMCP.Holesremains the splicing engine (a pre-Agda source edit structurally needs a source view:fill_holeand the injection path must find a hole's span in the bytes they are about to rewrite) and the fallback for files Agda refuses to load. It is never again the authority for anything Agda can answer; the parity tests keep it honest against the lane'sInteractionPoints.
2. The wire protocol, as observed¶
2.1 Framing¶
The child is spawned as agda --interaction-json and spoken to over stdin/stdout. One IOTCM line per command on stdin; newline-delimited JSON objects on stdout, with two non-JSON line shapes interleaved:
JSON>prompt markers. Agda's reader thread prints one each time it consumes an input line, while a separate executor works through the queued commands — so the marker floats: it can stand alone, or prefix a response line (JSON> {"kind":…}), and it says nothing about command completion. The reader strips a leadingJSON>(repeatedly) and ignores what remains if empty.cannot read: <line>— the reply to an IOTCM line that did not parse. Plain text, not JSON. The process survives it and continues with the next command.
Everything else is a JSON object with a top-level kind. The reader is keyed on kind and never on line position. Kinds observed in the probes: DisplayInfo (with info.kind one of Error, AllGoalsWarnings, GoalSpecific, InferredType, NormalForm, WhyInScope, ModuleContents, Version), InteractionPoints, HighlightingInfo, Status, RunningInfo, ClearRunningInfo, ClearHighlighting, JumpToError.
Commands execute strictly in order: the reader enqueues, a single executor answers, so response streams never interleave across commands. That yields the sentinel discipline the lane runner is built on: after every real command the lane sends Cmd_show_version, whose response —
{"info":{"kind":"Version","version":"2.8.0"},"kind":"DisplayInfo"}
— is unmistakable and state-free; every response collected before it belongs to the real command. No per-command-kind completion heuristics, no timeouts standing in for framing.
2.2 Startup noise¶
The child emits output before the first command when its startup configuration is inconsistent — observed with the flake's agda wrapper, whose --library-file names a registry without agda-dojang while $AGDA_DIR/defaults asks for it:
{"info":{"error":{"message":"error: [LibraryError]\nLibrary 'agda-dojang' not found.\n…"},"kind":"Error","warnings":[]},"kind":"DisplayInfo"}
{"direct":false,"filepath":"/tmp/…/agda2-mode…-0","kind":"HighlightingInfo"}
{"kind":"Status","status":{"checked":false,…}}
This is once per process, not per load (verified against an empty stdin). The lane flushes it by running one sentinel immediately after spawn, before accepting requests, so no command's response collection can misread startup noise as its own failure.
2.3 The IOTCM line and its escaping¶
IOTCM "<absolute-file>" None Direct (<Command> …)
- The second field is the highlighting level.
Nonesuppresses the per-tokenHighlightingInfopayloads that otherwise dominate the stream (aCmd_loadof the 25-lineTwoHoles.agdaproduced ten of them atNonInteractive); error highlighting and the startup trio still appear, and the reader ignores the kind either way. - Every embedded string — file paths, expressions, names — is a Haskell string literal:
showis the escaper. Probed:"\x -> suc x"is rejected whole (cannot read: …, because\xis not a Haskell escape) while"\\x -> suc x"works;"\955 (x : Nat) \8594 x"—show's decimal escapes forλand→— infers(x : Nat) → Nat; a newline ships as\n. The lane builds every IOTCM withshowand never with string concatenation around raw text.
2.4 Cmd_load — the state-establishing command¶
IOTCM "<abs>" None Direct (Cmd_load "<abs>" ["-i", "<dir>", "--library-file=<registry>", "-l", "<lib>", …])
- The second argument is the per-load argv, and it must carry the resolved project flags.
Cmd_load "<file>" []does not inherit a useful context: probed, it produced aLibraryErrornaming the wrapper's nix-store registry and checked the file against whatever remained. The lane passes the same flag list the batch lane would runagdawith — the server's flags plusAgdaMCP.Project.projectExtraFlagsplusfileDirIncludeFlags— so a foreign-project query resolves against the same tree, by construction, as a batch check of the same file (issues #76/#103). -
A successful load ends with
InteractionPoints, preceded byAllGoalsWarningscarrying every visible goal's type — captured onTwoHoles.agda:{"info":{"errors":[],"invisibleGoals":[],"kind":"AllGoalsWarnings","visibleGoals":[{"constraintObj":{"id":0,"range":[{"end":{"col":9,"line":22,"pos":816},"start":{"col":5,"line":22,"pos":812}}]},"kind":"OfType","type":"Nat"},{"constraintObj":{"id":1,…},"kind":"OfType","type":"Nat"}],"warnings":[]},"kind":"DisplayInfo"} {"interactionPoints":[{"id":0,"range":[{"end":{"col":9,"line":22,"pos":816},"start":{"col":5,"line":22,"pos":812}}]},{"id":1,…}],"kind":"InteractionPoints"}The ranges are 1-based (line, col) plus a character offset
pos, in the coordinates of the file as written — literate coordinates for literate files (verified onLiterateMd.lagda.md: its{! zero !}hole reportsstart 22.5, exactly whereHoles.findHolesputs it). A load succeeding on a file with open holes is the tolerance § 1 banishes from verdicts. + A failed load ends withDisplayInfo/ErrorplusJumpToError, and noInteractionPoints— captured on a type error:{"info":{"error":{"message":"/…/TypeErr.agda:4.7-10: error: [UnequalTerms]\nSet !=< Nat\nwhen checking that the expression Nat has type Nat"},"kind":"Error","warnings":[]},"kind":"DisplayInfo"} {"filepath":"/…/TypeErr.agda","kind":"JumpToError","position":67}A parse error has the same shape. The process survives and accepts further commands. + Nothing rewrites the file.
HoleVariants.agda(holes in all four syntaxes,?included) andLiterateMd.lagda.mdhash identically before and after a load;?holes are not expanded on disk. +RunningInfolines carry Agda'sChecking M (path).progress, indented by import depth — the same linesAgdaMCP.Agda.progressModulesalready parses from batch output, and the lane's evidence for "this call re-checked the file from source". That evidence is only as good as the channel: a per-load argv carrying an effective--trace-imports=0emits noRunningInfoat all (probed — the load went straight toAllGoalsWarnings), soAgdaMCP.Interaction.loadCheckedFromSourcereads a line naming the file as a re-check and answers "unknown" whenever the evidence could not arrive: the argv it was handed muted the channel (issue #114; the grammar and its measurements are indocs/agda-mcp/agda-mcp-ask-agda-audit.md§ 4), or the load failed before Agda announced this file — a header that does not match its file name, a parse error — which establishes no interface reuse either. Only a load that succeeded in silence over an open channel reads as reuse, which is the batch signal's own reading of silent success.
2.5 The query commands¶
All verified live; each answer arrives as one DisplayInfo whose info.kind names it. Toplevel variants answer in the scope of the loaded file's top-level module; goal variants take an interaction-point id and answer in the scope at that goal, locals included.
The goal and inference commands name a display mode, Agda's Rewrite (AsIs, Instantiated, HeadNormal, Simplified, Normalised), which decides how the types in the answer are printed; the word on the wire is the constructor's name, read by Agda's derived Read. The lane was first probed in Normalised on Nat fixtures, where every mode prints the same thing, and get_goal and type_of sent it until issue #248. The modes differ on a defined type. On the hole of the #243 field session, Normalised printed a module parameter 𝑮 : Group α ρ as the 528-character Σ type Group abbreviates, ε∈B : ε ∈ B as 145 characters of interpretation term, and the hole's context as 1,326 characters against 168 in AsIs and Simplified; a record type, such as that hole's goal IsSubgroup 𝑮 B, prints the same in every mode, since there is nothing to unfold. So get_goal and type_of send the caller's rewrite, Simplified by default, which is what an editor's C-c C-, and C-c C-d send without a prefix argument (agda2-maybe-normalised in agda2-mode.el); search_in_scope and resolve_name's recovery still send Normalised (§ 5). The goal answer echoes the mode it printed in (goalInfo.rewrite, below); the inference answer does not.
-
Cmd_infer_toplevel <rewrite> "<expr>"→InferredType. The inferred type is in theexprfield (so named on the wire);commandStateechoes the current file and its load mtime:{"info":{"commandState":{"currentFile":["/…/TwoHoles.agda","2026-08-20T02:57:51.892054865Z"],"interactionPoints":[0,1]},"expr":"Nat","kind":"InferredType","time":null},"kind":"DisplayInfo"}The expression need not appear in the file — the § 4 moment — and an ill-typed expression answers with
DisplayInfo/Errorwhose positions are in the expression's own coordinates (1.1-4: error: [CannotApply] …), not the file's. +Cmd_infer <rewrite> <goalId> noRange "<expr>"→GoalSpecificwrappinggoalInfo:{"expr":"Nat","kind":"InferredType"}: the same answer, in the goal's scope. +Cmd_compute_toplevel DefaultCompute "<expr>"→NormalForm("expr":"2"forimplicitOnly {suc 1});Cmd_compute DefaultCompute <goalId> noRange "<expr>"is the goal variant. +Cmd_why_in_scope_toplevel "<name>"/Cmd_why_in_scope <goalId> noRange "<name>"→WhyInScopewiththing(the name as asked) andmessage, the provenance prose:g is in scope as * a defined name TwoHoles.g brought into scope by - its definition at /…/TwoHoles.agda:21.1-2One
*bullet per candidate — an ambiguous name lists them all, each with its own chain (captured on the two-openfixture:AmbigHole.Source1.ambviathe opening of Source1 at …:9.6-13thenits definition at …:4.3-6, and likewise forSource2.amb). A re-export chains through every hop — captured on the barrel fixture:originalName is in scope as * a defined name ReexportOrigin.originalName brought into scope by - the opening of ReexportBarrel at - the opening of ReexportOrigin at - its definition at /…/ReexportOrigin.agda:14.1-13Chain steps can carry an empty location (the blank
atabove — those openings live in other modules' scope info). A local variable answersa variable bound at <file>:<L>.<C>-<C'>, only at a goal. An unknown name answers the same kind withmessage"<name> is not in scope."— not an error. Thefilepathfield in this response is the current file's directory, not an answer; the message is the answer. +Cmd_show_module_contents_toplevel Simplified "<module>"/Cmd_show_module_contents Simplified <goalId> noRange "<module>"→ModuleContents:{"info":{"contents":[{"name":"_+_","term":"Nat → Nat → Nat"},…],"kind":"ModuleContents","names":["Nat"],"telescope":[]},"kind":"DisplayInfo"}The module must be in scope in the loaded file —
Agda.Builtin.Natanswers in a file that imports it andNotInScopein one that does not, and the loaded file's own top-level module name is itselfNotInScope. The empty string names the file's own top-level module and lists its definitions (g,h,implicitOnlyforTwoHoles). +Cmd_goal_type_context <rewrite> <goalId> noRange ""→GoalSpecificwith the goal's type and its context as data, with no source mutation and no injected macro. Captured inNormalised;rewritein the answer is the mode that printed it:{"info":{"goalInfo":{"boundary":[],"entries":[{"binding":"Nat","inScope":true,"originalName":"x","reifiedName":"x"},{"binding":"Nat","inScope":true,"originalName":"y","reifiedName":"y"}],"kind":"GoalType","outputForms":[],"rewrite":"Normalised","type":"Nat","typeAux":{"kind":"GoalOnly"}},"interactionPoint":{"id":0,…},"kind":"GoalSpecific"},"kind":"DisplayInfo"} -
Cmd_show_version→Version— the sentinel (§ 2.1). -
Cmd_autoOne Simplified <goalId> noRange "<options>"(issue #205) runs Agda's own proof search at the goal; under Agda 2.8 that is Mimer, which replaced Agsy in 2.7. It is not a query: on success Agda gives the term it found into its own state, with force, so the point is consumed and a forced re-load is owed, exactly as after a give. Probed on the benchmark and on the suite'sAutoSearch.agda, three answers. A term found is a top-levelGiveActionwhosegiveResult.stris Mimer's printing (Agda's pretty printer, which breaks a long term across lines and starts some continuations at column 1), then anInteractionPointslist without the point:{"giveResult":{"str":"m , n"},"interactionPoint":{"id":0,"range":[…]},"kind":"GiveAction"}Nothing found, within the search's time or its space, is
{"info":{"info":"No solution found","kind":"Auto"},"kind":"DisplayInfo"}, the message the same in both cases. A refusal is aDisplayInfo/Errorwith its text underinfo.error.message: a hint the scope cannot name (hints are read before the search), or a term the search found that Agda prints and then cannot read back in the hole's scope, most oftenNotInScopefor a record field spelled by its full internal name (AutoScopeInner.Cell.contents). The options are the hole's contents as an editor would send them, read byAgda.Mimer.Options(§autoinagda-mcp/README.md);-tis CPU time, checked between search steps. Neither the empty answer nor a refusal changes the state: the search runs in a local copy of it, and the interaction loop puts back the state it held before a failed command.
2.6 Scope model gotchas, probed¶
- A hole-free file's toplevel scope loses file-local
opens. After loading a file whose last-value declarations sit underopen Source1/open Source2and which has no interaction points,Cmd_why_in_scope_toplevel "amb"answersnot in scope— while the identical file plus one trailing hole answers with both candidates and full chains, and so does the goal variant. Qualified names (Source1.amb) resolve either way, as do names opened from imports (zeroviaopen import Agda.Builtin.Nat, its opening location degraded to blank). The same degradation shows in rendering: a type the source-checked scope printed asNatprints fully qualified (Agda.Builtin.Nat.Nat) once the file is re-loaded from its interface, so two queries can render one type differently depending on load provenance. Consequence:resolve_nameprefers a goal-scoped query when the file has any interaction point, and theScopeAmbiguous.agdafixture carries a hole on purpose. - The ambiguity error is itself an answer.
Cmd_inferon an ambiguous unqualified name fails with the field session's exact shape —[AmbiguousName] Ambiguous name amb. It could refer to any one of Source1.amb bound at <loc> Source2.amb bound at <loc>— and on a near-miss with[NotInScope] … (did you mean 'Source1.amb' or 'Source2.amb'?).resolve_namecomposes these:why_in_scopefirst; when that says not-in-scope, aninferof the bare name recovers the candidate list, and each suggested qualified spelling can bewhy_in_scoped for its chain. - No auto-reload on change; auto-load on switch. A query after an on-disk edit answers against the old state (probed: a definition appended to the file is
not in scopeuntil an explicitCmd_load). Conversely, a toplevel query naming a file that is not current triggers a load of it — with an argv the lane did not choose — so the lane always issues its own explicitCmd_loadfirst and never leans on the implicit one. A query issued while the current file's last load failed replays the failure rather than answering stale (probed on a parse-error file), but the lane still gates queries on its own load bookkeeping so the failure surfaces once, structurally. - A re-load re-checks. A file with open holes writes no interface, so
Cmd_loadof even an unchanged such file re-typechecks it (probed: two identical loads, twoCheckinglines), and switching files A → B → A re-checks A on return. Re-loading only on evidence of change is therefore load-bearing for the economics, not a nicety.
2.7 Economics, measured¶
Probed on this session's hardware, disk-warm .agdai interfaces throughout (the honest comparison: the batch lane is disk-warm too). The subject file imports AgdaDojang.Debug and Data.Nat.
- Batch lane:
agda <flags> <file>= 2.78 s, then 2.60 s on the repeat — paid per call, so five scope questions cost ~13 s. - Interaction lane: process start +
Cmd_load= 2.59 s once; the same five knowledge queries after the load added less than measurement noise (2.580 s total for load plus all five, versus 2.589 s for load alone — each query is on the order of a millisecond). - Micro-fixture floor: a nine-command batch against
TwoHoles.agda, load included, completes in 0.04 s of wall clock. - The #83 field test's shell baseline was a 10.0 s median per check. The asymptotic claim for the tool descriptions, scoped to what a one-current-file lane can honestly promise: the first question about a file costs one load, and every further consecutive question about it is effectively free until the file changes or the lane's current file switches away — alternating between two files under one root pays the switched-to file's load each time (measured warm on the fixture pair: tens of milliseconds; a full re-typecheck for a holed file, which writes no interface).
3. Process lifecycle¶
AgdaMCP.Interaction owns a registry of lanes, one per resolved project root.
- Key. The lane key is the
pcRootof theAgdaMCP.Project.resolveProjectanswer for the queried file — the same resolution, run per call, that the batch tools use, including itsProjectMismatchrefusal. Since #103/PR 104 a server is routinely asked about foreign checkouts, so multiple simultaneous roots are the design case, not an edge case: the registry is a map, not a slot. - Spawn.
agdaBin cfgwith the single argument--interaction-json, inheriting the server's working directory exactly as the batch lane's one-shotagdadoes — the server's--agda-flagsmay name paths relative to that directory (the shipped--library-file=agda/librariesis exactly that), and the two lanes must resolve one file against one tree. Project flags ride eachCmd_load, not the process argv, so one child serves every file under its root; the root keys the registry, it is not a chdir. After spawn the lane flushes startup noise with a sentinel (§ 2.2) before its first real command. - Requests. Serialized per lane under an
MVar; each request is (ensure loaded → command → sentinel → collect bykind).ensure loadedsendsCmd_loadwith the resolved argv iff the lane's current file differs from the request's, the file's stamp — mtime, size, and a content fingerprint, so a same-size rewrite under a preserved mtime still counts — changed since the lane last loaded it, the last load of it failed, or the client passedreload: true(the escape hatch for a changed dependency, which no stamp on the queried file can see). The registry is safe for concurrent callers on distinct roots, but the stdio server loop that drives it is itself serial, so at most one request is ever in flight — capability, not yet behavior. - Timeouts. Every request runs under one deadline (the server's
--timeout, as in the batch lane), and every phase shares its remaining budget — the spawn's startup flush, the load, the query, and the pipe writes as well as the reads, since a child that stopped consuming stdin would otherwise block a large write forever. On expiry the lane kills the child's whole process group by the issue-#77 ladder — SIGINT, then SIGTERM, then SIGKILL, each rung taken while the group still has members — reaps it, surfaces a structured timeout naming the bound, and marks the lane dead; the next request respawns it. Killing rather than in-band cancellation is deliberate v1 simplicity:Cmd_abortexists but its interleaving with a queued reader is its own protocol study, noted as follow-on work. - Crash and shutdown. A child that exits or closes its pipes mid-request surfaces as a structured failure naming the lane, the event, and the child's stderr tail — never as a bare
-32603, the #101 lesson. The lane is removed and respawned on next use. A child found dead between requests (it crashed while idle) is replaced silently, its pipe handles closed but its ladder deliberately skipped: the ladder probes and signals the raw pgid, and a long-dead child's pgid may have been recycled by an unrelated process group. Server shutdown latches the registry closed under its own lock — a later request is refused structurally (event: "shutdown") rather than spawning a child nothing would stop, and a slot an in-flight request still holds is waited for, not skipped, so its lane cannot be restored into a registry nobody will drain again. FromcreateProcessto the registry, a spawning call owns its child undermask/onException, so a cancellation mid-spawn stops the child rather than leaking it. An idle lane (no request for the configured idle bound) is shut down by closing its stdin, which Agda answers by exiting cleanly (probed: rc 0 on EOF). Server exit closes every lane the same way. - The Agda behind a lane (issue #347). A lane answers only from the Agda that
--agda-binwould start now. Before spawning a child the lane takes a stamp of that Agda (AgdaMCP.AgdaStamp): the real path--agda-binresolves to, every symlink followed; a fingerprint of its bytes when it is 64 KiB or less (a wrapper script), else its size and modification time (a binary); and, when the server has--agda-identity-command, that command's output, for a launcher whose own path and bytes never change (scripts/agda-for-flake.sh --print-keyprints the key it would build under). A request compares a fresh stamp with the lane's under the slot's lock, before the body runs; on a difference it stops the lane as the reaper does and spawns another, and the answer'slane.loadisrestarted. The bytes, not the metadata: a dev shell that rewrites its wrapper on every entry (agda-algebras'.agda/bin/agda, rewritten with the same bytes and a new mtime three entries in a row, measured) must not restart every lane at everynix develop. The identity command costs a process (15 ms for the launcher on formal-ledger-specifications), so its output stands for--agda-identity-ttlseconds (default 2) after the run, while a spawn always takes a fresh run; the stamp is taken before the spawn, so a change in between leaves a stamp older than the child and costs at most one restart more than needed. The batch path's peek declines a lane whose stamp differs, computing the stamp only once the stored load would otherwise vouch for the file. - Echo. Every response carries the #72-style echo, in this lane's vocabulary: the
projectblock (the sameProjectContextserialization the batch tools emit), thecommandblock naming the child (binary,args = ["--interaction-json"],cwd= the server's working directory the child inherits), and alaneblock: root, child pid, whether this call spawned the child, whether and why it (re)loaded the file (reused,first,switch,changed,retry,forcedfor the client'sreload: true, orrestartedwhen the lane's Agda had changed and this call restarted it), the load's own elapsed milliseconds beside the call's total, the child's reported Agda version, the stamp of the Agda the lane was started with (agdaStamp {path, contents, identity?}), and the exact IOTCM lines this call sent, sentinel included, so a call can be replayed by hand. Since issue #184 that is the echo of an answer to a call that passesverbose: true; the default answer keepslane {load, loadElapsedMs?}andproject {root, rootSource}, drops thecommandblock and the rest of the other two, and an error response keeps everything. Beside thelaneblock the response carriescheckedFromSource, the batch tools' cache signal in this lane's vocabulary:falsefor a reused load, since noCmd_loadran and nothing was checked, and absent when the answer's evidence could not arrive: a per-load argv that muted the progress channel, or a load that failed before Agda announced the file (§ 2.4, issue #114). The one thing it never carries is a verdict: the tools' descriptions and their responses both say these calls inform and never decide a build verdict.
4. What each existing module becomes¶
AgdaMCP.Agda— unchanged: the batch subprocess layer, the verdict source, the kill ladder generalized by #77/#78. The lane borrows its ladder constants and itsChecking-line parser, not its process model (one-shot vs persistent).AgdaMCP.Project— unchanged in behavior, promoted in role: its per-call resolution now also keys the lane registry, so the "which tree" answer and the "which process" answer cannot diverge.AgdaMCP.Holes— the splicing engine and the pre-Agda source view (codeOnly,findHolesfor edits and for files Agda refuses), no longer the authority for anything Agda can answer; parity tests hold it to the lane'sInteractionPointsacross the fixture matrix.AgdaMCP.Tools.ProofState— itsget_goalnow answers from the lane first (issue #108):Cmd_goal_type_contextreturns Agda's own goal display as data — probed byte-identical to the macro's goal strings on the fixture matrix — with no file mutation, and the response sayssource: "interaction-lane"with the lane echo in place of a verdict. The injection path remains as the fallback (source: "injected-macro") for a lane that crashed, could not start, a file that does not load there, or a shutting-down registry — and it is the one path that reports binder visibility, which Agda's goal display does not carry. A lane timeout surfaces as the structured lane failure rather than silently running the fallback behind it, which would double the bound. The batch verdict tools also gained a free enrichment:check_fileandget_diagnosticsfill their hole listings'goalfields from a warm lane's storedAllGoalsWarningswhen — and only when — the lane's recorded load matches the file's current bytes (a peek, never a lane call), keeping the"?"placeholder otherwise. The same peek reads the same response's invisible goals (issue #115): each unsolved meta's name, printed type, and range lands in the[UnsolvedMetaVariables]and[UnsolvedConstraints]diagnostics'involved.metas. That is the one § 5 payload batch prose cannot carry at all, since Agda prints its unsolved metas' locations and never their types;involved.metaTypesstays exactly what the prose said, so a cold or stale lane leaves the response byte-identical, and the batch exit code remains the only verdict on a class this lane tolerates.AgdaMCP.Interaction(new) — the lane runner of § 3.AgdaMCP.Tools.LiveQueries(new) — the tool handlers over the lane:type_of,normalize,resolve_name,definition_of,exports_of.AgdaMCP.Server— registers the five new tools and their descriptions; dispatch unchanged otherwise.
5. The tools, mapped to the protocol¶
Each of the six below takes filePath (absolute; resolved and refused exactly as the batch tools do, per #101) and verbose (issue #184), and answers with the echo of § 3, lean unless verbose is true; get_goal and search_in_scope take the lane too and are documented with their own tools. get_goal takes rewrite as type_of does (issue #248), while search_in_scope reads the goal and types its rows in Normalised, the mode it was built and measured in: its query tokens come from the goal's display, and its lane-form statement exclusion compares printed types.
type_of(filePath, expr, line?, column?, rewrite?)→Cmd_inferat the goal whose range contains the position when one does, elseCmd_infer_toplevel, printed in the call'srewritemode,Simplifiedby default (issue #248), which the answer echoes asrewrite. Answers for expressions not present in the file. The optional column decides between two goals sharing a line, whose scopes can differ (probed:(\ m -> {!!}) {!!}bindsmin the first hole only); a line alone selects the earliest goal on it.normalize(filePath, expr, line?, column?)→Cmd_compute/Cmd_compute_toplevel,DefaultCompute.resolve_name(filePath, name, line?, column?)→Cmd_why_in_scope(goal-scoped when the position addresses a goal, else toplevel), parsed into candidates{name, qualified?, kind?, provenance chain with file/line/col steps, definition site}; on a not-in-scope answer the ambiguity recovery of § 2.6 runs before the tool reports an empty candidate list.definition_of(filePath, name, line?, column?, maxLines?)→ theresolve_namemachinery, projected to each candidate'sits definition atstep: qualified name, file, line, column; and since issue #185 each site'ssource, the declaration it opens quoted from the file on disk (at mostmaxLineslines, default 40,0for all). The quote is a read of the file, not a lane query: no command answers a declaration's range, soAgdaMCP.Declarationcuts it by layout and the answer names the line range it quotes.exports_of(filePath, module, limit?, offset?, pattern?)→Cmd_show_module_contents_toplevel Simplified;modulemust be in scope infilePath, and""names the file's own top-level module. Agda answers with the whole surface and the tool sends one page of it (issue #184):limitmembers with their types (default 20; 0 for all), fromoffset, among the members whose name containspattern(ignoring case), withtotalandtruncatedon every answer andnextOffsetand theremainingnames when the page is not the last. A library module's surface printed whole was 23 KB an answer in the #162 arms, nearly all of it types.
auto(filePath, line+column | holeIndex, hints?, hintMode?, timeoutMs?, skip?) (issue #205, registered only with --auto) → one Cmd_why_in_scope per hint at the goal, refusing a hint the search cannot use or cannot read, then Cmd_autoOne Simplified at the goal the address names, the hole matched to its interaction point by index and coordinates as get_goal matches it, with the options built from the declared fields; a found term is joined onto one line and the file re-loaded before the answer, whose resetMs says what that cost, and every answer names the hole searched in addressed (the one-hole rule of issue #201 applies). The answer is a candidate for fill_hole, never a verdict.
scope_at(filePath, line), the sixth tool issue #75 proposed, is not protocol-backed: no interaction command enumerates the names in scope (the module-contents command lists one module's members, not the environment; the goal commands answer point questions). Per the issue's own bar (§ 2.2 of the feedback document: ship only where the server beats the shell), it is omitted rather than approximated with grep, and the finding is recorded on issue #75.