@mcp-fe/mcp-worker 0.1.11 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ /**
2
+ * WebMcpAdapter — bridge between WorkerClient's tool system and the WebMCP API.
3
+ *
4
+ * Responsibilities:
5
+ * - Feature-detect `navigator.modelContext` availability
6
+ * - Map internal ToolDefinition + ToolHandler to the ModelContextTool format
7
+ * - Track which tools have been registered via WebMCP for cleanup
8
+ * - Provide register / unregister / cleanup that are safe no-ops when API is absent
9
+ *
10
+ * Design principles:
11
+ * - The adapter is ADDITIVE: the worker-based system remains the primary transport.
12
+ * WebMCP registration is a secondary channel for browser-level tool discovery.
13
+ * - Enabled by default — auto-detects browser support. Can be explicitly disabled.
14
+ * - All public methods are safe to call even when the API is unavailable —
15
+ * they silently return without throwing.
16
+ * - The WebMCP API (§5.2) is synchronous: registerTool() and unregisterTool()
17
+ * return `undefined`. The adapter wraps them in try/catch for safety.
18
+ *
19
+ * @see https://webmachinelearning.github.io/webmcp/
20
+ */
21
+ import type { ToolDefinition } from '../shared/types';
22
+ import type { ToolHandler, ToolOptions } from './tool-registry';
23
+ import type { ModelContextTool } from './web-mcp-types';
24
+ export declare class WebMcpAdapter {
25
+ /** Tracks names of tools currently registered via WebMCP API */
26
+ private registeredTools;
27
+ /** Whether the adapter is enabled (enabled by default — auto-detects browser support) */
28
+ private enabled;
29
+ /**
30
+ * Check if the browser exposes the WebMCP API (`navigator.modelContext`).
31
+ *
32
+ * Safe to call in any environment (SSR, workers, older browsers).
33
+ *
34
+ * @see https://webmachinelearning.github.io/webmcp/#navigator-extension
35
+ */
36
+ static isSupported(): boolean;
37
+ /**
38
+ * Convenience: instance-level check that also respects the `enabled` flag.
39
+ */
40
+ isAvailable(): boolean;
41
+ /**
42
+ * Enable or disable the WebMCP adapter.
43
+ *
44
+ * When disabled, `registerTool` / `unregisterTool` become silent no-ops
45
+ * even if the browser supports the API.
46
+ */
47
+ setEnabled(value: boolean): void;
48
+ /**
49
+ * Register a tool with the WebMCP API (`navigator.modelContext.registerTool()`).
50
+ *
51
+ * Silently returns if the API is unavailable or the adapter is disabled.
52
+ * Per spec, `registerTool()` throws if a tool with the same name already exists,
53
+ * so we unregister first if needed (idempotent update).
54
+ *
55
+ * @param name - Tool name
56
+ * @param description - Human-readable description (required by spec)
57
+ * @param inputSchema - JSON Schema for tool inputs
58
+ * @param handler - Async handler executed in the main thread
59
+ * @param options - Additional MCP tool options (annotations, …)
60
+ */
61
+ registerTool(name: string, description: string | undefined, inputSchema: Record<string, unknown>, handler: ToolHandler, options?: ToolOptions): void;
62
+ /**
63
+ * Unregister a tool from the WebMCP API (`navigator.modelContext.unregisterTool()`).
64
+ *
65
+ * Safe to call even if the tool was never registered via WebMCP.
66
+ *
67
+ * @param name - Tool name to unregister
68
+ * @returns `true` if the tool was found and unregistered, `false` otherwise
69
+ */
70
+ unregisterTool(name: string): boolean;
71
+ /**
72
+ * Unregister ALL tools registered via WebMCP.
73
+ *
74
+ * Uses `navigator.modelContext.clearContext()` when available (per spec, clears
75
+ * all tools at once), otherwise falls back to individual unregisterTool calls.
76
+ */
77
+ clearAll(): void;
78
+ /**
79
+ * Check if a tool is registered via WebMCP.
80
+ */
81
+ isRegistered(name: string): boolean;
82
+ /**
83
+ * Get names of all tools registered via WebMCP.
84
+ */
85
+ getRegisteredTools(): string[];
86
+ /**
87
+ * Map internal ToolAnnotations to WebMCP ToolAnnotations.
88
+ * The spec currently only defines `readOnlyHint`.
89
+ */
90
+ private mapAnnotations;
91
+ /**
92
+ * Convert internal ToolDefinition to ModelContextTool format (utility).
93
+ * Requires an execute callback to be provided separately.
94
+ */
95
+ static toModelContextTool(tool: ToolDefinition, handler: ToolHandler): ModelContextTool;
96
+ }
97
+ //# sourceMappingURL=web-mcp-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-mcp-adapter.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/client/web-mcp-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAEV,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,aAAa;IACxB,gEAAgE;IAChE,OAAO,CAAC,eAAe,CAAqB;IAE5C,yFAAyF;IACzF,OAAO,CAAC,OAAO,CAAQ;IAMvB;;;;;;OAMG;WACW,WAAW,IAAI,OAAO;IAapC;;OAEG;IACI,WAAW,IAAI,OAAO;IAQ7B;;;;;OAKG;IACI,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IASvC;;;;;;;;;;;;OAYG;IACI,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,WAAW,GACpB,IAAI;IAuCP;;;;;;;OAOG;IACI,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAyB5C;;;;;OAKG;IACI,QAAQ,IAAI,IAAI;IAoCvB;;OAEG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1C;;OAEG;IACI,kBAAkB,IAAI,MAAM,EAAE;IAQrC;;;OAGG;IACH,OAAO,CAAC,cAAc;IAUtB;;;OAGG;WACW,kBAAkB,CAC9B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,WAAW,GACnB,gBAAgB;CAapB"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * WebMCP API type definitions
3
+ *
4
+ * These types model the browser API (`navigator.modelContext`)
5
+ * based on the WebMCP specification (webmachinelearning.github.io/webmcp).
6
+ *
7
+ * The API allows web pages to register MCP tools with the browser/user-agent,
8
+ * enabling AI agents, browser's agents, and assistive technologies to discover and
9
+ * invoke them without relying on custom worker transports.
10
+ *
11
+ * When the API is not available, the existing worker-based transport is used
12
+ * as the sole registration path. When the API IS available, tools are registered
13
+ * in BOTH systems (worker for backward compat + browser-level for discovery).
14
+ *
15
+ * @see https://webmachinelearning.github.io/webmcp/
16
+ */
17
+ /**
18
+ * Callback invoked to perform user interaction (e.g., showing a confirmation dialog).
19
+ *
20
+ * @see https://webmachinelearning.github.io/webmcp/#callbackdef-userinteractioncallback
21
+ */
22
+ export type UserInteractionCallback = () => Promise<unknown>;
23
+ /**
24
+ * Represents an agent executing a tool provided by the site through the ModelContext API.
25
+ *
26
+ * @see https://webmachinelearning.github.io/webmcp/#modelcontextclient
27
+ */
28
+ export interface ModelContextClient {
29
+ /**
30
+ * Asynchronously requests user input during the execution of a tool.
31
+ * The callback function is invoked to perform the user interaction,
32
+ * and the promise resolves with the result of the callback.
33
+ */
34
+ requestUserInteraction(callback: UserInteractionCallback): Promise<unknown>;
35
+ }
36
+ /**
37
+ * Callback invoked when an agent calls a tool.
38
+ * Receives the input parameters and a ModelContextClient object.
39
+ *
40
+ * @see https://webmachinelearning.github.io/webmcp/#callbackdef-toolexecutecallback
41
+ */
42
+ export type ToolExecuteCallback = (input: object, client: ModelContextClient) => Promise<unknown>;
43
+ /**
44
+ * Optional annotations providing additional metadata about a tool's behavior.
45
+ *
46
+ * @see https://webmachinelearning.github.io/webmcp/#dictdef-toolannotations
47
+ */
48
+ export interface WebMcpToolAnnotations {
49
+ /**
50
+ * If true, indicates the tool does not modify any state and only reads data.
51
+ * This hint helps agents decide when it is safe to call the tool.
52
+ */
53
+ readOnlyHint?: boolean;
54
+ }
55
+ /**
56
+ * Describes a tool that can be invoked by agents.
57
+ *
58
+ * @see https://webmachinelearning.github.io/webmcp/#dictdef-modelcontexttool
59
+ */
60
+ export interface ModelContextTool {
61
+ /** A unique identifier for the tool. Used by agents to reference the tool. */
62
+ name: string;
63
+ /** A natural language description of the tool's functionality. */
64
+ description: string;
65
+ /** A JSON Schema object describing the expected input parameters. */
66
+ inputSchema?: object;
67
+ /** Callback invoked when an agent calls the tool. */
68
+ execute: ToolExecuteCallback;
69
+ /** Optional annotations providing additional metadata about the tool's behavior. */
70
+ annotations?: WebMcpToolAnnotations;
71
+ }
72
+ /**
73
+ * Options for `provideContext()`.
74
+ *
75
+ * @see https://webmachinelearning.github.io/webmcp/#dictdef-modelcontextoptions
76
+ */
77
+ export interface ModelContextOptions {
78
+ /** A list of tools to register with the browser. Each tool name must be unique. */
79
+ tools?: ModelContextTool[];
80
+ }
81
+ /**
82
+ * The `ModelContext` interface provides methods for web applications to register
83
+ * and manage tools that can be invoked by agents.
84
+ *
85
+ * Accessed via `navigator.modelContext`.
86
+ *
87
+ * @see https://webmachinelearning.github.io/webmcp/#model-context-container
88
+ */
89
+ export interface ModelContext {
90
+ /**
91
+ * Registers the provided context (tools) with the browser.
92
+ * Clears any pre-existing tools and other context before registering the new ones.
93
+ */
94
+ provideContext(options?: ModelContextOptions): void;
95
+ /**
96
+ * Unregisters all context (tools) with the browser.
97
+ */
98
+ clearContext(): void;
99
+ /**
100
+ * Registers a single tool without clearing the existing set of tools.
101
+ * Throws an error if a tool with the same name already exists,
102
+ * or if the inputSchema is invalid.
103
+ */
104
+ registerTool(tool: ModelContextTool): void;
105
+ /**
106
+ * Removes the tool with the specified name from the registered set.
107
+ */
108
+ unregisterTool(name: string): void;
109
+ }
110
+ declare global {
111
+ interface Navigator {
112
+ /**
113
+ * WebMCP API — available when the browser supports the WebMCP specification.
114
+ * Use `WebMcpAdapter.isSupported()` for safe feature detection.
115
+ *
116
+ * @see https://webmachinelearning.github.io/webmcp/#navigator-extension
117
+ */
118
+ readonly modelContext?: ModelContext;
119
+ }
120
+ }
121
+ export {};
122
+ //# sourceMappingURL=web-mcp-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-mcp-types.d.ts","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G,IAAI,CAAC;CACpC;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,SAAS;QACjB;;;;;WAKG;QACH,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;KACtC;CACF;AAGD,OAAO,EAAE,CAAC"}
@@ -45,6 +45,14 @@ export type WorkerClientInitOptions = {
45
45
  serviceWorkerUrl?: string;
46
46
  /** Backend WebSocket URL to configure inside the worker (optional) */
47
47
  backendWsUrl?: string;
48
+ /**
49
+ * Enable WebMCP API registration via `navigator.modelContext`.
50
+ * When `true` (default) and the browser supports the WebMCP spec, tools will be
51
+ * registered both in the worker transport AND via the browser API.
52
+ * Set to `false` to explicitly disable WebMCP registration.
53
+ * Defaults to `true`.
54
+ */
55
+ enableWebMcp?: boolean;
48
56
  };
49
57
  export declare class WorkerClient {
50
58
  private sharedWorkerUrl;
@@ -60,6 +68,7 @@ export declare class WorkerClient {
60
68
  private isInitialized;
61
69
  private initResolvers;
62
70
  private toolRegistry;
71
+ private webMcpAdapter;
63
72
  private tabId;
64
73
  private static readonly TAB_ID_STORAGE_KEY;
65
74
  constructor();
@@ -226,6 +235,28 @@ export declare class WorkerClient {
226
235
  * Check if a tool is registered
227
236
  */
228
237
  isToolRegistered(toolName: string): boolean;
238
+ /**
239
+ * Check if the browser supports the WebMCP API (`navigator.modelContext`).
240
+ */
241
+ static isWebMcpSupported(): boolean;
242
+ /**
243
+ * Check if WebMCP is both enabled AND supported.
244
+ */
245
+ isWebMcpAvailable(): boolean;
246
+ /**
247
+ * Enable or disable WebMCP registration at runtime.
248
+ * When enabled and the browser supports it, newly registered tools will also
249
+ * be advertised via `navigator.modelContext`. Existing tools are synced immediately.
250
+ */
251
+ setWebMcpEnabled(enabled: boolean): void;
252
+ /**
253
+ * Check if a specific tool is registered via the WebMCP API.
254
+ */
255
+ isToolRegisteredViaWebMcp(toolName: string): boolean;
256
+ /**
257
+ * Get names of tools registered via the WebMCP API.
258
+ */
259
+ getWebMcpRegisteredTools(): string[];
229
260
  /**
230
261
  * Handle tool call from worker - execute handler in main thread and return result
231
262
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/client/worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,uBAAuB,GAAG;IACpC,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,YAAY;IAEvB,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,YAAY,CAAwC;IAE5D,OAAO,CAAC,yBAAyB,CAA0C;IAC3E,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;IAE/C,OAAO,CAAC,yBAAyB,CACrB;IAGZ,OAAO,CAAC,WAAW,CAA8B;IAGjD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAyB;IAG9C,OAAO,CAAC,YAAY,CAAsB;IAG1C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAmB;;IA+B7D;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAwBxB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAWnB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAOpB;;;OAGG;IACI,QAAQ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oB;IA6BlC;;;;OAIG;IACU,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B3D;;;OAGG;IACI,YAAY,CACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CACR,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,KACrD,IAAI,GACR,MAAM,IAAI;IAIb;;OAEG;IACI,WAAW,CAChB,QAAQ,EAAE,MAAM,GACf;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAIrD;;OAEG;IACI,cAAc,CAAC,QAAQ,EAAE,MAAM,GAClC,CAAC,cAAc,GAAG;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC,GACF,IAAI;IAIR;;OAEG;IACI,kBAAkB,IAAI,MAAM,EAAE;IAIrC;;OAEG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQlD;;OAEG;WACW,iBAAiB,IAAI,OAAO;IAI1C;;OAEG;IACI,iBAAiB,IAAI,OAAO;IAInC;;;;OAIG;IACI,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAgC/C;;OAEG;IACI,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI3D;;OAEG;IACI,wBAAwB,IAAI,MAAM,EAAE;IAI3C;;;OAGG;YACW,cAAc;IAiC5B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAmC3B"}
@@ -64,6 +64,11 @@ export declare class MCPController {
64
64
  private handleRegisterToolInternal;
65
65
  handleToolCallResult(callId: string, result: ToolCallResult): void;
66
66
  handleUnregisterTool(toolName: string, tabId?: string): Promise<boolean>;
67
+ /**
68
+ * Sends AUTH message and waits for AUTH_OK before MCP transport is started.
69
+ * Token is never sent in the URL — only in this initial payload message.
70
+ */
71
+ private performAuthHandshake;
67
72
  getConnectionStatus(): boolean;
68
73
  dispose(): void;
69
74
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-controller.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/worker/mcp-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAc,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAWjD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAGrD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAChD,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAapE;AAED,qBAAa,aAAa;IAmCtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;IAnCrB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,iBAAiB,CAA+C;IACxE,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,sBAAsB,CAAS;IAGvC,OAAO,CAAC,wBAAwB,CAIxB;IAER,OAAO,CAAC,gBAAgB,CAAS;IAGjC,OAAO,CAAC,UAAU,CAAoB;IAGtC,OAAO,CAAC,gBAAgB,CAUpB;gBAGM,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EAChC,WAAW,UAAO;IAOpB;;;OAGG;IACI,iB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