webmcp library

Framework-independent WebMCP API for Dart web applications.

Classes

WebMcp
Entry point for WebMCP feature detection and tool registration.
WebMcpAnnotations
Hints that help an agent handle a tool safely.
WebMcpExecutionContext
Information associated with one invocation of a tool.
WebMcpRegistration
A registered tool whose lifecycle can be ended with unregister.
WebMcpResult
A JSON-serializable result returned to a WebMCP agent.
WebMcpSupport
A feature-detection result with a status and readable explanation.
WebMcpTool
A tool exposed by the current web page to browser agents.
WebMcpToolCallEvent
Diagnostic information emitted after a tool invocation completes.
WebMcpTypedTool<T>
A WebMcpTool that decodes its JSON input into an application type.

Enums

WebMcpSupportStatus
Why WebMCP is or is not available in the current environment.
WebMcpToolCallStatus
Outcome of a WebMCP tool invocation.

Properties

webMcpLogger WebMcpLogger?
Internal process-wide logger shared with the browser adapter.
getter/setter pair

Functions

emitWebMcpLog(WebMcpToolCallEvent event) → void
Delivers event without allowing logger failures to escape.

Typedefs

WebMcpInputDecoder<T> = T Function(Map<String, Object?> input)
Converts raw JSON object input into an application-specific type.
WebMcpLogger = void Function(WebMcpToolCallEvent event)
Receives diagnostic information after a tool call completes.
WebMcpToolHandler = FutureOr<Object?> Function(Map<String, Object?> input, WebMcpExecutionContext context)
Handles a tool call with raw JSON object input.
WebMcpTypedToolHandler<T> = FutureOr<Object?> Function(T input, WebMcpExecutionContext context)
Handles a tool call after its input has been decoded to T.

Exceptions / Errors

WebMcpException
An error reported while registering or executing a WebMCP tool.
WebMcpToolException
A failure that should be returned to the agent in a structured form.