@mcp-b/webmcp-ts-sdk 1.0.2-beta.1 → 1.0.2-beta.3

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.
Files changed (2) hide show
  1. package/README.md +71 -5
  2. package/package.json +24 -9
package/README.md CHANGED
@@ -1,13 +1,30 @@
1
1
  # @mcp-b/webmcp-ts-sdk
2
2
 
3
- > Browser-adapted Model Context Protocol TypeScript SDK
3
+ > Browser-adapted MCP TypeScript SDK - Dynamic tool registration for AI agents like Claude, ChatGPT, and Gemini
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@mcp-b/webmcp-ts-sdk?style=flat-square)](https://www.npmjs.com/package/@mcp-b/webmcp-ts-sdk)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@mcp-b/webmcp-ts-sdk?style=flat-square)](https://www.npmjs.com/package/@mcp-b/webmcp-ts-sdk)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?style=flat-square)](https://www.typescriptlang.org/)
9
+ [![Minimal Code](https://img.shields.io/badge/Custom_Code-~50_lines-green?style=flat-square)](https://github.com/WebMCP-org/npm-packages)
10
+
11
+ 📖 **[Full Documentation](https://docs.mcp-b.ai/packages/webmcp-ts-sdk)** | 🚀 **[Quick Start](https://docs.mcp-b.ai/quickstart)**
12
+
13
+ **@mcp-b/webmcp-ts-sdk** adapts the official MCP TypeScript SDK for browser environments, enabling dynamic tool registration required by the W3C Web Model Context API. This allows AI agents like Claude, ChatGPT, Gemini, Cursor, and Copilot to interact with browser-based applications.
14
+
15
+ ## Why Use @mcp-b/webmcp-ts-sdk?
16
+
17
+ | Feature | Benefit |
18
+ |---------|---------|
19
+ | **Dynamic Tool Registration** | Register tools after transport connection - required for browser apps |
20
+ | **Minimal Overhead** | Only ~50 lines of custom code on top of official SDK |
21
+ | **Full SDK Compatibility** | Re-exports all types, classes, and utilities from official SDK |
22
+ | **Type-Safe** | No prototype hacks - clean TypeScript extension |
23
+ | **Auto-Updates** | Types and protocol follow official SDK automatically |
7
24
 
8
25
  ## Overview
9
26
 
10
- This package adapts the official [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) for browser environments with modifications to support dynamic tool registration required by the [W3C Web Model Context API](https://github.com/webmachinelearning/webmcp) (`window.navigator.modelContext`).
27
+ This package adapts the official [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) for browser environments with modifications to support dynamic tool registration required by the [W3C Web Model Context API](https://github.com/nicolo-ribaudo/model-context-protocol-api) (`window.navigator.modelContext`).
11
28
 
12
29
  ## Why This Package Exists
13
30
 
@@ -107,13 +124,39 @@ await server.connect(transport);
107
124
  server.registerTool('my-tool', {
108
125
  description: 'A dynamically registered tool',
109
126
  inputSchema: { message: z.string() },
127
+ // Output schemas enable structured, type-safe AI responses
110
128
  outputSchema: { result: z.string() }
111
129
  }, async ({ message }) => {
112
130
  return {
113
131
  content: [{ type: 'text', text: `Echo: ${message}` }],
132
+ // structuredContent must match the outputSchema
114
133
  structuredContent: { result: `Echo: ${message}` }
115
134
  };
116
135
  });
136
+
137
+ // Example with complex output schema
138
+ server.registerTool('analyze-data', {
139
+ description: 'Analyze data and return structured results',
140
+ inputSchema: {
141
+ data: z.array(z.number()),
142
+ operation: z.enum(['sum', 'average', 'stats'])
143
+ },
144
+ outputSchema: {
145
+ result: z.number(),
146
+ operation: z.string(),
147
+ metadata: z.object({
148
+ count: z.number(),
149
+ min: z.number().optional(),
150
+ max: z.number().optional()
151
+ })
152
+ }
153
+ }, async ({ data, operation }) => {
154
+ const stats = calculateStats(data, operation);
155
+ return {
156
+ content: [{ type: 'text', text: `Result: ${stats.result}` }],
157
+ structuredContent: stats
158
+ };
159
+ });
117
160
  ```
118
161
 
119
162
  ## Architecture
@@ -158,17 +201,39 @@ When the official SDK updates:
158
201
 
159
202
  The modification is minimal and unlikely to conflict with upstream changes.
160
203
 
204
+ ## Frequently Asked Questions
205
+
206
+ ### Why can't I use the official SDK directly?
207
+
208
+ The official SDK throws an error if you try to register tools after connecting a transport. Browsers need dynamic registration because tools arrive asynchronously as the page loads.
209
+
210
+ ### Is this a fork of the official SDK?
211
+
212
+ No - it's a thin adapter (~50 lines) that extends the official SDK. All types, protocol handling, and validation come from the upstream package.
213
+
214
+ ### Will this break when the official SDK updates?
215
+
216
+ Unlikely. The modification is minimal and isolated. When upstream updates, just update your dependencies - the wrapper adapts automatically.
217
+
218
+ ### When should I use this vs `@mcp-b/global`?
219
+
220
+ Use `@mcp-b/global` for the standard `navigator.modelContext` API. Use this package directly only if you need low-level control over the MCP server.
221
+
161
222
  ## Related Packages
162
223
 
163
- - [`@mcp-b/global`](../global) - W3C Web Model Context API implementation (uses this package)
164
- - [`@mcp-b/transports`](../transports) - Browser-specific MCP transports
224
+ - [`@mcp-b/global`](https://docs.mcp-b.ai/packages/global) - W3C Web Model Context API polyfill (uses this package internally)
225
+ - [`@mcp-b/transports`](https://docs.mcp-b.ai/packages/transports) - Browser-specific MCP transports
226
+ - [`@mcp-b/react-webmcp`](https://docs.mcp-b.ai/packages/react-webmcp) - React hooks for MCP
227
+ - [`@mcp-b/chrome-devtools-mcp`](https://docs.mcp-b.ai/packages/chrome-devtools-mcp) - Connect desktop AI agents to browser tools
165
228
  - [`@modelcontextprotocol/sdk`](https://www.npmjs.com/package/@modelcontextprotocol/sdk) - Official MCP SDK
166
229
 
167
230
  ## Resources
168
231
 
169
- - [Web Model Context API Explainer](https://github.com/webmachinelearning/webmcp)
232
+ - [WebMCP Documentation](https://docs.mcp-b.ai)
233
+ - [Web Model Context API Explainer](https://github.com/nicolo-ribaudo/model-context-protocol-api)
170
234
  - [Model Context Protocol Spec](https://modelcontextprotocol.io/)
171
235
  - [Official MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
236
+ - [MCP GitHub Repository](https://github.com/modelcontextprotocol)
172
237
 
173
238
  ## License
174
239
 
@@ -178,3 +243,4 @@ MIT - see [LICENSE](../../LICENSE) for details
178
243
 
179
244
  - [GitHub Issues](https://github.com/WebMCP-org/npm-packages/issues)
180
245
  - [Documentation](https://docs.mcp-b.ai)
246
+ - [Discord Community](https://discord.gg/a9fBR6Bw)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mcp-b/webmcp-ts-sdk",
3
- "version": "1.0.2-beta.1",
4
- "description": "TypeScript SDK adapter for Model Context Protocol with dynamic tool registration support for browsers",
3
+ "version": "1.0.2-beta.3",
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",
7
7
  "model-context-protocol",
@@ -10,17 +10,32 @@
10
10
  "sdk",
11
11
  "adapter",
12
12
  "web-model-context",
13
- "navigator.modelContext",
14
- "w3c"
13
+ "navigator-modelcontext",
14
+ "w3c",
15
+ "ai-agents",
16
+ "llm",
17
+ "claude",
18
+ "chatgpt",
19
+ "openai",
20
+ "anthropic",
21
+ "cursor",
22
+ "copilot",
23
+ "gemini",
24
+ "webmcp",
25
+ "dynamic-tools",
26
+ "mcp-server",
27
+ "mcp-client",
28
+ "tool-registration",
29
+ "ai-integration"
15
30
  ],
16
- "homepage": "https://github.com/MiguelsPizza/WebMCP#readme",
31
+ "homepage": "https://docs.mcp-b.ai/packages/webmcp-ts-sdk",
17
32
  "bugs": {
18
- "url": "https://github.com/MiguelsPizza/WebMCP/issues"
33
+ "url": "https://github.com/WebMCP-org/npm-packages/issues"
19
34
  },
20
35
  "repository": {
21
36
  "type": "git",
22
- "url": "git+https://github.com/MiguelsPizza/WebMCP.git",
23
- "directory": "packages/webmcp-ts-sdk"
37
+ "url": "git+https://github.com/WebMCP-org/npm-packages.git",
38
+ "directory": "webmcp-ts-sdk"
24
39
  },
25
40
  "license": "MIT",
26
41
  "author": "Alex Nahas",
@@ -38,7 +53,7 @@
38
53
  "dist"
39
54
  ],
40
55
  "dependencies": {
41
- "@modelcontextprotocol/sdk": "1.15.0"
56
+ "@modelcontextprotocol/sdk": "1.24.3"
42
57
  },
43
58
  "devDependencies": {
44
59
  "@types/node": "22.17.2",