@mcp-b/webmcp-ts-sdk 1.0.2-beta.3 → 2.0.0-beta.20260125195014
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.
- package/dist/index.d.ts +68 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
1
2
|
import { Server, ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
-
import { mergeCapabilities } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
3
|
-
import {
|
|
3
|
+
import { RequestOptions, mergeCapabilities } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
4
|
+
import { ReadBuffer, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
5
|
+
import { CallToolRequest, CallToolRequestSchema, CallToolResult, CallToolResultSchema, ClientCapabilities, ClientNotification, ClientRequest, ClientResult, CreateMessageRequest, CreateMessageRequestSchema, CreateMessageResult, CreateMessageResultSchema, ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResultSchema, ErrorCode, GetPromptRequest, GetPromptRequestSchema, GetPromptResult, GetPromptResultSchema, Implementation, Implementation as Implementation$1, InitializeRequest, InitializeRequestSchema, InitializeResult, InitializeResultSchema, JSONRPCMessage, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, ListPromptsRequest, ListPromptsRequestSchema, ListPromptsResult, ListPromptsResultSchema, ListResourcesRequest, ListResourcesRequestSchema, ListResourcesResult, ListResourcesResultSchema, ListToolsRequest, ListToolsRequestSchema, ListToolsResult, ListToolsResultSchema, LoggingLevel, LoggingLevelSchema, LoggingMessageNotification, McpError, Notification, Prompt, PromptMessage, ReadResourceRequest, ReadResourceRequestSchema, ReadResourceResult, ReadResourceResultSchema, Request, Resource, ResourceContents, ResourceListChangedNotificationSchema, ResourceTemplate, Result, SUPPORTED_PROTOCOL_VERSIONS, ServerCapabilities, ServerNotification, ServerRequest, ServerResult, Tool, ToolAnnotations, ToolListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
4
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
-
import { Transport, Transport as Transport$1 } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
7
|
+
import { Transport, Transport as Transport$1, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
6
8
|
|
|
7
9
|
//#region src/browser-server.d.ts
|
|
8
10
|
|
|
@@ -16,6 +18,7 @@ import { Transport, Transport as Transport$1 } from "@modelcontextprotocol/sdk/s
|
|
|
16
18
|
* Key differences from base McpServer:
|
|
17
19
|
* - Pre-registers tool, resource, and prompt capabilities before connection
|
|
18
20
|
* - Allows items to be registered after transport is connected
|
|
21
|
+
* - Uses no-op JSON Schema validator to avoid ajv errors in browser environments
|
|
19
22
|
* - Designed for browser environments where items arrive asynchronously
|
|
20
23
|
*/
|
|
21
24
|
declare class BrowserMcpServer extends McpServer {
|
|
@@ -30,5 +33,66 @@ declare class BrowserMcpServer extends McpServer {
|
|
|
30
33
|
connect(transport: Transport$1): Promise<void>;
|
|
31
34
|
}
|
|
32
35
|
//#endregion
|
|
33
|
-
|
|
36
|
+
//#region src/no-op-validator.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* No-op JSON Schema validator for browser environments.
|
|
39
|
+
*
|
|
40
|
+
* This validator bypasses the MCP SDK's internal ajv-based validation which causes
|
|
41
|
+
* "Error compiling schema" errors in browser extensions due to ajv's use of
|
|
42
|
+
* eval/Function constructor.
|
|
43
|
+
*
|
|
44
|
+
* Validation is handled externally by Zod in @mcp-b/global, making the SDK's
|
|
45
|
+
* internal validation redundant. This no-op validator allows the SDK to function
|
|
46
|
+
* without the ajv dependency issues.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Interface for JSON Schema validators.
|
|
50
|
+
* This matches the MCP SDK's jsonSchemaValidator interface.
|
|
51
|
+
*/
|
|
52
|
+
interface JsonSchemaValidator {
|
|
53
|
+
getValidator<T>(schema: unknown): (input: unknown) => JsonSchemaValidatorResult<T>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result type for JSON Schema validation
|
|
57
|
+
*/
|
|
58
|
+
type JsonSchemaValidatorResult<T> = {
|
|
59
|
+
valid: true;
|
|
60
|
+
data: T;
|
|
61
|
+
errorMessage: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
valid: false;
|
|
64
|
+
data: undefined;
|
|
65
|
+
errorMessage: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A no-op JSON Schema validator that always returns valid.
|
|
69
|
+
*
|
|
70
|
+
* Use this in browser environments where:
|
|
71
|
+
* - ajv causes "Error compiling schema" errors
|
|
72
|
+
* - Validation is already handled elsewhere (e.g., by Zod)
|
|
73
|
+
* - You need to avoid eval/Function constructor restrictions
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { BrowserMcpServer } from '@mcp-b/webmcp-ts-sdk';
|
|
78
|
+
* import { NoOpJsonSchemaValidator } from '@mcp-b/webmcp-ts-sdk/no-op-validator';
|
|
79
|
+
*
|
|
80
|
+
* const server = new BrowserMcpServer(
|
|
81
|
+
* { name: 'my-server', version: '1.0.0' },
|
|
82
|
+
* { jsonSchemaValidator: new NoOpJsonSchemaValidator() }
|
|
83
|
+
* );
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare class NoOpJsonSchemaValidator implements JsonSchemaValidator {
|
|
87
|
+
/**
|
|
88
|
+
* Returns a validator function that always passes.
|
|
89
|
+
* The input data is passed through unchanged.
|
|
90
|
+
*
|
|
91
|
+
* @param _schema - The JSON Schema (ignored)
|
|
92
|
+
* @returns A validator function that always returns valid
|
|
93
|
+
*/
|
|
94
|
+
getValidator<T>(_schema: unknown): (input: unknown) => JsonSchemaValidatorResult<T>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { BrowserMcpServer, BrowserMcpServer as McpServer, type CallToolRequest, CallToolRequestSchema, type CallToolResult, CallToolResultSchema, Client, type ClientCapabilities, type ClientNotification, type ClientRequest, type ClientResult, type CreateMessageRequest, CreateMessageRequestSchema, type CreateMessageResult, CreateMessageResultSchema, type ElicitRequest, ElicitRequestSchema, type ElicitResult, ElicitResultSchema, ErrorCode, type GetPromptRequest, GetPromptRequestSchema, type GetPromptResult, GetPromptResultSchema, type Implementation, type InitializeRequest, InitializeRequestSchema, type InitializeResult, InitializeResultSchema, type JSONRPCMessage, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, type ListPromptsRequest, ListPromptsRequestSchema, type ListPromptsResult, ListPromptsResultSchema, type ListResourcesRequest, ListResourcesRequestSchema, type ListResourcesResult, ListResourcesResultSchema, type ListToolsRequest, ListToolsRequestSchema, type ListToolsResult, ListToolsResultSchema, type LoggingLevel, LoggingLevelSchema, type LoggingMessageNotification, type McpError, NoOpJsonSchemaValidator, type Notification, type Prompt, type PromptMessage, ReadBuffer, type ReadResourceRequest, ReadResourceRequestSchema, type ReadResourceResult, ReadResourceResultSchema, type Request, type RequestOptions, type Resource, type ResourceContents, ResourceListChangedNotificationSchema, type ResourceTemplate, type Result, SUPPORTED_PROTOCOL_VERSIONS, Server, type ServerCapabilities, type ServerNotification, type ServerRequest, type ServerResult, type Tool, type ToolAnnotations, ToolListChangedNotificationSchema, type Transport, type TransportSendOptions, mergeCapabilities, serializeMessage };
|
|
34
98
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/browser-server.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/browser-server.ts","../src/no-op-validator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAoBA;;;;;;;;cAAa,gBAAA,SAAyB,SAAA;0BACZ,4BAA0B;ECL1C;AACuE;AA6BjF;;;;;qBDDoC,cAAY;;;;;;;;;;;;;AAzBhD;;;;;;UCJU,mBAAA,CDIyC;wDCHK,0BAA0B;;;;AAAD;AA6BjF,KAvBK,yBAuBgC,CAAA,CAAA,CAAA,GAAA;EAQ8C,KAAA,EAAA,IAAA;EAA1B,IAAA,EA9BhC,CA8BgC;EART,YAAA,EAAA,SAAA;CAAmB,GAAA;;;;;;;;;;;;;;;;;;;;;;;;cAAtD,uBAAA,YAAmC;;;;;;;;yDAQS,0BAA0B"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
1
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
3
|
import { mergeCapabilities, mergeCapabilities as mergeCapabilities$1 } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
3
|
-
import {
|
|
4
|
+
import { ReadBuffer, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
5
|
+
import { CallToolRequestSchema, CallToolResultSchema, CreateMessageRequestSchema, CreateMessageResultSchema, ElicitRequestSchema, ElicitResultSchema, ErrorCode, GetPromptRequestSchema, GetPromptResultSchema, InitializeRequestSchema, InitializeResultSchema, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, ListPromptsRequestSchema, ListPromptsResultSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListToolsRequestSchema, ListToolsResultSchema, LoggingLevelSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SUPPORTED_PROTOCOL_VERSIONS, ToolListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
4
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
7
|
|
|
8
|
+
//#region src/no-op-validator.ts
|
|
9
|
+
/**
|
|
10
|
+
* A no-op JSON Schema validator that always returns valid.
|
|
11
|
+
*
|
|
12
|
+
* Use this in browser environments where:
|
|
13
|
+
* - ajv causes "Error compiling schema" errors
|
|
14
|
+
* - Validation is already handled elsewhere (e.g., by Zod)
|
|
15
|
+
* - You need to avoid eval/Function constructor restrictions
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { BrowserMcpServer } from '@mcp-b/webmcp-ts-sdk';
|
|
20
|
+
* import { NoOpJsonSchemaValidator } from '@mcp-b/webmcp-ts-sdk/no-op-validator';
|
|
21
|
+
*
|
|
22
|
+
* const server = new BrowserMcpServer(
|
|
23
|
+
* { name: 'my-server', version: '1.0.0' },
|
|
24
|
+
* { jsonSchemaValidator: new NoOpJsonSchemaValidator() }
|
|
25
|
+
* );
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
var NoOpJsonSchemaValidator = class {
|
|
29
|
+
/**
|
|
30
|
+
* Returns a validator function that always passes.
|
|
31
|
+
* The input data is passed through unchanged.
|
|
32
|
+
*
|
|
33
|
+
* @param _schema - The JSON Schema (ignored)
|
|
34
|
+
* @returns A validator function that always returns valid
|
|
35
|
+
*/
|
|
36
|
+
getValidator(_schema) {
|
|
37
|
+
return (input) => ({
|
|
38
|
+
valid: true,
|
|
39
|
+
data: input,
|
|
40
|
+
errorMessage: void 0
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
6
46
|
//#region src/browser-server.ts
|
|
7
47
|
/**
|
|
8
48
|
* Browser-optimized MCP Server for Web Model Context API (navigator.modelContext).
|
|
@@ -14,6 +54,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
14
54
|
* Key differences from base McpServer:
|
|
15
55
|
* - Pre-registers tool, resource, and prompt capabilities before connection
|
|
16
56
|
* - Allows items to be registered after transport is connected
|
|
57
|
+
* - Uses no-op JSON Schema validator to avoid ajv errors in browser environments
|
|
17
58
|
* - Designed for browser environments where items arrive asynchronously
|
|
18
59
|
*/
|
|
19
60
|
var BrowserMcpServer = class extends McpServer {
|
|
@@ -24,7 +65,8 @@ var BrowserMcpServer = class extends McpServer {
|
|
|
24
65
|
tools: { listChanged: true },
|
|
25
66
|
resources: { listChanged: true },
|
|
26
67
|
prompts: { listChanged: true }
|
|
27
|
-
})
|
|
68
|
+
}),
|
|
69
|
+
jsonSchemaValidator: options?.jsonSchemaValidator ?? new NoOpJsonSchemaValidator()
|
|
28
70
|
};
|
|
29
71
|
super(serverInfo, enhancedOptions);
|
|
30
72
|
}
|
|
@@ -42,5 +84,5 @@ var BrowserMcpServer = class extends McpServer {
|
|
|
42
84
|
};
|
|
43
85
|
|
|
44
86
|
//#endregion
|
|
45
|
-
export { BrowserMcpServer, BrowserMcpServer as McpServer, CallToolRequestSchema, CallToolResultSchema, CreateMessageRequestSchema, CreateMessageResultSchema, ElicitRequestSchema, ElicitResultSchema, ErrorCode, GetPromptRequestSchema, GetPromptResultSchema, InitializeRequestSchema, InitializeResultSchema, LATEST_PROTOCOL_VERSION, ListPromptsRequestSchema, ListPromptsResultSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListToolsRequestSchema, ListToolsResultSchema, LoggingLevelSchema, ReadResourceRequestSchema, ReadResourceResultSchema, SUPPORTED_PROTOCOL_VERSIONS, Server, mergeCapabilities };
|
|
87
|
+
export { BrowserMcpServer, BrowserMcpServer as McpServer, CallToolRequestSchema, CallToolResultSchema, Client, CreateMessageRequestSchema, CreateMessageResultSchema, ElicitRequestSchema, ElicitResultSchema, ErrorCode, GetPromptRequestSchema, GetPromptResultSchema, InitializeRequestSchema, InitializeResultSchema, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, ListPromptsRequestSchema, ListPromptsResultSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListToolsRequestSchema, ListToolsResultSchema, LoggingLevelSchema, NoOpJsonSchemaValidator, ReadBuffer, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SUPPORTED_PROTOCOL_VERSIONS, Server, ToolListChangedNotificationSchema, mergeCapabilities, serializeMessage };
|
|
46
88
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["BaseMcpServer","enhancedOptions: ServerOptions","mergeCapabilities"],"sources":["../src/browser-server.ts"],"sourcesContent":["import type { ServerOptions } from '@modelcontextprotocol/sdk/server/index.js';\nimport { McpServer as BaseMcpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mergeCapabilities } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nimport type { Implementation } from '@modelcontextprotocol/sdk/types.js';\n\n/**\n * Browser-optimized MCP Server for Web Model Context API (navigator.modelContext).\n *\n * This class extends McpServer to support dynamic registration of tools, resources,\n * and prompts after transport connection, which is required for the Web Model Context API\n * where items are registered via navigator.modelContext.provideContext() at any time.\n *\n * Key differences from base McpServer:\n * - Pre-registers tool, resource, and prompt capabilities before connection\n * - Allows items to be registered after transport is connected\n * - Designed for browser environments where items arrive asynchronously\n */\nexport class BrowserMcpServer extends BaseMcpServer {\n constructor(serverInfo: Implementation, options?: ServerOptions) {\n // Ensure tools, resources, and prompts capabilities are registered from the start\n const enhancedOptions: ServerOptions = {\n ...options,\n capabilities: mergeCapabilities(options?.capabilities || {}, {\n tools: { listChanged: true },\n resources: { listChanged: true },\n prompts: { listChanged: true },\n }),\n };\n\n super(serverInfo, enhancedOptions);\n }\n\n /**\n * Override connect to ensure request handlers are initialized\n * BEFORE the transport connection is established.\n *\n * This prevents the \"Cannot register capabilities after connecting to transport\"\n * error when items are registered dynamically after connection.\n */\n override async connect(transport: Transport): Promise<void> {\n // Call setToolRequestHandlers() BEFORE connecting the transport\n // This will:\n // 1. Register tool capabilities (won't throw since transport isn't connected yet)\n // 2. Set up ListTools and CallTool request handlers\n // 3. Set _toolHandlersInitialized = true\n //\n // After this, any future registerTool() calls will skip registerCapabilities()\n // because _toolHandlersInitialized is true, allowing dynamic tool registration\n\n // Type-safe access to private method - we need to call this internal method\n // to initialize tool handlers before connecting\n (this as unknown as { setToolRequestHandlers: () => void }).setToolRequestHandlers();\n\n // Now connect with the transport\n return super.connect(transport);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["BaseMcpServer","enhancedOptions: ServerOptions","mergeCapabilities"],"sources":["../src/no-op-validator.ts","../src/browser-server.ts"],"sourcesContent":["/**\n * No-op JSON Schema validator for browser environments.\n *\n * This validator bypasses the MCP SDK's internal ajv-based validation which causes\n * \"Error compiling schema\" errors in browser extensions due to ajv's use of\n * eval/Function constructor.\n *\n * Validation is handled externally by Zod in @mcp-b/global, making the SDK's\n * internal validation redundant. This no-op validator allows the SDK to function\n * without the ajv dependency issues.\n */\n\n/**\n * Interface for JSON Schema validators.\n * This matches the MCP SDK's jsonSchemaValidator interface.\n */\ninterface JsonSchemaValidator {\n getValidator<T>(schema: unknown): (input: unknown) => JsonSchemaValidatorResult<T>;\n}\n\n/**\n * Result type for JSON Schema validation\n */\ntype JsonSchemaValidatorResult<T> =\n | { valid: true; data: T; errorMessage: undefined }\n | { valid: false; data: undefined; errorMessage: string };\n\n/**\n * A no-op JSON Schema validator that always returns valid.\n *\n * Use this in browser environments where:\n * - ajv causes \"Error compiling schema\" errors\n * - Validation is already handled elsewhere (e.g., by Zod)\n * - You need to avoid eval/Function constructor restrictions\n *\n * @example\n * ```typescript\n * import { BrowserMcpServer } from '@mcp-b/webmcp-ts-sdk';\n * import { NoOpJsonSchemaValidator } from '@mcp-b/webmcp-ts-sdk/no-op-validator';\n *\n * const server = new BrowserMcpServer(\n * { name: 'my-server', version: '1.0.0' },\n * { jsonSchemaValidator: new NoOpJsonSchemaValidator() }\n * );\n * ```\n */\nexport class NoOpJsonSchemaValidator implements JsonSchemaValidator {\n /**\n * Returns a validator function that always passes.\n * The input data is passed through unchanged.\n *\n * @param _schema - The JSON Schema (ignored)\n * @returns A validator function that always returns valid\n */\n getValidator<T>(_schema: unknown): (input: unknown) => JsonSchemaValidatorResult<T> {\n return (input: unknown): JsonSchemaValidatorResult<T> => ({\n valid: true,\n data: input as T,\n errorMessage: undefined,\n });\n }\n}\n","import type { ServerOptions } from '@modelcontextprotocol/sdk/server/index.js';\nimport { McpServer as BaseMcpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mergeCapabilities } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nimport type { Implementation } from '@modelcontextprotocol/sdk/types.js';\nimport { NoOpJsonSchemaValidator } from './no-op-validator.js';\n\n/**\n * Browser-optimized MCP Server for Web Model Context API (navigator.modelContext).\n *\n * This class extends McpServer to support dynamic registration of tools, resources,\n * and prompts after transport connection, which is required for the Web Model Context API\n * where items are registered via navigator.modelContext.provideContext() at any time.\n *\n * Key differences from base McpServer:\n * - Pre-registers tool, resource, and prompt capabilities before connection\n * - Allows items to be registered after transport is connected\n * - Uses no-op JSON Schema validator to avoid ajv errors in browser environments\n * - Designed for browser environments where items arrive asynchronously\n */\nexport class BrowserMcpServer extends BaseMcpServer {\n constructor(serverInfo: Implementation, options?: ServerOptions) {\n // Ensure tools, resources, and prompts capabilities are registered from the start\n // Use NoOpJsonSchemaValidator by default to avoid ajv \"Error compiling schema\" errors\n // in browser environments. Validation is handled by Zod in @mcp-b/global.\n const enhancedOptions: ServerOptions = {\n ...options,\n capabilities: mergeCapabilities(options?.capabilities || {}, {\n tools: { listChanged: true },\n resources: { listChanged: true },\n prompts: { listChanged: true },\n }),\n jsonSchemaValidator: options?.jsonSchemaValidator ?? new NoOpJsonSchemaValidator(),\n };\n\n super(serverInfo, enhancedOptions);\n }\n\n /**\n * Override connect to ensure request handlers are initialized\n * BEFORE the transport connection is established.\n *\n * This prevents the \"Cannot register capabilities after connecting to transport\"\n * error when items are registered dynamically after connection.\n */\n override async connect(transport: Transport): Promise<void> {\n // Call setToolRequestHandlers() BEFORE connecting the transport\n // This will:\n // 1. Register tool capabilities (won't throw since transport isn't connected yet)\n // 2. Set up ListTools and CallTool request handlers\n // 3. Set _toolHandlersInitialized = true\n //\n // After this, any future registerTool() calls will skip registerCapabilities()\n // because _toolHandlersInitialized is true, allowing dynamic tool registration\n\n // Type-safe access to private method - we need to call this internal method\n // to initialize tool handlers before connecting\n (this as unknown as { setToolRequestHandlers: () => void }).setToolRequestHandlers();\n\n // Now connect with the transport\n return super.connect(transport);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,0BAAb,MAAoE;;;;;;;;CAQlE,aAAgB,SAAoE;AAClF,UAAQ,WAAkD;GACxD,OAAO;GACP,MAAM;GACN,cAAc;GACf;;;;;;;;;;;;;;;;;;;ACvCL,IAAa,mBAAb,cAAsCA,UAAc;CAClD,YAAY,YAA4B,SAAyB;EAI/D,MAAMC,kBAAiC;GACrC,GAAG;GACH,cAAcC,oBAAkB,SAAS,gBAAgB,EAAE,EAAE;IAC3D,OAAO,EAAE,aAAa,MAAM;IAC5B,WAAW,EAAE,aAAa,MAAM;IAChC,SAAS,EAAE,aAAa,MAAM;IAC/B,CAAC;GACF,qBAAqB,SAAS,uBAAuB,IAAI,yBAAyB;GACnF;AAED,QAAM,YAAY,gBAAgB;;;;;;;;;CAUpC,MAAe,QAAQ,WAAqC;AAY1D,EAAC,KAA2D,wBAAwB;AAGpF,SAAO,MAAM,QAAQ,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/webmcp-ts-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.20260125195014",
|
|
4
4
|
"description": "Browser-adapted MCP TypeScript SDK - Dynamic tool registration for W3C Web Model Context API and AI agent integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "git+https://github.com/WebMCP-org/npm-packages.git",
|
|
38
|
-
"directory": "webmcp-ts-sdk"
|
|
38
|
+
"directory": "packages/webmcp-ts-sdk"
|
|
39
39
|
},
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"author": "Alex Nahas",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dist"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@modelcontextprotocol/sdk": "1.
|
|
56
|
+
"@modelcontextprotocol/sdk": "1.25.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "22.17.2",
|