1 Ordinary SDK values and constructors🔗ℹ

mcp exports the ordinary descriptor API alongside the declaration forms. The focused modules are mcp/descriptor, mcp/schema, mcp/workflow, mcp/runtime, mcp/stdio, mcp/http, and mcp/interaction. The following records have their usual Racket predicates and field accessors (for example, tool-descriptor-name). Descriptor construction does not start transports, open application storage, or call handlers.

Value

 

Fields / representation

server-descriptor

 

name version instructions

argument

 

name schema optional? default

prompt-argument

 

The argument fields plus codec.

tool-descriptor

 

name description arguments input-schema output-schema handler annotations workflow execution raw? changes

resource-descriptor

 

name uri description mime-type handler arguments matcher identity workflow renderer depends-on ttl-ms

prompt-descriptor

 

name description arguments handler workflow

interface-descriptor

 

server tools resources prompts completions

resource-ref

 

declaration arguments

request-context

 

principal capabilities request-id cancelled? notify

workflow-descriptor

 

name version fingerprint stages key changes

workflow-stage

 

id kind schema procedure adapter policy

Schema

 

A JSON object hash or Boolean schema; schema binds one of these values.

Result

 

A JSON hash produced by explicit content/result constructors.

Use the checked factories for dynamic interfaces. Raw record constructors remain available, but make-interface and make-runtime recheck their contracts. Resource and prompt declaration identities survive views; display names are not substitutes for those identities. Interface policy and reference maps are obtained with interface-requirements, interface-adapter-bindings, interface-adapter-restrictions, and interface-resource-references; they are not extra positional fields in the public five-field interface record.

  • (make-interface #:server server #:tools tools #:resources resources #:prompts prompts #:completions completions #:requirements requirements #:adapter-bindings adapters #:references references #:adapter-restrictions restrictions). Every keyword is optional: server defaults to #f, declaration collections to empty lists, and policy/reference collections to empty hashes. It returns a checked interface, resolving declaration identities and rejecting duplicates, missing references and ambiguous mappings.

  • (make-tool name arguments handler) accepts optional #:description (empty string), #:output (absent), #:annotations (empty JSON hash), #:workflow (#f), #:execution (’mrtr), #:input-schema (derived from arguments), #:raw? (#f), and #:changes (a two-argument callback returning no keys by default). The unary handler receives the bound argument map. With #:raw? #t, it instead receives the validated wire argument object without applying argument defaults. Successful structured output is validated against #:output.

  • (make-resource name uri handler) accepts optional #:description, #:mime-type, #:render, #:arguments, #:matcher, #:workflow, #:depends-on, and #:ttl-ms. Defaults are an empty description/argument list, no explicit renderer/workflow, generated URI matcher, no dependency keys, and zero TTL. MIME type comes from the renderer or defaults to "text/plain". Its handler receives positional bound URI arguments.

  • (make-prompt name arguments handler) accepts #:description (empty string) and #:workflow (#f). Its unary handler receives a bound argument map. Prompt wire values remain strings; prompt-argument supplies the explicit string codec for a different domain value.

  • (make-workflow name version fingerprint stages) accepts #:key (#f) and #:changes (a two-argument callback returning no keys). It validates the explicit execution-stage program and its codecs. The durable execution chapter defines stage kinds, effects and resumption; compiler IR is private and is not a substitute for these runtime stage records.

Argument names are symbols, schemas are native schema values, and optional? is a Boolean. A default is #f or a unary procedure receiving the map of previously bound arguments. It runs only when that optional argument is absent. The missing sentinel, json-null, and #f remain distinct. Calling a resource descriptor or (resource-ref descriptor values) constructs a checked reference without I/O; link serializes a link and embed resolves content through the current interface and authorization context.

During a handler, (current-request-context) is the request’s context record. Its principal is the configured local principal or verified HTTP identity; capabilities contains this request’s advertised client capabilities; request-id identifies the current request. cancelled? is a zero-argument cooperative cancellation query and notify is the active notification sink. Use protocol helpers such as progress! to enforce their notification contracts. The parameter defaults to #f outside dispatch. A context contains live procedures and must not be persisted as a workflow value.

(make-runtime interface) installs storage, adapters, authorization and request facilities. Optional #:store, #:adapters, #:authorize, #:required-scopes, #:clock, #:recover-tasks? and #:restore-principal configure those facilities; the pagination and freshness chapters document the cache/cursor settings. #:store defaults to #f; durable serving requires an explicit store path. #:recover-tasks? defaults to true, so creating a configured runtime may start persisted task recovery. That is distinct from constructing its descriptors.

(dispatch runtime method params #:principal principal #:id id #:notify notify) returns a protocol result body and raises exn:fail:mcp for a protocol error. Principal defaults to ’local, ID to #f, and notification sink to void. Supply per-request metadata with request-meta. (dispatch-message runtime message #:principal principal #:notify notify) uses the same validation and policy path, accepts a complete JSON-RPC request, and returns the JSON-RPC outcome (or no response for a valid notification). Both transports use this dispatch path. The transport chapters describe event handles and synchronous client calls; only the explicit run-interaction runner follows MRTR/Tasks outcomes using the supplied callbacks.