Module web_mcp

Module web_mcp 

Source
Expand description

WebMCP - Browser-native agent tool discovery primitives.

Defines the core types for the Web Model Context Protocol (WebMCP), which enables browser-side AI agents to discover and execute tools exposed by web applications via the navigator.modelContext API.

§Architecture

These are pure data types (no behavior) following the cellstate-core pattern. The API crate adds behavior (WebMcpConnector), the SDK wraps it in headless state machines, and the app dogfoods it via the SDK.

§Relationship to MCP

Standard MCP operates server-to-agent (tools exposed by an MCP server). WebMCP operates browser-to-agent: web pages expose tools via navigator.modelContext.registerTool() that any connected agent (browser sidebar, desktop app, or programmatic client) can discover and execute. This module provides the type vocabulary for both sides.

§Discovery Flow

┌────────────────────────────────────────────────────┐
│                WebMCP Discovery Lifecycle           │
│                                                    │
│  Page Load → Detect → Schema Parse → Ready         │
│     ↑                                  │           │
│     │          Execute ← Approve ← ─ ─┘           │
│     │             │                                │
│     └─── Context Update ←──┘                       │
└────────────────────────────────────────────────────┘

Structs§

WebMcpAgentCapabilities
Capabilities an agent advertises to a WebMCP-enabled page.
WebMcpContext
Page context metadata exposed via WebMCP.
WebMcpDiscoveryState
Complete discovery state for a single page.
WebMcpInputSchema
JSON Schema for tool input parameters.
WebMcpManifest
WebMCP manifest for declarative (non-JS) tool exposure.
WebMcpPropertySchema
Schema for a single property within a tool’s input.
WebMcpSecurityPolicy
Security policy governing WebMCP tool access.
WebMcpTool
A tool exposed by a web page via WebMCP.
WebMcpToolAnnotations
Security and behavioral annotations for a WebMCP tool.
WebMcpToolCall
A request to execute a WebMCP tool.
WebMcpToolResult
Result of a WebMCP tool execution.
WebMcpUserContext
User identity context within a WebMCP session.

Enums§

WebMcpDiscoveryPhase
State of the WebMCP discovery lifecycle for a single page.
WebMcpMemoryCapability
Memory capabilities an agent can provide to a WebMCP page.
WebMcpSandboxMode
Sandbox execution mode for WebMCP tools.