@siteverb/webmcp 0.1.0-rc.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.
- package/README.md +163 -0
- package/dist/browser.js +841 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +320 -0
- package/dist/client.js.map +1 -0
- package/dist/evals/index.d.ts +13 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +20 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/fingerprint.d.ts +3 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +33 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/id.d.ts +2 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +15 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/src/client.d.ts +3 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +292 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/evals/index.d.ts +13 -0
- package/dist/src/evals/index.d.ts.map +1 -0
- package/dist/src/evals/index.js +20 -0
- package/dist/src/evals/index.js.map +1 -0
- package/dist/src/fingerprint.d.ts +3 -0
- package/dist/src/fingerprint.d.ts.map +1 -0
- package/dist/src/fingerprint.js +27 -0
- package/dist/src/fingerprint.js.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/telemetry.d.ts +21 -0
- package/dist/src/telemetry.d.ts.map +1 -0
- package/dist/src/telemetry.js +218 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +2 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/memory.d.ts +17 -0
- package/dist/src/testing/memory.d.ts.map +1 -0
- package/dist/src/testing/memory.js +72 -0
- package/dist/src/testing/memory.js.map +1 -0
- package/dist/src/transport.d.ts +8 -0
- package/dist/src/transport.d.ts.map +1 -0
- package/dist/src/transport.js +29 -0
- package/dist/src/transport.js.map +1 -0
- package/dist/src/types.d.ts +185 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/validation.d.ts +5 -0
- package/dist/src/validation.d.ts.map +1 -0
- package/dist/src/validation.js +119 -0
- package/dist/src/validation.js.map +1 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +2 -0
- package/dist/src/version.js.map +1 -0
- package/dist/telemetry.d.ts +21 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +276 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/memory.d.ts +17 -0
- package/dist/testing/memory.d.ts.map +1 -0
- package/dist/testing/memory.js +72 -0
- package/dist/testing/memory.js.map +1 -0
- package/dist/transport.d.ts +7 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +55 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +189 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +117 -0
- package/dist/validation.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @siteverb/webmcp
|
|
2
|
+
|
|
3
|
+
Native-first WebMCP registration with durable tool identity, lifecycle control, coverage checks,
|
|
4
|
+
and opt-in metadata-only telemetry.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @siteverb/webmcp
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The package has no runtime dependencies and does not install a polyfill. Use native
|
|
13
|
+
`document.modelContext` where available. If a project needs broader browser compatibility, install
|
|
14
|
+
an explicit WebMCP polyfill such as `@mcp-b/webmcp-polyfill` before creating the Siteverb client.
|
|
15
|
+
The published package is ESM-only and targets modern browser build systems and Node.js 22 or newer.
|
|
16
|
+
|
|
17
|
+
## Define and register tools
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createSiteverb, defineTool } from '@siteverb/webmcp';
|
|
21
|
+
|
|
22
|
+
const searchProducts = defineTool({
|
|
23
|
+
id: 'catalog.search-products',
|
|
24
|
+
name: 'search_products',
|
|
25
|
+
description: 'Search products currently available in the catalog.',
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
query: { type: 'string', description: 'Words to search for.' },
|
|
30
|
+
},
|
|
31
|
+
required: ['query'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
annotations: { readOnlyHint: true },
|
|
35
|
+
execute: async ({ query }: { query: string }, { signal }) => {
|
|
36
|
+
const response = await fetch(`/api/products?q=${encodeURIComponent(query)}`, { signal });
|
|
37
|
+
if (!response.ok) throw new Error('Product search failed.');
|
|
38
|
+
return response.json();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const webmcp = createSiteverb();
|
|
43
|
+
const registration = webmcp.registerTool(searchProducts);
|
|
44
|
+
await registration.ready;
|
|
45
|
+
|
|
46
|
+
// AbortSignal is the current WebMCP unregistration mechanism.
|
|
47
|
+
registration.unregister();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`id` is Siteverb's durable `domain.action` identity. It is never exposed in browser tool metadata.
|
|
51
|
+
`name` is the WebMCP wire name and may evolve while the stable ID retains release and production
|
|
52
|
+
lineage.
|
|
53
|
+
|
|
54
|
+
## Dynamic tools
|
|
55
|
+
|
|
56
|
+
Register tools in state-specific batches and replace the handle when application state changes.
|
|
57
|
+
This mirrors the dynamic tool-set pattern in Google's WebMCP demos.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
let current = webmcp.registerTools(introTools);
|
|
61
|
+
await current.ready;
|
|
62
|
+
|
|
63
|
+
current.unregister();
|
|
64
|
+
current = webmcp.registerTools(checkoutTools);
|
|
65
|
+
await current.ready;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Batch registration is atomic by default: if one registration fails, registrations started by that
|
|
69
|
+
batch are removed. Set `atomic: false` only when partial registration is intentional.
|
|
70
|
+
|
|
71
|
+
## Production telemetry
|
|
72
|
+
|
|
73
|
+
Telemetry is disabled unless both a public site ID and an endpoint or custom transport are supplied.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const webmcp = createSiteverb({
|
|
77
|
+
siteId: 'site_public_123',
|
|
78
|
+
release: import.meta.env.PUBLIC_RELEASE_SHA,
|
|
79
|
+
environment: 'production',
|
|
80
|
+
routeTemplate: '/products/:slug',
|
|
81
|
+
telemetry: {
|
|
82
|
+
endpoint: 'https://events.example.com/v1/webmcp',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The event contract contains registrations, invocation lifecycle, duration, stable tool identity,
|
|
88
|
+
wire name, schema hash, release, environment, and an ephemeral first-party page-session ID. It does
|
|
89
|
+
not contain prompts, arguments, results, DOM content, URLs, credentials, user IDs, error messages,
|
|
90
|
+
or client identity. Failed batches retain the same batch ID for idempotent retry. Automatic retries
|
|
91
|
+
use bounded exponential backoff and pause after five failures by default; the retained batch can be
|
|
92
|
+
retried explicitly with `flush()`. SHA-256 schema hashes use an algorithm-labeled FNV-1a fallback
|
|
93
|
+
only where SubtleCrypto is unavailable.
|
|
94
|
+
|
|
95
|
+
The default transport uses credential-free keepalive fetch for every flush, including page
|
|
96
|
+
lifecycle delivery. Route templates must be pathname templates such as `/products/:slug`; full URLs,
|
|
97
|
+
query strings, fragments, control characters, and values over 500 characters are omitted with a
|
|
98
|
+
diagnostic rather than transmitted.
|
|
99
|
+
|
|
100
|
+
Collector endpoints must be a same-origin relative path, HTTPS URL, or loopback HTTP URL. URL
|
|
101
|
+
credentials, query strings, and fragments are rejected. Use an explicit custom transport when a
|
|
102
|
+
first-party collector requires a different authenticated delivery mechanism.
|
|
103
|
+
|
|
104
|
+
Use a custom transport for first-party collection, OpenTelemetry adaptation, tests, or a private
|
|
105
|
+
collector:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const webmcp = createSiteverb({
|
|
109
|
+
siteId: 'site_public_123',
|
|
110
|
+
telemetry: {
|
|
111
|
+
transport: {
|
|
112
|
+
async send(batch, reason) {
|
|
113
|
+
await myCollector.write(batch, reason);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Coverage
|
|
121
|
+
|
|
122
|
+
`coverage()` compares native `getTools()` inventory with tools registered through Siteverb. A tool
|
|
123
|
+
that bypasses the facade is reported as `inventoryOnly`; the SDK never claims invocation telemetry
|
|
124
|
+
for it.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const coverage = await webmcp.coverage();
|
|
128
|
+
console.log(coverage.completeness, coverage.inventoryOnly);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Google webmcp-evals
|
|
132
|
+
|
|
133
|
+
Siteverb exports the static schema consumed by GoogleChromeLabs `webmcp-evals local` mode:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { toWebMcpEvalsSchema } from '@siteverb/webmcp/evals';
|
|
137
|
+
|
|
138
|
+
const schema = toWebMcpEvalsSchema([searchProducts]);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Write the returned JSON to a generated artifact, then run Google's CLI. `@siteverb/runner` separately
|
|
142
|
+
executes portable deterministic journeys through Puppeteer's native `page.webmcp` surface. Google's
|
|
143
|
+
model-backed evals remain a distinct evidence class; model variance does not silently become a
|
|
144
|
+
Siteverb release failure.
|
|
145
|
+
|
|
146
|
+
## Testing
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { createMemoryModelContext, createMemoryTelemetryTransport } from '@siteverb/webmcp/testing';
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The memory context implements registration, unregistration, discovery, cancellation, and direct
|
|
153
|
+
execution. It is for unit tests only; browser evidence must still run against a named browser build.
|
|
154
|
+
|
|
155
|
+
## Current boundary
|
|
156
|
+
|
|
157
|
+
- The package targets the current `document.modelContext` Community Group draft and compiles
|
|
158
|
+
against the official `webmcp-types` package.
|
|
159
|
+
- Registration visibility is not authorization. Every underlying action must enforce authentication,
|
|
160
|
+
authorization, validation, and confirmation independently.
|
|
161
|
+
- Unsupported environments return `status: 'unsupported'`; they are not reported as verified.
|
|
162
|
+
- No caller identity is inferred. WebMCP does not expose a portable agent identity field.
|
|
163
|
+
- Website-facing skills, ARD, A2A, and backend MCP are not runtime dependencies.
|