@mcp-b/webmcp-local-relay 4.0.0 → 5.0.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/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { EventEmitter } from "node:events";
2
- import { CallToolRequestParamsSchema, CallToolResult, CallToolResult as CallToolResult$1, CallToolResultSchema, Tool, Tool as Tool$1, ToolAnnotations, ToolAnnotations as ToolAnnotations$1, ToolAnnotationsSchema, ToolSchema } from "@modelcontextprotocol/sdk/types.js";
2
+ import { CallToolRequestParamsSchema, CallToolResultSchema, ToolAnnotationsSchema, ToolSchema } from "@modelcontextprotocol/core";
3
3
  import { z } from "zod/v4";
4
- import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
4
+ import * as _$_modelcontextprotocol_server0 from "@modelcontextprotocol/server";
5
+ import { CallToolResult, Tool, ToolAnnotations, Transport } from "@modelcontextprotocol/server";
5
6
 
6
7
  //#region src/protocol.d.ts
7
8
  /**
@@ -11,14 +12,12 @@ declare const NormalizedToolSchema: z.ZodObject<{
11
12
  description: z.ZodOptional<z.ZodString>;
12
13
  inputSchema: z.ZodObject<{
13
14
  type: z.ZodLiteral<"object">;
14
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
15
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
15
16
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
17
  }, z.core.$catchall<z.ZodUnknown>>;
17
18
  outputSchema: z.ZodOptional<z.ZodObject<{
18
- type: z.ZodLiteral<"object">;
19
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
20
- required: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
- }, z.core.$catchall<z.ZodUnknown>>>;
19
+ $schema: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$loose>>;
22
21
  annotations: z.ZodOptional<z.ZodObject<{
23
22
  title: z.ZodOptional<z.ZodString>;
24
23
  readOnlyHint: z.ZodOptional<z.ZodBoolean>;
@@ -46,15 +45,6 @@ declare const NormalizedToolSchema: z.ZodObject<{
46
45
  title: z.ZodOptional<z.ZodString>;
47
46
  name: z.ZodString;
48
47
  }, z.core.$strip>;
49
- /**
50
- * Permissive inbound tool shape from browser/widget payloads.
51
- *
52
- * Only enforces a non-empty name at ingest. All other fields are normalized
53
- * against SDK schemas by {@link normalizeInboundTool}.
54
- */
55
- declare const InboundToolSchema: z.ZodObject<{
56
- name: z.ZodString;
57
- }, z.core.$loose>;
58
48
  /**
59
49
  * SDK-derived argument schema for tool invocation payloads.
60
50
  */
@@ -63,7 +53,45 @@ declare const RelayInvokeArgsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.Zo
63
53
  * Default input schema applied when inbound payload omits or provides
64
54
  * a non-object input schema.
65
55
  */
66
- declare const DEFAULT_TOOL_INPUT_SCHEMA: Tool$1['inputSchema'];
56
+ declare const DEFAULT_TOOL_INPUT_SCHEMA: Tool['inputSchema'];
57
+ /** SDK tool schema with a browser-compatible default input schema. */
58
+ declare const InboundToolSchema: z.ZodObject<{
59
+ description: z.ZodOptional<z.ZodString>;
60
+ outputSchema: z.ZodOptional<z.ZodObject<{
61
+ $schema: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$loose>>;
63
+ annotations: z.ZodOptional<z.ZodObject<{
64
+ title: z.ZodOptional<z.ZodString>;
65
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
66
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
67
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
68
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
69
+ }, z.core.$strip>>;
70
+ execution: z.ZodOptional<z.ZodObject<{
71
+ taskSupport: z.ZodOptional<z.ZodEnum<{
72
+ optional: "optional";
73
+ required: "required";
74
+ forbidden: "forbidden";
75
+ }>>;
76
+ }, z.core.$strip>>;
77
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
78
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
79
+ src: z.ZodString;
80
+ mimeType: z.ZodOptional<z.ZodString>;
81
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
+ theme: z.ZodOptional<z.ZodEnum<{
83
+ light: "light";
84
+ dark: "dark";
85
+ }>>;
86
+ }, z.core.$strip>>>;
87
+ title: z.ZodOptional<z.ZodString>;
88
+ name: z.ZodString;
89
+ inputSchema: z.ZodOptional<z.ZodObject<{
90
+ type: z.ZodLiteral<"object">;
91
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
92
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
+ }, z.core.$catchall<z.ZodUnknown>>>;
94
+ }, z.core.$strip>;
67
95
  /**
68
96
  * Canonical normalized relay tool shape.
69
97
  */
@@ -71,27 +99,21 @@ type RelayTool = z.infer<typeof NormalizedToolSchema>;
71
99
  /**
72
100
  * Canonical relay tool annotations shape.
73
101
  */
74
- type RelayToolAnnotations = ToolAnnotations$1;
102
+ type RelayToolAnnotations = ToolAnnotations;
75
103
  /**
76
104
  * Canonical relay call result shape.
77
105
  */
78
- type RelayCallToolResult = CallToolResult$1;
106
+ type RelayCallToolResult = CallToolResult;
79
107
  /**
80
108
  * Invocation argument object shape derived from MCP SDK request params.
81
109
  */
82
110
  type RelayInvokeArgs = Exclude<z.infer<typeof RelayInvokeArgsSchema>, undefined>;
83
111
  /**
84
- * Normalizes permissive inbound tool payloads into SDK-compliant Tool objects.
85
- *
86
- * Invalid optional metadata (description, output schema, annotations, etc.)
87
- * is dropped. Invalid/missing inputSchema falls back to an empty object schema.
112
+ * Applies the browser default input schema and validates the complete SDK tool.
88
113
  */
89
114
  declare function normalizeInboundTool(inbound: z.infer<typeof InboundToolSchema>): RelayTool;
90
115
  //#endregion
91
116
  //#region src/schemas.d.ts
92
- /**
93
- * Schema for source identity bootstrap message.
94
- */
95
117
  declare const BrowserHelloMessageSchema: z.ZodObject<{
96
118
  type: z.ZodLiteral<"hello">;
97
119
  tabId: z.ZodString;
@@ -113,21 +135,53 @@ declare const BrowserToRelayMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
113
135
  }, z.core.$strip>, z.ZodObject<{
114
136
  type: z.ZodLiteral<"tools/list">;
115
137
  tools: z.ZodPipe<z.ZodArray<z.ZodObject<{
138
+ description: z.ZodOptional<z.ZodString>;
139
+ outputSchema: z.ZodOptional<z.ZodObject<{
140
+ $schema: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$loose>>;
142
+ annotations: z.ZodOptional<z.ZodObject<{
143
+ title: z.ZodOptional<z.ZodString>;
144
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
145
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
146
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
147
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
148
+ }, z.core.$strip>>;
149
+ execution: z.ZodOptional<z.ZodObject<{
150
+ taskSupport: z.ZodOptional<z.ZodEnum<{
151
+ optional: "optional";
152
+ required: "required";
153
+ forbidden: "forbidden";
154
+ }>>;
155
+ }, z.core.$strip>>;
156
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
157
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
158
+ src: z.ZodString;
159
+ mimeType: z.ZodOptional<z.ZodString>;
160
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
161
+ theme: z.ZodOptional<z.ZodEnum<{
162
+ light: "light";
163
+ dark: "dark";
164
+ }>>;
165
+ }, z.core.$strip>>>;
166
+ title: z.ZodOptional<z.ZodString>;
116
167
  name: z.ZodString;
117
- }, z.core.$loose>>, z.ZodTransform<{
168
+ inputSchema: z.ZodOptional<z.ZodObject<{
169
+ type: z.ZodLiteral<"object">;
170
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
171
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
172
+ }, z.core.$catchall<z.ZodUnknown>>>;
173
+ }, z.core.$strip>>, z.ZodTransform<{
118
174
  inputSchema: {
119
175
  [x: string]: unknown;
120
176
  type: "object";
121
- properties?: Record<string, object> | undefined;
177
+ properties?: Record<string, _$_modelcontextprotocol_server0.JSONValue> | undefined;
122
178
  required?: string[] | undefined;
123
179
  };
124
180
  name: string;
125
181
  description?: string | undefined;
126
182
  outputSchema?: {
127
183
  [x: string]: unknown;
128
- type: "object";
129
- properties?: Record<string, object> | undefined;
130
- required?: string[] | undefined;
184
+ $schema?: string | undefined;
131
185
  } | undefined;
132
186
  annotations?: {
133
187
  title?: string | undefined;
@@ -148,27 +202,87 @@ declare const BrowserToRelayMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
148
202
  }[] | undefined;
149
203
  title?: string | undefined;
150
204
  }[], {
151
- [x: string]: unknown;
152
205
  name: string;
206
+ description?: string | undefined;
207
+ outputSchema?: {
208
+ [x: string]: unknown;
209
+ $schema?: string | undefined;
210
+ } | undefined;
211
+ annotations?: {
212
+ title?: string | undefined;
213
+ readOnlyHint?: boolean | undefined;
214
+ destructiveHint?: boolean | undefined;
215
+ idempotentHint?: boolean | undefined;
216
+ openWorldHint?: boolean | undefined;
217
+ } | undefined;
218
+ execution?: {
219
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
220
+ } | undefined;
221
+ _meta?: Record<string, unknown> | undefined;
222
+ icons?: {
223
+ src: string;
224
+ mimeType?: string | undefined;
225
+ sizes?: string[] | undefined;
226
+ theme?: "light" | "dark" | undefined;
227
+ }[] | undefined;
228
+ title?: string | undefined;
229
+ inputSchema?: {
230
+ [x: string]: unknown;
231
+ type: "object";
232
+ properties?: Record<string, _$_modelcontextprotocol_server0.JSONValue> | undefined;
233
+ required?: string[] | undefined;
234
+ } | undefined;
153
235
  }[]>>;
154
236
  }, z.core.$strip>, z.ZodObject<{
155
237
  type: z.ZodLiteral<"tools/changed">;
156
238
  tools: z.ZodPipe<z.ZodArray<z.ZodObject<{
239
+ description: z.ZodOptional<z.ZodString>;
240
+ outputSchema: z.ZodOptional<z.ZodObject<{
241
+ $schema: z.ZodOptional<z.ZodString>;
242
+ }, z.core.$loose>>;
243
+ annotations: z.ZodOptional<z.ZodObject<{
244
+ title: z.ZodOptional<z.ZodString>;
245
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
246
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
247
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
248
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
249
+ }, z.core.$strip>>;
250
+ execution: z.ZodOptional<z.ZodObject<{
251
+ taskSupport: z.ZodOptional<z.ZodEnum<{
252
+ optional: "optional";
253
+ required: "required";
254
+ forbidden: "forbidden";
255
+ }>>;
256
+ }, z.core.$strip>>;
257
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
258
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
259
+ src: z.ZodString;
260
+ mimeType: z.ZodOptional<z.ZodString>;
261
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
262
+ theme: z.ZodOptional<z.ZodEnum<{
263
+ light: "light";
264
+ dark: "dark";
265
+ }>>;
266
+ }, z.core.$strip>>>;
267
+ title: z.ZodOptional<z.ZodString>;
157
268
  name: z.ZodString;
158
- }, z.core.$loose>>, z.ZodTransform<{
269
+ inputSchema: z.ZodOptional<z.ZodObject<{
270
+ type: z.ZodLiteral<"object">;
271
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
272
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
273
+ }, z.core.$catchall<z.ZodUnknown>>>;
274
+ }, z.core.$strip>>, z.ZodTransform<{
159
275
  inputSchema: {
160
276
  [x: string]: unknown;
161
277
  type: "object";
162
- properties?: Record<string, object> | undefined;
278
+ properties?: Record<string, _$_modelcontextprotocol_server0.JSONValue> | undefined;
163
279
  required?: string[] | undefined;
164
280
  };
165
281
  name: string;
166
282
  description?: string | undefined;
167
283
  outputSchema?: {
168
284
  [x: string]: unknown;
169
- type: "object";
170
- properties?: Record<string, object> | undefined;
171
- required?: string[] | undefined;
285
+ $schema?: string | undefined;
172
286
  } | undefined;
173
287
  annotations?: {
174
288
  title?: string | undefined;
@@ -189,8 +303,36 @@ declare const BrowserToRelayMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
189
303
  }[] | undefined;
190
304
  title?: string | undefined;
191
305
  }[], {
192
- [x: string]: unknown;
193
306
  name: string;
307
+ description?: string | undefined;
308
+ outputSchema?: {
309
+ [x: string]: unknown;
310
+ $schema?: string | undefined;
311
+ } | undefined;
312
+ annotations?: {
313
+ title?: string | undefined;
314
+ readOnlyHint?: boolean | undefined;
315
+ destructiveHint?: boolean | undefined;
316
+ idempotentHint?: boolean | undefined;
317
+ openWorldHint?: boolean | undefined;
318
+ } | undefined;
319
+ execution?: {
320
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
321
+ } | undefined;
322
+ _meta?: Record<string, unknown> | undefined;
323
+ icons?: {
324
+ src: string;
325
+ mimeType?: string | undefined;
326
+ sizes?: string[] | undefined;
327
+ theme?: "light" | "dark" | undefined;
328
+ }[] | undefined;
329
+ title?: string | undefined;
330
+ inputSchema?: {
331
+ [x: string]: unknown;
332
+ type: "object";
333
+ properties?: Record<string, _$_modelcontextprotocol_server0.JSONValue> | undefined;
334
+ required?: string[] | undefined;
335
+ } | undefined;
194
336
  }[]>>;
195
337
  }, z.core.$strip>, z.ZodObject<{
196
338
  type: z.ZodLiteral<"result">;
@@ -198,11 +340,7 @@ declare const BrowserToRelayMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
198
340
  result: z.ZodUnknown;
199
341
  }, z.core.$strip>, z.ZodObject<{
200
342
  type: z.ZodLiteral<"pong">;
201
- }, z.core.$strip>, z.ZodObject<{
202
- type: z.ZodLiteral<"elicitation-request">;
203
- callId: z.ZodString;
204
- params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
205
- }, z.core.$strip>]>;
343
+ }, z.core.$strip>], "type">;
206
344
  /**
207
345
  * Browser-to-relay message payload.
208
346
  */
@@ -294,18 +432,11 @@ declare const RelayToBrowserMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
294
432
  type: z.ZodLiteral<"ping">;
295
433
  }, z.core.$strip>, z.ZodObject<{
296
434
  type: z.ZodLiteral<"reload">;
297
- }, z.core.$strip>, z.ZodObject<{
298
- type: z.ZodLiteral<"elicitation-response">;
299
- callId: z.ZodString;
300
- result: z.ZodRecord<z.ZodString, z.ZodUnknown>;
301
- }, z.core.$strip>]>;
435
+ }, z.core.$strip>], "type">;
302
436
  /**
303
437
  * Relay-to-browser message payload.
304
438
  */
305
439
  type RelayToBrowserMessage = z.infer<typeof RelayToBrowserMessageSchema>;
306
- /**
307
- * Relay-to-relay protocol (client mode <-> server mode).
308
- */
309
440
  /**
310
441
  * Schema for source metadata transmitted in relay-to-relay messages.
311
442
  */
@@ -336,7 +467,7 @@ declare const RelayClientToServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
336
467
  callId: z.ZodString;
337
468
  toolName: z.ZodString;
338
469
  args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
339
- }, z.core.$strip>]>;
470
+ }, z.core.$strip>], "type">;
340
471
  /**
341
472
  * Relay client to server message payload.
342
473
  */
@@ -359,14 +490,12 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
359
490
  description: z.ZodOptional<z.ZodString>;
360
491
  inputSchema: z.ZodObject<{
361
492
  type: z.ZodLiteral<"object">;
362
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
493
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
363
494
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
364
495
  }, z.core.$catchall<z.ZodUnknown>>;
365
496
  outputSchema: z.ZodOptional<z.ZodObject<{
366
- type: z.ZodLiteral<"object">;
367
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
368
- required: z.ZodOptional<z.ZodArray<z.ZodString>>;
369
- }, z.core.$catchall<z.ZodUnknown>>>;
497
+ $schema: z.ZodOptional<z.ZodString>;
498
+ }, z.core.$loose>>;
370
499
  annotations: z.ZodOptional<z.ZodObject<{
371
500
  title: z.ZodOptional<z.ZodString>;
372
501
  readOnlyHint: z.ZodOptional<z.ZodBoolean>;
@@ -394,7 +523,7 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
394
523
  title: z.ZodOptional<z.ZodString>;
395
524
  name: z.ZodString;
396
525
  }, z.core.$strip>>;
397
- sources: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
526
+ sources: z.ZodArray<z.ZodObject<{
398
527
  sourceId: z.ZodString;
399
528
  tabId: z.ZodString;
400
529
  origin: z.ZodOptional<z.ZodString>;
@@ -404,18 +533,30 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
404
533
  connectedAt: z.ZodNumber;
405
534
  lastSeenAt: z.ZodNumber;
406
535
  toolCount: z.ZodNumber;
407
- }, z.core.$strip>>>>;
408
- toolSourceMap: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
536
+ }, z.core.$strip>>;
537
+ toolSourceMap: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
409
538
  type: z.ZodLiteral<"relay/tools">;
410
539
  }, z.core.$strip>, z.ZodObject<{
411
540
  type: z.ZodLiteral<"relay/result">;
412
541
  callId: z.ZodString;
413
542
  result: z.ZodObject<{
414
543
  _meta: z.ZodOptional<z.ZodObject<{
415
- progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
416
- "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
417
- taskId: z.ZodString;
418
- }, z.core.$strip>>;
544
+ readonly "io.modelcontextprotocol/serverInfo": z.ZodCatch<z.ZodOptional<z.ZodObject<{
545
+ version: z.ZodString;
546
+ websiteUrl: z.ZodOptional<z.ZodString>;
547
+ description: z.ZodOptional<z.ZodString>;
548
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
549
+ src: z.ZodString;
550
+ mimeType: z.ZodOptional<z.ZodString>;
551
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
552
+ theme: z.ZodOptional<z.ZodEnum<{
553
+ light: "light";
554
+ dark: "dark";
555
+ }>>;
556
+ }, z.core.$strip>>>;
557
+ name: z.ZodString;
558
+ title: z.ZodOptional<z.ZodString>;
559
+ }, z.core.$strip>>>;
419
560
  }, z.core.$loose>>;
420
561
  content: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
421
562
  type: z.ZodLiteral<"text">;
@@ -504,7 +645,7 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
504
645
  }, z.core.$strip>>;
505
646
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
506
647
  }, z.core.$strip>]>>>;
507
- structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
648
+ structuredContent: z.ZodOptional<z.ZodUnknown>;
508
649
  isError: z.ZodOptional<z.ZodBoolean>;
509
650
  }, z.core.$loose>;
510
651
  }, z.core.$strip>, z.ZodObject<{
@@ -512,14 +653,12 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
512
653
  description: z.ZodOptional<z.ZodString>;
513
654
  inputSchema: z.ZodObject<{
514
655
  type: z.ZodLiteral<"object">;
515
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
656
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue, z.core.$ZodTypeInternals<_$_modelcontextprotocol_server0.JSONValue, _$_modelcontextprotocol_server0.JSONValue>>>>;
516
657
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
517
658
  }, z.core.$catchall<z.ZodUnknown>>;
518
659
  outputSchema: z.ZodOptional<z.ZodObject<{
519
- type: z.ZodLiteral<"object">;
520
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<object, object>>>;
521
- required: z.ZodOptional<z.ZodArray<z.ZodString>>;
522
- }, z.core.$catchall<z.ZodUnknown>>>;
660
+ $schema: z.ZodOptional<z.ZodString>;
661
+ }, z.core.$loose>>;
523
662
  annotations: z.ZodOptional<z.ZodObject<{
524
663
  title: z.ZodOptional<z.ZodString>;
525
664
  readOnlyHint: z.ZodOptional<z.ZodBoolean>;
@@ -547,7 +686,7 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
547
686
  title: z.ZodOptional<z.ZodString>;
548
687
  name: z.ZodString;
549
688
  }, z.core.$strip>>;
550
- sources: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
689
+ sources: z.ZodArray<z.ZodObject<{
551
690
  sourceId: z.ZodString;
552
691
  tabId: z.ZodString;
553
692
  origin: z.ZodOptional<z.ZodString>;
@@ -557,10 +696,10 @@ declare const RelayServerToClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
557
696
  connectedAt: z.ZodNumber;
558
697
  lastSeenAt: z.ZodNumber;
559
698
  toolCount: z.ZodNumber;
560
- }, z.core.$strip>>>>;
561
- toolSourceMap: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
699
+ }, z.core.$strip>>;
700
+ toolSourceMap: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
562
701
  type: z.ZodLiteral<"relay/tools-changed">;
563
- }, z.core.$strip>]>;
702
+ }, z.core.$strip>], "type">;
564
703
  /**
565
704
  * Relay server to client message payload.
566
705
  */
@@ -573,10 +712,10 @@ type RelayServerToClientMessage = z.infer<typeof RelayServerToClientMessageSchem
573
712
  interface SourceMetadata {
574
713
  sourceId: string;
575
714
  tabId: string;
576
- origin: string | undefined;
577
- url: string | undefined;
578
- title: string | undefined;
579
- iconUrl: string | undefined;
715
+ origin?: string | undefined;
716
+ url?: string | undefined;
717
+ title?: string | undefined;
718
+ iconUrl?: string | undefined;
580
719
  connectedAt: number;
581
720
  lastSeenAt: number;
582
721
  }
@@ -667,10 +806,6 @@ declare class RelayRegistry {
667
806
  * Converts internal source metadata to public source info.
668
807
  */
669
808
  private toSourceInfo;
670
- /**
671
- * Removes all tool providers for a connection.
672
- */
673
- private removeConnectionTools;
674
809
  /**
675
810
  * Rebuilds public tool names after source set changes.
676
811
  *
@@ -720,7 +855,7 @@ interface RelayBridgeServerOptions {
720
855
  */
721
856
  persistPath?: string;
722
857
  /**
723
- * Allowed host page origins reported by browser `hello` messages.
858
+ * Allowed host page origins verified from browser WebSocket requests.
724
859
  * Use `["*"]` to allow all origins.
725
860
  *
726
861
  * Permissive by default for zero-config developer experience: any browser
@@ -738,7 +873,7 @@ interface RelayBridgeServerOptions {
738
873
  maxPayloadBytes?: number;
739
874
  /**
740
875
  * Timeout used for browser tool invocations.
741
- * @defaultValue `25000`
876
+ * @defaultValue `65000`
742
877
  */
743
878
  invokeTimeoutMs?: number;
744
879
  /**
@@ -784,7 +919,9 @@ declare class RelayBridgeServer extends EventEmitter {
784
919
  private readonly instanceId;
785
920
  private wss;
786
921
  private readonly socketByConnectionId;
922
+ private readonly requestOriginByConnectionId;
787
923
  private readonly pendingInvocations;
924
+ private readonly browserClientConnectionIds;
788
925
  private readonly relayClientConnectionIds;
789
926
  private readonly heartbeatIntervalByConnectionId;
790
927
  private readonly lastPongByConnectionId;
@@ -841,6 +978,7 @@ declare class RelayBridgeServer extends EventEmitter {
841
978
  start(): Promise<void>;
842
979
  private startUsingPortStrategy;
843
980
  private isAddressInUseError;
981
+ private persistSelectedPort;
844
982
  private tryAttachToExistingRelay;
845
983
  /**
846
984
  * Stops all relay resources and rejects any pending invocations.
@@ -861,22 +999,21 @@ declare class RelayBridgeServer extends EventEmitter {
861
999
  }): Promise<RelayCallToolResult>;
862
1000
  private startAsServer;
863
1001
  private buildServerHello;
864
- private invokeToolLocally;
865
1002
  /**
866
- * Handles a raw WebSocket message from a connected source.
867
- *
868
- * Routes relay-protocol messages (`relay/*`) to the relay client handler
869
- * and browser-protocol messages to the existing browser handler.
1003
+ * `async` is load-bearing: {@link onRelayClientMessage} consumes this through
1004
+ * `.then(onResult, onError)`, so a synchronous throw would escape the socket
1005
+ * message handler as an uncaught exception and leave the relay client waiting
1006
+ * for a `relay/result` that never arrives.
870
1007
  */
1008
+ private invokeToolLocally;
1009
+ /** Handles a raw message according to the negotiated WebSocket protocol. */
871
1010
  private onSocketMessage;
872
- /**
873
- * Sends an elicitation response back to the browser source that requested it.
874
- */
875
- sendElicitationResponse(connectionId: string, callId: string, result: Record<string, unknown>): void;
1011
+ private onBrowserClientMessage;
876
1012
  /**
877
1013
  * Handles relay-protocol messages from relay client connections.
878
1014
  */
879
1015
  private onRelayClientMessage;
1016
+ private sendRelayResult;
880
1017
  /**
881
1018
  * Pushes current tool state to all connected relay clients.
882
1019
  */
@@ -907,10 +1044,6 @@ declare class RelayBridgeServer extends EventEmitter {
907
1044
  * Builds the complete relay response payload including tools and source metadata.
908
1045
  */
909
1046
  private buildRelayToolsPayload;
910
- /**
911
- * Maps aggregated tools to the wire format used by the relay protocol.
912
- */
913
- private toWireTools;
914
1047
  private isHostOriginAllowed;
915
1048
  private sendHelloAccepted;
916
1049
  private sendHelloRejected;
@@ -930,6 +1063,7 @@ declare class RelayBridgeServer extends EventEmitter {
930
1063
  * Parsed CLI options for relay startup.
931
1064
  */
932
1065
  interface CliOptions {
1066
+ help: boolean;
933
1067
  host: string;
934
1068
  port: number;
935
1069
  portExplicitlySet: boolean;
@@ -938,6 +1072,7 @@ interface CliOptions {
938
1072
  workspace?: string;
939
1073
  relayId?: string;
940
1074
  maxPayloadBytes?: number;
1075
+ invokeTimeoutMs?: number;
941
1076
  }
942
1077
  /**
943
1078
  * Parses supported CLI flags for relay startup.
@@ -984,12 +1119,7 @@ declare class LocalRelayMcpServer {
984
1119
  */
985
1120
  readonly bridge: RelayBridgeServer;
986
1121
  private readonly mcpServer;
987
- private readonly staticToolData;
988
- private readonly dynamicToolHandles;
989
- private readonly dynamicToolData;
990
- private readonly dynamicToolSignature;
991
- private syncing;
992
- private syncRequested;
1122
+ private readonly dynamicTools;
993
1123
  private syncDebounceTimer;
994
1124
  private connected;
995
1125
  /**
@@ -1018,32 +1148,15 @@ declare class LocalRelayMcpServer {
1018
1148
  * Returns dynamic tool names currently registered in MCP.
1019
1149
  */
1020
1150
  listDynamicToolNames(): string[];
1021
- /**
1022
- * Overrides the SDK's ListTools handler to return real JSON Schema
1023
- * for dynamic tools instead of the empty `z.object({}).passthrough()`
1024
- * schema that the SDK would otherwise convert to `{ type: 'object' }`.
1025
- *
1026
- * The MCP SDK's McpServer internally runs `toJsonSchemaCompat()` on
1027
- * registered inputSchema values, which strips plain JSON Schema objects
1028
- * (non-Zod) to empty schemas. This override bypasses that conversion
1029
- * for dynamic (relayed) tools while preserving static tools as-is.
1030
- */
1031
- private overrideListToolsHandler;
1032
- private registerStaticTool;
1033
1151
  /**
1034
1152
  * Registers built-in management tools exposed by the relay.
1035
1153
  */
1036
1154
  private registerStaticTools;
1037
- /**
1038
- * Builds a concise plain-text list of available tools.
1039
- */
1040
- private buildToolSummary;
1041
1155
  /**
1042
1156
  * Opens a URL in the user's default browser using the platform open command.
1043
1157
  *
1044
- * Uses the re-serialized `URL.href` to prevent injection of shell metacharacters.
1045
- * On Windows, PowerShell `Start-Process` is used instead of `cmd /c start`
1046
- * because cmd.exe interprets `&`, `|`, and other metacharacters in URLs.
1158
+ * Passes the re-serialized `URL.href` directly to the platform launcher.
1159
+ * No shell or command-language string is involved.
1047
1160
  */
1048
1161
  private openInBrowser;
1049
1162
  /**
@@ -1055,10 +1168,6 @@ declare class LocalRelayMcpServer {
1055
1168
  * notifications through the stdio transport and overwhelming the agent.
1056
1169
  */
1057
1170
  private debouncedSyncDynamicTools;
1058
- /**
1059
- * Coalesces concurrent sync requests into a single serialized sync loop.
1060
- */
1061
- private syncDynamicTools;
1062
1171
  /**
1063
1172
  * Returns the current aggregated tool list, dispatching based on bridge mode.
1064
1173
  */
@@ -1069,9 +1178,9 @@ declare class LocalRelayMcpServer {
1069
1178
  */
1070
1179
  private buildAggregatedToolsFromRelay;
1071
1180
  /**
1072
- * Applies registry tool state to MCP dynamic registrations.
1181
+ * Applies current aggregated tool state to MCP dynamic registrations.
1073
1182
  */
1074
- private applyDynamicTools;
1183
+ private syncDynamicTools;
1075
1184
  /**
1076
1185
  * Registers a single dynamic tool and returns a removal handle.
1077
1186
  */
@@ -1089,10 +1198,6 @@ declare class LocalRelayMcpServer {
1089
1198
  * same tools does not trigger a needless remove+re-register cycle.
1090
1199
  */
1091
1200
  private toolSignature;
1092
- /**
1093
- * Logs tool sync errors with full detail.
1094
- */
1095
- private logSyncError;
1096
1201
  }
1097
1202
  //#endregion
1098
1203
  //#region src/naming.d.ts
@@ -1116,5 +1221,5 @@ declare function buildPublicToolName(options: {
1116
1221
  disambiguate?: boolean;
1117
1222
  }): string;
1118
1223
  //#endregion
1119
- export { type AggregatedTool, type BrowserToRelayMessage, BrowserToRelayMessageSchema, CallToolRequestParamsSchema, type CallToolResult, CallToolResultSchema, type CliOptions, DEFAULT_TOOL_INPUT_SCHEMA, HelloRequiredError, InboundToolSchema, LocalRelayMcpServer, type LocalRelayMcpServerOptions, NormalizedToolSchema, RelayBridgeServer, type RelayBridgeServerOptions, type RelayCallToolResult, type RelayClientToServerMessage, RelayClientToServerMessageSchema, type RelayDescriptor, RelayDescriptorSchema, type RelayHelloAcceptedMessage, RelayHelloAcceptedMessageSchema, type RelayHelloRejectedMessage, RelayHelloRejectedMessageSchema, type RelayInvokeArgs, RelayInvokeArgsSchema, RelayRegistry, type RelayServerToClientMessage, RelayServerToClientMessageSchema, type RelaySourceInfo, RelaySourceInfoSchema, type RelayToBrowserMessage, RelayToBrowserMessageSchema, type RelayTool, type RelayToolAnnotations, type ResolvedInvocation, type ServerHelloMessage, ServerHelloMessageSchema, type SourceInfo, type Tool, type ToolAnnotations, ToolAnnotationsSchema, ToolSchema, buildPublicToolName, extractSanitizedDomain, normalizeInboundTool, parseCliOptions, printHelp, sanitizeName };
1224
+ export { type AggregatedTool, type BrowserToRelayMessage, BrowserToRelayMessageSchema, CallToolRequestParamsSchema, CallToolResultSchema, type CliOptions, DEFAULT_TOOL_INPUT_SCHEMA, HelloRequiredError, InboundToolSchema, LocalRelayMcpServer, type LocalRelayMcpServerOptions, NormalizedToolSchema, RelayBridgeServer, type RelayBridgeServerOptions, type RelayCallToolResult, type RelayClientToServerMessage, RelayClientToServerMessageSchema, type RelayDescriptor, RelayDescriptorSchema, type RelayHelloAcceptedMessage, RelayHelloAcceptedMessageSchema, type RelayHelloRejectedMessage, RelayHelloRejectedMessageSchema, type RelayInvokeArgs, RelayInvokeArgsSchema, RelayRegistry, type RelayServerToClientMessage, RelayServerToClientMessageSchema, type RelaySourceInfo, RelaySourceInfoSchema, type RelayToBrowserMessage, RelayToBrowserMessageSchema, type RelayTool, type RelayToolAnnotations, type ResolvedInvocation, type ServerHelloMessage, ServerHelloMessageSchema, type SourceInfo, ToolAnnotationsSchema, ToolSchema, buildPublicToolName, extractSanitizedDomain, normalizeInboundTool, parseCliOptions, printHelp, sanitizeName };
1120
1225
  //# sourceMappingURL=index.d.mts.map