package wasix:mcp@25.6.18;
/// MCP router snapshot (2025-06-18) with structured output, resources, elicitation, and tightened auth semantics.
interface router {
/// JSON payload.
type json = string;
/// UTC datetime encoded as string.
type datetime = string;
/// Optional annotations attached to tools/content/resources.
record annotations {
audience: option<list<role>>,
priority: option<f32>,
timestamp: option<datetime>,
}
enum role {
user,
assistant,
}
/// Metadata entry for metadata maps.
record meta-entry {
key: string,
value: json,
}
/// Tool-level annotations (read-only/destructive/etc).
record tool-annotations {
read-only: option<bool>,
destructive: option<bool>,
streaming: option<bool>,
experimental: option<bool>,
}
/// Tool descriptor aligned with the June 2025 MCP spec.
record tool {
/// Programmatic name.
name: string,
/// Human-friendly display title.
title: option<string>,
description: string,
input-schema: json,
/// Structured output schema (replaces ad-hoc `output` hints).
output-schema: option<json>,
annotations: option<tool-annotations>,
/// Greentic-specific metadata surface.
meta: option<list<meta-entry>>,
}
/// Prompts capability (list_changed field).
record prompts-capability {
list-changed: option<bool>,
}
/// Resources capability (subscribe and list_changed fields).
record resources-capability {
subscribe: option<bool>,
list-changed: option<bool>,
}
/// Tools capability (list_changed field).
record tools-capability {
list-changed: option<bool>,
}
/// Completions capability marker.
record completions-capability {
enabled: bool,
}
/// Server-wide capabilities.
record server-capabilities {
prompts: option<prompts-capability>,
resources: option<resources-capability>,
tools: option<tools-capability>,
completions: option<completions-capability>,
}
/// Authorization server descriptor for OAuth/resource metadata.
record authorization-server {
issuer: string,
token-endpoint: option<string>,
}
/// Resource metadata describing auth context.
record resource-metadata {
authorization-servers: list<authorization-server>,
resource-indicator: string,
default-scopes: list<string>,
}
/// Router/server description including resource metadata.
record server-description {
name: string,
title: option<string>,
capabilities: server-capabilities,
resources: option<list<mcp-resource>>,
resource-metadata: option<list<resource-metadata>>,
meta: option<list<meta-entry>>,
}
/// Progress notification from a running tool.
record progress-notification {
progress: option<f32>,
message: option<string>,
annotations: option<annotations>,
}
/// Tool invocation result with structured output.
record tool-result {
content: list<content-block>,
/// Structured JSON output; should conform to `output-schema` when both are present.
structured-content: option<json>,
progress: option<list<progress-notification>>,
meta: option<list<meta-entry>>,
is-error: option<bool>,
}
/// Router response: result or elicitation request.
variant response {
completed(tool-result),
elicit(elicitation-request),
}
/// Elicitation request for additional structured input.
record elicitation-request {
title: option<string>,
message: string,
schema: json,
annotations: option<annotations>,
meta: option<list<meta-entry>>,
}
/// Content variant for tool results.
variant content-block {
text(text-content),
image(image-content),
audio(audio-content),
resource-link(resource-link-content),
embedded-resource(embedded-resource),
}
record text-content {
text: string,
annotations: option<annotations>,
}
record image-content {
data: string,
mime-type: string,
annotations: option<annotations>,
}
record audio-content {
data: string,
mime-type: string,
annotations: option<annotations>,
}
/// Link to a remote resource (no payload embedded).
record resource-link-content {
uri: string,
title: option<string>,
description: option<string>,
mime-type: option<string>,
annotations: option<annotations>,
}
/// Embedded resource payload.
record embedded-resource {
uri: string,
title: option<string>,
description: option<string>,
mime-type: option<string>,
data: string,
annotations: option<annotations>,
}
/// Discoverable resource descriptor.
record mcp-resource {
uri: string,
name: string,
title: option<string>,
description: option<string>,
mime-type: string,
annotations: option<annotations>,
}
record text-resource-contents {
uri: string,
mime-type: option<string>,
text: string,
}
record blob-resource-contents {
uri: string,
mime-type: option<string>,
blob: string,
}
/// Text or binary resource payload.
variant resource-contents {
text(text-resource-contents),
blob(blob-resource-contents),
}
record read-resource-result {
contents: list<resource-contents>,
}
/// Tool-level errors.
variant tool-error {
invalid-parameters(string),
execution-error(string),
schema-error(string),
not-found(string),
}
/// Resource-level errors.
variant resource-error {
execution-error(string),
not-found(string),
}
/// Prompt-level errors.
variant prompt-error {
invalid-parameters(string),
internal-error(string),
not-found(string),
}
/// Completion-level errors.
variant completion-error {
invalid-parameters(string),
execution-error(string),
schema-error(string),
not-found(string),
}
record prompt {
name: string,
description: option<string>,
arguments: option<list<prompt-argument>>,
}
record prompt-argument {
name: string,
description: option<string>,
required: option<bool>,
}
record get-prompt-result {
description: option<string>,
messages: list<prompt-message>,
}
record prompt-message {
role: prompt-message-role,
content: prompt-message-content,
}
enum prompt-message-role {
user,
assistant,
}
variant prompt-message-content {
text(text-content),
image(image-content),
mcp-resource(embedded-resource),
}
/// Completion request payload.
record completion-request {
input: json,
streaming: option<bool>,
meta: option<list<meta-entry>>,
}
/// Completion response payload.
record completion-response {
content: list<content-block>,
meta: option<list<meta-entry>>,
is-error: option<bool>,
}
/// Human-readable router name.
name: func() -> string;
/// Optional human-friendly title.
title: func() -> option<string>;
/// Router instructions/overview.
instructions: func() -> string;
/// Advertised capabilities and metadata.
describe-server: func() -> server-description;
/// List available tools.
list-tools: func() -> list<tool>;
/// Invoke a tool; may elicit more input.
call-tool: func(tool-name: string, arguments: json) -> result<response, tool-error>;
/// Discover server resources.
list-resources: func() -> list<mcp-resource>;
/// Fetch resource contents.
read-resource: func(uri: string) -> result<read-resource-result, resource-error>;
/// List prompts.
list-prompts: func() -> list<prompt>;
/// Fetch a prompt by name.
get-prompt: func(prompt-name: string) -> result<get-prompt-result, prompt-error>;
/// Request a completion.
complete: func(request: completion-request) -> result<completion-response, completion-error>;
}
world mcp-router {
export router;
}