On this page:
load-interface
31.1 Declared identities for ordinary loading
current-build-identity
call-with-build-identity
31.2 Recognizing interface descriptors
interface-descriptor?
interface-requires-state?

31 Loading interfaces with executable identity🔗ℹ

 (require mcp/loader) package: racket-mcp

procedure

(load-interface path 
  #:runtime-build-id runtime-build-id) 
 → interface-descriptor?
  path : (or/c path-string? module-path?)
  runtime-build-id : string?
Loads the module’s mcp-interface in a fresh namespace, shares the current SDK’s descriptor types and runtime parameters, and seals captured workflows to an executable identity. Available from mcp and mcp/loader. Filesystem paths are resolved against the caller’s current directory. Fragments without a server declaration can be loaded, but serving still requires a server.

The nonempty runtime-build-id is the caller’s immutable identity for the already-loaded SDK, its language/compiler dependencies, and the running Racket executable/distribution, including predefined modules. Use the same identity only for the same runtime build. The SDK cannot verify that this supplied identifier truthfully describes already-loaded code. It is never used as a substitute for uncaptured application code. A package version reused across changed development builds does not meet this contract.

Application module code is captured as it is evaluated, including helpers loaded during instantiation. Application declarations without observed code or a retained producer identity cause an error; Racket’s compiled-module cache can require using a fresh loading process. No resume-time file hashing substitutes for the loaded executable. User-written definitions and imports execute with normal module-instantiation semantics. Constructing the interface does not itself start a transport, open workflow storage, or invoke handlers.

A workflow retains its captured namespace. Ordinary dynamic imports during its execution must refer to modules already loaded and included in the sealed build. Prepare those imports during application loading. Changing a captured helper or the runtime build ID rejects incompatible saved execution. Replacing a source file after loading does not replace the code retained by that loaded workflow. Fresh and unreadable symbols are rejected as module names in captured loading: their printed names can alias distinct identities, including predefined modules. Use file modules or stable interned module/submodule names. A public registration API for portable identities of these reflective modules is not implemented yet. This is not a sandbox for trusted Racket code that deliberately changes its own resolver or namespace.

The serving command opts into this loader with an explicit runtime identity:

raco mcp --runtime-build-id MY-IMMUTABLE-RUNTIME-BUILD --state state.sqlite serve application.rkt

The mcp/command entry point starts in Racket’s kernel language and installs observation before loading ordinary SDK libraries. Direct file execution and racket -l mcp/command use this cold entry. The raco mcp launcher starts that entry in a fresh Racket process from the same installation, so libraries already loaded by raco do not escape observation in the serving process. Arguments are passed without a shell; standard streams and the exit status are forwarded. Interrupting the launcher terminates its owned child. For supervisors that forcibly terminate process trees, include the child serving process; an uncatchable parent-only termination does not run Racket custodian cleanup. Importing the kernel command alone does not load the ordinary SDK. Kernel observations transfer to the SDK collector by module registry, and retained loader hooks forward later declarations until the command scope closes. For SDK dependencies evaluated under observation, captured loading uses the actual compiled module code in its original module registry instead of the supplied identity. The explicit identity remains required for dependencies loaded before observation, including predefined runtime modules. Importing the SDK first or calling mcp/cli directly does not retroactively observe those modules.

Use the same compiled SDK build when restarting durable execution. Fresh source compilation can produce different compiled code even without source edits; this is conservatively treated as a different executable. Rebuilds are not promised compatible merely because their source text or package version is unchanged. An SDK code change captured by this entry point invalidates saved execution even when the caller supplies the same runtime identity.

Captured fingerprints now use the mcp-executable/3 format and include the execution namespace’s base phase. Identical code executed at different phases therefore has distinct build identities. On Linux, when /proc/self/exe is readable, the fingerprint includes a cached SHA-256 identity of the running executable image. Its original pathname is never used as a substitute: that pathname may have been replaced since process startup. Unreadable procfs evidence, including stale backing-file handles, is recorded as unavailable. Other platforms currently have no automatic executable-image evidence. This component does not identify shared libraries, host-injected libraries, or the whole runtime distribution, so the explicit runtime build ID remains required. Earlier captured fingerprints are conservatively incompatible with this format; resume them using their compatible SDK/runtime build.

The returned descriptor works with ordinary make-runtime, local dispatch, stdio and HTTP APIs. Captured tool, resource and prompt workflows use the same validation and authorization paths. A changed build currently reaches stdio clients through the runtime’s ordinary internal-error channel; local workflow calls retain the recovery diagnostic.

Executable capture uses retained producer identities when available, including for dependencies declared before its scope began. Otherwise it hashes code that it actually observed being evaluated. A preloaded dependency without either kind of evidence remains unresolved; a replacement file is never used to identify it. The same identity selection applies to observed SDK bootstrap code. The explicit runtime identity is still required for the remaining unobserved runtime baseline.

The language reader starts with kernel-only bootstrap observation before loading its ordinary reader and observer dependencies. After handoff, retained loader callbacks continue forwarding to the installed observer. Reinstalling a seed cannot replace newer code already observed in the same module registry. The language runtime also installs an idempotent observer before subsequent application dependencies load. Source and compiled imports retain the actual evaluated module code, including after the corresponding files change. The observer preserves caller evaluator behavior and scopes records by module registry. Code loaded before the observer remains explicitly unknown. This is private capture infrastructure; it does not yet seal a complete executable identity for the default serving path.

The compiler hook also retains a producer identity in the language metadata of module declarations it compiles. It requests saveable module code, compiles once, hashes the artifact with an unfilled metadata cell, and fills that cell before returning. The identity-information provider itself uses only the kernel language, so a startup query for a stamped kernel module does not load ordinary libraries before its observation boundary. The original language-information provider remains available through delegation. Identity reflection reads an already declared module without loading files or running its handlers; replacing or deleting its files cannot change the retained identity. This is trusted compiler metadata, not a signature or a proof of equivalence across different builds. Any transformation after identity creation requires a new identity. These per-module identities are not yet a complete default-path durable build fingerprint.

Automatic runtime provenance is not asserted for ordinary loading. Applications can use the declared identity contract below without a capture boundary. Inspection commands continue to use the generated manifest rather than this instantiating loader.

31.1 Declared identities for ordinary loading🔗ℹ

parameter

(current-build-identity) → (or/c #f non-empty-string?)

(current-build-identity identity) → void?
  identity : (or/c #f non-empty-string?)
 = #f
The application/runtime identity for descriptors constructed and durable operations executed in this scope. The SDK retains an immutable copy. This is an application assertion, not observed provenance, a code signature, or proof that initialization succeeded. The application must change it whenever its application code, imported helpers, adapters, codecs, SDK, Racket runtime, or native dependencies change in a way that can affect resumed execution. Use an immutable deployment identifier or a digest of the application’s controlled build inputs.

procedure

(call-with-build-identity identity thunk) → any

  identity : non-empty-string?
  thunk : (-> any)
Calls thunk with the declared identity. Workflows created by ordinary make-workflow, macro declarations, or factories retain it after the scope ends. Normal Racket loading and instantiation semantics are preserved; this function neither reloads modules nor seals an observed dependency capture. A failed module initialization propagates normally and does not produce a successful interface.

make-workflow accepts #:build-id, defaulting to the current parameter. make-runtime accepts the same keyword and retains it for dispatch, durable worker execution and startup recovery, including descriptors constructed before that runtime exists. runtime-build-identity returns the retained identity. If both workflow and runtime declare an identity, they must agree; a conflict fails before workflow execution. Constructor validation rejects empty strings and values other than strings or #f.

The identity participates in workflow fingerprints, plain-handler parent rendering state, and local/upstream continuation and task bindings. Changed identities reject incompatible resumes; task input updates reject them before persisting input. Read-only retrieval of recorded native task results and cancellation do not run the old program. Existing terminal task states remain immutable. Direct low-level workflow execution or upstream recovery APIs must run under the matching declared identity scope; runtime recovery functions supply that scope automatically.

(define rt (make-runtime mcp-interface #:store store #:build-id "my-application/42"))

racket application.rkt --build-id my-application/42 --state state.sqlite

raco mcp --build-id my-application/42 --state state.sqlite serve application.rkt

–build-id works with ordinary source and compiled module loading, including the generated direct entry point. It does not instantiate the application twice. serve-interface accepts the corresponding #:build-id keyword. –runtime-build-id remains the separate captured-loader contract above; applications can use both contracts, in which case both identities constrain compatibility. Without either contract, local program/version/codec/adapter checks remain available but do not establish compatibility of imported helpers or the runtime. Reusing a declared ID after changing those dependencies violates the application’s contract; the SDK cannot detect that misdeclaration automatically.

31.2 Recognizing interface descriptors🔗ℹ

procedure

(interface-descriptor? value) → boolean?

  value : any/c
Recognizes an SDK interface descriptor, including descriptors returned by load-interface. The predicate does not instantiate application modules or invoke handlers.

procedure

(interface-requires-state? interface) → boolean?

  interface : interface-descriptor?
Reports whether the published tools, resources, or prompts contain a workflow or an upstream bridge requiring a state store. It inspects descriptor metadata without invoking handlers or credential callbacks. Mounting, renaming, and rebuilding descriptors preserve bridge requirements; removing all stateful declarations with a view removes the requirement. Ordinary application I/O is not inferred from Racket procedures. The serving command uses this predicate to require an explicit state-file path before acquiring runtime resources.