@mcp-fe/mcp-worker 0.1.10 → 0.2.0

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.
@@ -20933,6 +20933,14 @@ function createMCPServer(options = {}) {
20933
20933
  );
20934
20934
  return server;
20935
20935
  }
20936
+ function notifyToolsChanged(server) {
20937
+ try {
20938
+ server.notification({
20939
+ method: "notifications/tools/list_changed"
20940
+ });
20941
+ } catch {
20942
+ }
20943
+ }
20936
20944
  var mcpServer = createMCPServer();
20937
20945
 
20938
20946
  // libs/mcp-worker/src/worker/websocket-transport.ts
@@ -21579,6 +21587,7 @@ var MCPController = class _MCPController {
21579
21587
  logger.log(
21580
21588
  `[MCPController] Registered proxy tool: ${name} with smart multi-tab routing`
21581
21589
  );
21590
+ notifyToolsChanged(mcpServer);
21582
21591
  }
21583
21592
  }
21584
21593
  handleToolCallResult(callId, result) {
@@ -21652,6 +21661,7 @@ var MCPController = class _MCPController {
21652
21661
  logger.log(
21653
21662
  `[MCPController] Unregistered tool from MCP: ${toolName} (no tabs remaining)`
21654
21663
  );
21664
+ notifyToolsChanged(mcpServer);
21655
21665
  }
21656
21666
  return success2;
21657
21667
  }
@@ -20933,6 +20933,14 @@ function createMCPServer(options = {}) {
20933
20933
  );
20934
20934
  return server;
20935
20935
  }
20936
+ function notifyToolsChanged(server) {
20937
+ try {
20938
+ server.notification({
20939
+ method: "notifications/tools/list_changed"
20940
+ });
20941
+ } catch {
20942
+ }
20943
+ }
20936
20944
  var mcpServer = createMCPServer();
20937
20945
 
20938
20946
  // libs/mcp-worker/src/worker/websocket-transport.ts
@@ -21579,6 +21587,7 @@ var MCPController = class _MCPController {
21579
21587
  logger.log(
21580
21588
  `[MCPController] Registered proxy tool: ${name} with smart multi-tab routing`
21581
21589
  );
21590
+ notifyToolsChanged(mcpServer);
21582
21591
  }
21583
21592
  }
21584
21593
  handleToolCallResult(callId, result) {
@@ -21652,6 +21661,7 @@ var MCPController = class _MCPController {
21652
21661
  logger.log(
21653
21662
  `[MCPController] Unregistered tool from MCP: ${toolName} (no tabs remaining)`
21654
21663
  );
21664
+ notifyToolsChanged(mcpServer);
21655
21665
  }
21656
21666
  return success2;
21657
21667
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-fe/mcp-worker",
3
- "version": "0.1.10",
3
+ "version": "0.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://mcp-fe.ai",
6
6
  "repository": {
@@ -3,6 +3,8 @@
3
3
  * Use this in your application code
4
4
  */
5
5
  export { WorkerClient, type WorkerClientInitOptions } from './worker-client';
6
+ export { WebMcpAdapter } from './web-mcp-adapter';
7
+ export type { ModelContext, ModelContextTool, ModelContextOptions, ModelContextClient, ToolExecuteCallback, UserInteractionCallback, WebMcpToolAnnotations, } from './web-mcp-types';
6
8
  export type { ToolHandler, ToolDefinition, Icon, ToolAnnotations, ToolExecution, UserEvent, EventFilters, TabInfo, } from '../shared/types';
7
9
  export { logger } from '../shared/logger';
8
10
  import { WorkerClient } from './worker-client';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,YAAY,EACV,WAAW,EACX,cAAc,EACd,IAAI,EACJ,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,eAAO,MAAM,YAAY,cAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,WAAW,EACX,cAAc,EACd,IAAI,EACJ,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * ToolRegistry — manages registration, reference counting, and lifecycle of MCP tools.
3
+ *
4
+ * Responsibilities:
5
+ * - Track registered tools with reference counting for proper cleanup
6
+ * - Store tool handlers (functions that execute in main thread)
7
+ * - Manage tool change subscriptions for reactive updates
8
+ * - Provide query methods for tool state
9
+ *
10
+ * Public API:
11
+ * - register(tool, handler): Register a tool and increment ref count
12
+ * - unregister(name): Decrement ref count and optionally remove tool
13
+ * - getHandler(name): Get tool handler function
14
+ * - getInfo(name): Get tool metadata (refCount, isRegistered)
15
+ * - getDetails(name): Get full tool definition
16
+ * - getRegisteredTools(): Get list of all registered tool names
17
+ * - isRegistered(name): Check if tool is registered
18
+ * - onToolChange(name, callback): Subscribe to tool changes
19
+ */
20
+ import type { ToolDefinition } from '../shared/types';
21
+ export type ToolHandler = (args: unknown) => Promise<{
22
+ content: Array<{
23
+ type: string;
24
+ text: string;
25
+ }>;
26
+ }>;
27
+ export type ToolOptions = {
28
+ outputSchema?: Record<string, unknown>;
29
+ annotations?: {
30
+ title?: string;
31
+ readOnlyHint?: boolean;
32
+ destructiveHint?: boolean;
33
+ idempotentHint?: boolean;
34
+ openWorldHint?: boolean;
35
+ };
36
+ execution?: {
37
+ taskSupport?: 'optional' | 'required' | 'forbidden';
38
+ };
39
+ _meta?: Record<string, unknown>;
40
+ icons?: Array<{
41
+ src: string;
42
+ mimeType?: string;
43
+ sizes?: string[];
44
+ theme?: 'light' | 'dark';
45
+ }>;
46
+ title?: string;
47
+ };
48
+ export type ToolInfo = {
49
+ refCount: number;
50
+ isRegistered: boolean;
51
+ };
52
+ export type ToolDetails = ToolDefinition & {
53
+ refCount: number;
54
+ isRegistered: boolean;
55
+ };
56
+ export declare class ToolRegistry {
57
+ private toolHandlers;
58
+ private toolRegistry;
59
+ private toolChangeListeners;
60
+ /**
61
+ * Register a tool with handler (or increment ref count if already exists)
62
+ *
63
+ * @param name - Tool name
64
+ * @param description - Tool description
65
+ * @param inputSchema - JSON Schema for tool inputs
66
+ * @param handler - Async function that handles the tool execution
67
+ * @param options - Additional tool options
68
+ * @returns true if newly registered, false if ref count incremented
69
+ */
70
+ register(name: string, description: string | undefined, inputSchema: Record<string, unknown>, handler: ToolHandler, options?: ToolOptions): boolean;
71
+ /**
72
+ * Unregister a tool (decrement ref count, remove if count reaches 0)
73
+ *
74
+ * @param name - Tool name to unregister
75
+ * @returns true if tool was removed (ref count reached 0), false if ref count decremented, null if not found
76
+ */
77
+ unregister(name: string): boolean | null;
78
+ /**
79
+ * Get tool handler function
80
+ */
81
+ getHandler(name: string): ToolHandler | undefined;
82
+ /**
83
+ * Get tool info (ref count and registration status)
84
+ */
85
+ getInfo(name: string): ToolInfo | null;
86
+ /**
87
+ * Get complete tool details
88
+ */
89
+ getDetails(name: string): ToolDetails | null;
90
+ /**
91
+ * Get all registered tool names
92
+ */
93
+ getRegisteredTools(): string[];
94
+ /**
95
+ * Check if a tool is registered
96
+ */
97
+ isRegistered(name: string): boolean;
98
+ /**
99
+ * Subscribe to tool changes for a specific tool
100
+ * Returns unsubscribe function
101
+ */
102
+ onToolChange(toolName: string, callback: (info: ToolInfo | null) => void): () => void;
103
+ /**
104
+ * Notify all listeners about tool changes
105
+ * @private
106
+ */
107
+ private notifyToolChange;
108
+ /**
109
+ * Clear all tools (useful for cleanup/testing)
110
+ */
111
+ clear(): void;
112
+ /**
113
+ * Get all tool names (including those with refCount > 0)
114
+ */
115
+ getAllToolNames(): string[];
116
+ }
117
+ //# sourceMappingURL=tool-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/client/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,SAAS,CAAC,EAAE;QACV,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;KACrD,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC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AAI;IAmCb;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;OAEG;IACI,KAAK,IAAI,IAAI;IAOpB;;OAEG;IACI,eAAe,IAAI,MAAM,EAAE;CAGnC"}
@@ -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,"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AI,EAAE,MAAM,GAAG,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"}
@@ -37,6 +37,7 @@
37
37
  *
38
38
  */
39
39
  import type { ToolDefinition } from '../shared/types';
40
+ import { type ToolHandler, type ToolOptions } from './tool-registry';
40
41
  export type WorkerClientInitOptions = {
41
42
  /** URL to the SharedWorker script (optional) */
42
43
  sharedWorkerUrl?: string;
@@ -44,6 +45,14 @@ export type WorkerClientInitOptions = {
44
45
  serviceWorkerUrl?: string;
45
46
  /** Backend WebSocket URL to configure inside the worker (optional) */
46
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;
47
56
  };
48
57
  export declare class WorkerClient {
49
58
  private sharedWorkerUrl;
@@ -58,10 +67,8 @@ export declare class WorkerClient {
58
67
  private initPromise;
59
68
  private isInitialized;
60
69
  private initResolvers;
61
- private pendingRegistrations;
62
- private toolHandlers;
63
70
  private toolRegistry;
64
- private toolChangeListeners;
71
+ private webMcpAdapter;
65
72
  private tabId;
66
73
  private static readonly TAB_ID_STORAGE_KEY;
67
74
  constructor();
@@ -106,10 +113,15 @@ export declare class WorkerClient {
106
113
  private cleanupAllTools;
107
114
  init(registrationOrOptions?: ServiceWorkerRegistration | WorkerClientInitOptions): Promise<void>;
108
115
  /**
109
- * Mark worker as initialized and process pending registrations
116
+ * Mark worker as initialized and sync all registered tools to worker
110
117
  * @private
111
118
  */
112
119
  private markAsInitialized;
120
+ /**
121
+ * Synchronize all locally registered tools to worker
122
+ * @private
123
+ */
124
+ private syncToolsToWorker;
113
125
  /**
114
126
  * Wait for worker initialization
115
127
  * @returns Promise that resolves when worker is initialized
@@ -176,42 +188,17 @@ export declare class WorkerClient {
176
188
  * );
177
189
  * ```
178
190
  */
179
- registerTool(name: string, description: string | undefined, inputSchema: Record<string, unknown>, handler: (args: unknown) => Promise<{
180
- content: Array<{
181
- type: string;
182
- text: string;
183
- }>;
184
- }>, options?: {
185
- outputSchema?: Record<string, unknown>;
186
- annotations?: {
187
- title?: string;
188
- readOnlyHint?: boolean;
189
- destructiveHint?: boolean;
190
- idempotentHint?: boolean;
191
- openWorldHint?: boolean;
192
- };
193
- execution?: {
194
- taskSupport?: 'optional' | 'required' | 'forbidden';
195
- };
196
- _meta?: Record<string, unknown>;
197
- icons?: Array<{
198
- src: string;
199
- mimeType?: string;
200
- sizes?: string[];
201
- theme?: 'light' | 'dark';
202
- }>;
203
- title?: string;
204
- }): Promise<void>;
191
+ registerTool(name: string, description: string | undefined, inputSchema: Record<string, unknown>, handler: ToolHandler, options?: ToolOptions): Promise<void>;
205
192
  /**
206
193
  * Enhance tool input schema with optional tabId parameter for multi-tab support
207
194
  * @private
208
195
  */
209
196
  private enhanceSchemaWithTabId;
210
197
  /**
211
- * Internal method to register tool (assumes worker is initialized)
198
+ * Register tool in worker only (assumes already registered in ToolRegistry)
212
199
  * @private
213
200
  */
214
- private registerToolInternal;
201
+ private registerToolInWorker;
215
202
  /**
216
203
  * Unregister a previously registered MCP tool
217
204
  * @param name - Tool name to unregister
@@ -226,11 +213,6 @@ export declare class WorkerClient {
226
213
  refCount: number;
227
214
  isRegistered: boolean;
228
215
  } | null) => void): () => void;
229
- /**
230
- * Notify all listeners about tool changes
231
- * @private
232
- */
233
- private notifyToolChange;
234
216
  /**
235
217
  * Get tool info from registry
236
218
  */
@@ -253,6 +235,28 @@ export declare class WorkerClient {
253
235
  * Check if a tool is registered
254
236
  */
255
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[];
256
260
  /**
257
261
  * Handle tool call from worker - execute handler in main thread and return result
258
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;AAKtD,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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AAC,GAChC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;OAGG;YACW,0BAA0B;IAsJjC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IAyD5D,oBAAoB,CAC/B,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;IA6CZ,mBAAmB,IAAI,OAAO;IAI9B,OAAO,IAAI,IAAI;IAYtB;;;OAGG;WACW,MAAM,CAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EACxB,WAAW,UAAO,GACjB,aAAa;CAGjB"}
@@ -14,6 +14,11 @@ export interface MCPServerOptions {
14
14
  * @returns Configured MCP Server instance
15
15
  */
16
16
  export declare function createMCPServer(options?: MCPServerOptions): Server;
17
+ /**
18
+ * Send tools/list_changed notification to MCP client
19
+ * Call this whenever tools are added or removed from the registry
20
+ */
21
+ export declare function notifyToolsChanged(server: Server): void;
17
22
  export declare const mcpServer: Server<{
18
23
  method: string;
19
24
  params?: {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/worker/mcp-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAgDtE;AAGD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAoB,CAAC"}
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../../../libs/mcp-worker/src/worker/mcp-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAgDtE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAQvD;AAGD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAoB,CAAC"}