18 Interface resource-reference maps
make-interface accepts #:references, a hash from tool, resource, or prompt source descriptors to lists of resource descriptors they reference. interface-resource-references returns the normalized immutable map. Sources must belong to the interface. Each target must resolve to exactly one published resource with the same declaration identity; matching a wire name or URI alone cannot satisfy the reference. Duplicate targets are removed.
Mounts combine these maps. Views remap surviving source descriptors and resolve their target identities against the transformed resources. Removing a referenced resource while retaining its source fails during interface construction, before handlers run. Removing both source and target is allowed. Multiple mounted URI views of the same referenced identity are rejected as ambiguous. Cyclic references are allowed because links can be cyclic; recursive embedding retains its own runtime cycle checks.
The ordinary resource-ref constructor checks its resource descriptor, argument list, exact arity, and each argument’s schema through the same path as applying a resource declaration. Neither form reads the resource. References constructed in ordinary helpers or from runtime data still resolve against the active interface: missing and multiply mounted identities raise errors. Dynamic links and embeddings never select a mount merely because it occurs first in the resource list.
For example, after defining a tool open-document and resource document, construct their interface with #:references (hasheq open-document (list document)). A view excluding document then fails while open-document remains exposed. The map survives #lang mcp mounts and runtime validation.
Ordinary tool, resource, and prompt handlers additionally collect lexically bound resource references through syntax-spec’s host-expression API. This includes references introduced by macros and imported through renamed bindings. Quoted names and shadowing host bindings do not create dependencies. The generated procedure carries a private thunk that resolves resource descriptors when the interface is built; discovery does not execute handlers. Explicit maps and collected references combine, so an explicit map cannot erase a known edge.
Collection is conservative across branches and nested lambdas in the handler syntax. It does not inspect separately defined Racket helper procedures or infer references created from arbitrary runtime data. Supply explicit references for those relationships. Generated workflow-stage procedures use the same collection boundary. The workflow descriptor contributes references from every stage, including branches that may not execute, to its enclosing tool, resource, or prompt. Reading those references does not open storage, run a stage, or request input. Ordinary data-API workflows can declare relationships through the explicit interface map.
Manifest declaration entries include resource-references, containing the original resource names and source locations, and reference-analysis set to lexical-handler-syntax. Imported aliases retain the declaration’s original name. Repeated targets are deduplicated and sorted. Missing origin metadata is explicitly marked unknown. These fields describe references visible in handler and workflow-stage syntax; they do not prove that separately defined helpers or dynamic interface expressions introduce no additional references.
Each local resource has a local-id. A reference’s local-target is that identifier when lexical binding resolves to a resource in this manifest, and #f otherwise. These identifiers are local to this generated manifest; they are not wire names or stable identifiers across builds. Imported resources remain external unless their declaration origins resolve to a resource supplied by a statically known mount; names and source files alone do not establish this. Generated bindings need no source location to establish a local target.
References also record binding-provider: the defining module’s file or symbol identity, submodule path, and binding phase. Re-export aliases retain the original provider. This distinguishes same-name resources in different submodules of one file without relying on source positions or generated binding names. Unavailable module-binding information is explicitly #f. These are static declaration identities, not executable compatibility fingerprints.
Resource origins and references also retain an opaque string binding-name from the module binding. Together with the provider, this distinguishes hygienic declarations even when their public names and diagnostic locations coincide. Cross-module resolution uses that binding pair, not source hints. Missing keys leave a reference unresolved. These compiler names are not public wire names or stable build identifiers. Diffs ignore their incidental spelling for resolved public targets; a changed unresolved external binding requires review. String encoding preserves manifest write/read round trips when Racket uses uninterned symbols internally for module bindings.
Prompt declarations also carry local IDs and binding origins. A completion’s prompt-reference records its lexical prompt target using the same provider, binding-name and local-target fields. Mounted views resolve it to the prompt’s published name. Diffs normalize incidental IDs and binding names once that target is resolved; unresolved references require review.
The independent manifest submodule retains manifest-exclusions for resources and prompts explicitly removed by static views. Exclusions survive fragment re-exports. A local handler referencing an excluded resource receives an expansion error when no other static mount supplies it and no dynamic mount could supply it. Multiple known mounts of one referenced binding are ambiguous and also receive an expansion error. Exclusion is not a permanent ban: another mount can supply the declaration. Runtime interface checks still arbitrate computed compositions.
The compiler emits the manifest after declaration right-hand sides expand, using Racket’s module-lifting API. The resulting submodule uses racket/base and quoted data only. Reading it does not instantiate the application or its imported resource providers. Compiling source still executes trusted transformers.
The exported mcp-interface binding carries private compiler metadata while its expression value remains the interface descriptor, including through dynamic-require. Renamed imports and re-exports preserve this metadata. A module-level mount reads only the provider’s independent generated manifest. It includes tools, workflows, resources, prompts and completions, with fresh local identities for mounted resources. Local handler references can resolve to those resources through their recorded binding origins.
Static composition recognizes imported interface bindings, mount-interfaces applications, and view applications with literal inclusion, exclusion, renaming, namespaces and URI maps. The literal grammar includes quoted data, literal hashes, and binding-checked list, hash, hasheq and hasheqv constructors over literals. It does not evaluate host helpers. Views retain declared policy expressions in composition-policies; dynamic policy values remain marked unknown. Duplicate known published identities, overlapping generated URI routes and view removal of an internally referenced resource receive expansion errors.
Computed interface values, dynamic surface transformations, and mounts inside host expression contexts are explicit mount entries with known? set to #f, source locations and the unevaluated expression. Their presence does not assert that their declarations are installed. Documentation and diagrams display these unknown mounts; diffs require review rather than classifying their unknown contents as established additions or removals. Runtime interface checks still apply to dynamically constructed compositions.
Workflow manifest entries also record client-capabilities, with required and optional objects using the protocol capability names and an analysis value of declared-workflow-stages. Input stages require elicitation; #:execution task requires the Tasks extension; task-optional records it as optional because MRTR execution remains available. Task execution modes add task-workers to runtime-requirements. The checked execution identifier is known grammar data, so it does not by itself mark metadata dynamic.
These fields describe the local declared workflow stages, including branches, and the runtime’s capability preflight for those stages. They do not infer hidden input requests in arbitrary Racket helpers, upstream adapters, or dynamically composed interfaces. They are client requirements, not server discovery output. Generated Markdown documentation includes these requirements without evaluating handlers or input-request expressions. Manifest diffs classify a newly required elicitation or Tasks capability as a breaking contract change when both entries contain this analysis. Missing analysis in an older manifest requires review; it does not establish that the capability was previously unnecessary.