@mcp-b/global 2.3.0 → 2.3.1-beta.20260528050333
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/README.md +8 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.js +32 -7
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
## Why Use @mcp-b/global?
|
|
16
16
|
|
|
17
|
-
| Feature | Benefit
|
|
18
|
-
| ---------------------------- |
|
|
19
|
-
| **W3C Standard** | Implements the emerging Web Model Context API specification
|
|
20
|
-
| **Drop-in IIFE** | Add AI capabilities with a single `<script>` tag - no build step
|
|
21
|
-
| **Native Chromium Support** | Auto-detects and uses native browser implementation when available
|
|
22
|
-
| **Dual Transport** | Works with both same-window clients AND parent pages (iframe support)
|
|
23
|
-
| **Spec-Aware Compatibility** | Tracks the
|
|
24
|
-
| **Works with Any AI** | Claude, ChatGPT, Gemini, Cursor, Copilot, and any MCP client
|
|
17
|
+
| Feature | Benefit |
|
|
18
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| **W3C Standard** | Implements the emerging Web Model Context API specification |
|
|
20
|
+
| **Drop-in IIFE** | Add AI capabilities with a single `<script>` tag - no build step |
|
|
21
|
+
| **Native Chromium Support** | Auto-detects and uses native browser implementation when available |
|
|
22
|
+
| **Dual Transport** | Works with both same-window clients AND parent pages (iframe support) |
|
|
23
|
+
| **Spec-Aware Compatibility** | Tracks the current WebMCP draft (`document.modelContext`, `registerTool(tool, { signal })`, `getTools()`, and `executeTool(...)`). Deprecated `unregisterTool(name)` and the `{ unregister }` return handle remain for existing MCP-B integrations and will be removed in the next major version. |
|
|
24
|
+
| **Works with Any AI** | Claude, ChatGPT, Gemini, Cursor, Copilot, and any MCP client |
|
|
25
25
|
|
|
26
26
|
## Package Selection
|
|
27
27
|
|
|
@@ -134,47 +134,6 @@ initializeWebModelContext();
|
|
|
134
134
|
|
|
135
135
|
After initialization, `navigator.modelContext` exposes these methods:
|
|
136
136
|
|
|
137
|
-
#### `provideContext(options?)`
|
|
138
|
-
|
|
139
|
-
Deprecated compatibility API. The upstream WebMCP spec removed `provideContext()` on March 5, 2026. `@mcp-b/global` keeps it functional for now, but logs a deprecation warning and will remove it in the next major version.
|
|
140
|
-
|
|
141
|
-
Replaces all currently registered tools with a new set. This is an atomic replacement - all previous tools are removed first.
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
navigator.modelContext.provideContext({
|
|
145
|
-
tools: [
|
|
146
|
-
{
|
|
147
|
-
name: 'search-products',
|
|
148
|
-
description: 'Search the product catalog by query',
|
|
149
|
-
inputSchema: {
|
|
150
|
-
type: 'object',
|
|
151
|
-
properties: {
|
|
152
|
-
query: { type: 'string', description: 'Search query' },
|
|
153
|
-
limit: { type: 'integer', description: 'Max results' },
|
|
154
|
-
},
|
|
155
|
-
required: ['query'],
|
|
156
|
-
},
|
|
157
|
-
async execute(args) {
|
|
158
|
-
const results = await searchProducts(args.query, args.limit ?? 10);
|
|
159
|
-
return {
|
|
160
|
-
content: [{ type: 'text', text: JSON.stringify(results) }],
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: 'get-cart',
|
|
166
|
-
description: 'Get the current shopping cart contents',
|
|
167
|
-
inputSchema: { type: 'object', properties: {} },
|
|
168
|
-
async execute() {
|
|
169
|
-
return {
|
|
170
|
-
content: [{ type: 'text', text: JSON.stringify(getCart()) }],
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
137
|
#### `registerTool(tool, options?)`
|
|
179
138
|
|
|
180
139
|
Registers a single tool. The tool name must be unique, otherwise throws if a tool with the same name already exists. The recommended unregistration path is `options.signal` (`AbortSignal`):
|
|
@@ -217,16 +176,6 @@ Removes a tool by name. The April 23, 2026 WebMCP draft removed `unregisterTool`
|
|
|
217
176
|
navigator.modelContext.unregisterTool('add-to-cart');
|
|
218
177
|
```
|
|
219
178
|
|
|
220
|
-
#### `clearContext()`
|
|
221
|
-
|
|
222
|
-
Deprecated compatibility API. The upstream WebMCP spec removed `clearContext()` on March 5, 2026. `@mcp-b/global` keeps it functional for now, but logs a deprecation warning and will remove it in the next major version.
|
|
223
|
-
|
|
224
|
-
Removes all registered tools.
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
navigator.modelContext.clearContext();
|
|
228
|
-
```
|
|
229
|
-
|
|
230
179
|
#### `listTools()`
|
|
231
180
|
|
|
232
181
|
Returns metadata for all registered tools (without execute functions).
|
|
@@ -527,7 +476,6 @@ import type {
|
|
|
527
476
|
InputSchema,
|
|
528
477
|
ModelContext,
|
|
529
478
|
ModelContextCore,
|
|
530
|
-
ModelContextOptions,
|
|
531
479
|
NativeModelContextBehavior,
|
|
532
480
|
ToolAnnotations,
|
|
533
481
|
ToolDescriptor,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/global.ts"],"mappings":";;;UAEiB,sBAAA;EACf,SAAA,GAAY,OAAA,CAAQ,yBAAA;EACpB,YAAA,GAAe,OAAA,CAAQ,2BAAA;AAAA;AAAA,KAGb,0BAAA;AAAA,UAEK,0BAAA;EACf,SAAA,GAAY,sBAAA;EACZ,cAAA;EAPe;;;;;;;EAef,0BAAA,GAA6B,0BAAA;EAfN;;;AAGzB;;;EAmBE,kBAAA;AAAA;AAAA,QAGM,MAAA;EAAA,UACI,MAAA;IACR,wBAAA,GAA2B,0BAAA;EAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/global.ts"],"mappings":";;;UAEiB,sBAAA;EACf,SAAA,GAAY,OAAA,CAAQ,yBAAA;EACpB,YAAA,GAAe,OAAA,CAAQ,2BAAA;AAAA;AAAA,KAGb,0BAAA;AAAA,UAEK,0BAAA;EACf,SAAA,GAAY,sBAAA;EACZ,cAAA;EAPe;;;;;;;EAef,0BAAA,GAA6B,0BAAA;EAfN;;;AAGzB;;;EAmBE,kBAAA;AAAA;AAAA,QAGM,MAAA;EAAA,UACI,MAAA;IACR,wBAAA,GAA2B,0BAAA;EAAA;AAAA;;;iBC2Mf,yBAAA,CAA0B,OAAA,GAAU,0BAAA;AAAA,iBA6DpC,sBAAA,CAAA"}
|