@frontmcp/plugin-webmcp 1.12.0 → 1.12.1

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/esm/index.mjs CHANGED
@@ -432,23 +432,32 @@ var LazyWebMcpTools = class {
432
432
  const placeholder = {
433
433
  fingerprint: fingerprintOf(tool, exposedTo),
434
434
  controller: new AbortController(),
435
- adopted: false
435
+ adopted: false,
436
+ exposedTo: exposedTo ?? []
436
437
  };
437
438
  this.placeholders.set(tool.name, placeholder);
438
439
  try {
439
440
  await this.modelContext.registerTool(
440
- { ...tool, execute: (input, options) => this.call(tool.name, input, options) },
441
+ { ...tool, execute: (input, options) => this.call(tool.name, placeholder, input, options) },
441
442
  { signal: placeholder.controller.signal, ...exposedTo && { exposedTo } }
442
443
  );
443
444
  } catch {
444
445
  this.release(tool.name, placeholder);
445
446
  }
446
447
  }
447
- async call(name, input, options) {
448
+ /**
449
+ * A call an agent made through a listed tool, run by the plugin once the server is loaded, unless the plugin no
450
+ * longer offers the tool to every origin the listed one was offered to: that call must come again through the
451
+ * plugin's own registration.
452
+ */
453
+ async call(name, placeholder, input, options) {
448
454
  await this.load();
449
- const execute = this.executors.get(name);
450
- if (!execute) throw new Error(`Tool "${name}" not found`);
451
- return execute(input, options);
455
+ const executor = this.executors.get(name);
456
+ if (!executor) throw new Error(`Tool "${name}" not found`);
457
+ if (!placeholder.exposedTo.every((origin) => executor.exposedTo.includes(origin))) {
458
+ throw new Error(`Tool "${name}" is no longer offered to every origin it was listed for: call it again`);
459
+ }
460
+ return executor.execute(input, options);
452
461
  }
453
462
  /** Load the server once; a failed load is tried again on the next call. */
454
463
  load() {
@@ -493,12 +502,13 @@ var LazyWebMcpTools = class {
493
502
  const { execute, ...descriptor } = tool;
494
503
  const placeholder = this.placeholders.get(tool.name);
495
504
  const kept = placeholder && !placeholder.adopted && placeholder.fingerprint === fingerprintOf(descriptor, options?.exposedTo) ? placeholder : void 0;
496
- this.executors.set(tool.name, execute);
505
+ const executor = { execute, exposedTo: options?.exposedTo ?? [] };
506
+ this.executors.set(tool.name, executor);
497
507
  options?.signal?.addEventListener(
498
508
  "abort",
499
509
  () => {
500
510
  if (attempt.failed) return;
501
- if (this.executors.get(tool.name) === execute) this.executors.delete(tool.name);
511
+ if (this.executors.get(tool.name) === executor) this.executors.delete(tool.name);
502
512
  if (kept) this.release(tool.name, kept);
503
513
  },
504
514
  { once: true }
package/esm/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-webmcp",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "WebMCP plugin for FrontMCP - expose an in-browser FrontMCP server's tools to browser agents through document.modelContext",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -60,14 +60,14 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@frontmcp/utils": "1.12.0"
63
+ "@frontmcp/utils": "1.12.1"
64
64
  },
65
65
  "peerDependencies": {
66
- "@frontmcp/lazy-zod": "1.12.0",
67
- "@frontmcp/sdk": "1.12.0"
66
+ "@frontmcp/lazy-zod": "1.12.1",
67
+ "@frontmcp/sdk": "1.12.1"
68
68
  },
69
69
  "devDependencies": {
70
- "@frontmcp/sdk": "1.12.0",
70
+ "@frontmcp/sdk": "1.12.1",
71
71
  "reflect-metadata": "^0.2.2"
72
72
  }
73
73
  }
package/esm/register.mjs CHANGED
@@ -59,23 +59,32 @@ var LazyWebMcpTools = class {
59
59
  const placeholder = {
60
60
  fingerprint: fingerprintOf(tool, exposedTo),
61
61
  controller: new AbortController(),
62
- adopted: false
62
+ adopted: false,
63
+ exposedTo: exposedTo ?? []
63
64
  };
64
65
  this.placeholders.set(tool.name, placeholder);
65
66
  try {
66
67
  await this.modelContext.registerTool(
67
- { ...tool, execute: (input, options) => this.call(tool.name, input, options) },
68
+ { ...tool, execute: (input, options) => this.call(tool.name, placeholder, input, options) },
68
69
  { signal: placeholder.controller.signal, ...exposedTo && { exposedTo } }
69
70
  );
70
71
  } catch {
71
72
  this.release(tool.name, placeholder);
72
73
  }
73
74
  }
74
- async call(name, input, options) {
75
+ /**
76
+ * A call an agent made through a listed tool, run by the plugin once the server is loaded, unless the plugin no
77
+ * longer offers the tool to every origin the listed one was offered to: that call must come again through the
78
+ * plugin's own registration.
79
+ */
80
+ async call(name, placeholder, input, options) {
75
81
  await this.load();
76
- const execute = this.executors.get(name);
77
- if (!execute) throw new Error(`Tool "${name}" not found`);
78
- return execute(input, options);
82
+ const executor = this.executors.get(name);
83
+ if (!executor) throw new Error(`Tool "${name}" not found`);
84
+ if (!placeholder.exposedTo.every((origin) => executor.exposedTo.includes(origin))) {
85
+ throw new Error(`Tool "${name}" is no longer offered to every origin it was listed for: call it again`);
86
+ }
87
+ return executor.execute(input, options);
79
88
  }
80
89
  /** Load the server once; a failed load is tried again on the next call. */
81
90
  load() {
@@ -120,12 +129,13 @@ var LazyWebMcpTools = class {
120
129
  const { execute, ...descriptor } = tool;
121
130
  const placeholder = this.placeholders.get(tool.name);
122
131
  const kept = placeholder && !placeholder.adopted && placeholder.fingerprint === fingerprintOf(descriptor, options?.exposedTo) ? placeholder : void 0;
123
- this.executors.set(tool.name, execute);
132
+ const executor = { execute, exposedTo: options?.exposedTo ?? [] };
133
+ this.executors.set(tool.name, executor);
124
134
  options?.signal?.addEventListener(
125
135
  "abort",
126
136
  () => {
127
137
  if (attempt.failed) return;
128
- if (this.executors.get(tool.name) === execute) this.executors.delete(tool.name);
138
+ if (this.executors.get(tool.name) === executor) this.executors.delete(tool.name);
129
139
  if (kept) this.release(tool.name, kept);
130
140
  },
131
141
  { once: true }
package/index.js CHANGED
@@ -460,23 +460,32 @@ var LazyWebMcpTools = class {
460
460
  const placeholder = {
461
461
  fingerprint: fingerprintOf(tool, exposedTo),
462
462
  controller: new AbortController(),
463
- adopted: false
463
+ adopted: false,
464
+ exposedTo: exposedTo ?? []
464
465
  };
465
466
  this.placeholders.set(tool.name, placeholder);
466
467
  try {
467
468
  await this.modelContext.registerTool(
468
- { ...tool, execute: (input, options) => this.call(tool.name, input, options) },
469
+ { ...tool, execute: (input, options) => this.call(tool.name, placeholder, input, options) },
469
470
  { signal: placeholder.controller.signal, ...exposedTo && { exposedTo } }
470
471
  );
471
472
  } catch {
472
473
  this.release(tool.name, placeholder);
473
474
  }
474
475
  }
475
- async call(name, input, options) {
476
+ /**
477
+ * A call an agent made through a listed tool, run by the plugin once the server is loaded, unless the plugin no
478
+ * longer offers the tool to every origin the listed one was offered to: that call must come again through the
479
+ * plugin's own registration.
480
+ */
481
+ async call(name, placeholder, input, options) {
476
482
  await this.load();
477
- const execute = this.executors.get(name);
478
- if (!execute) throw new Error(`Tool "${name}" not found`);
479
- return execute(input, options);
483
+ const executor = this.executors.get(name);
484
+ if (!executor) throw new Error(`Tool "${name}" not found`);
485
+ if (!placeholder.exposedTo.every((origin) => executor.exposedTo.includes(origin))) {
486
+ throw new Error(`Tool "${name}" is no longer offered to every origin it was listed for: call it again`);
487
+ }
488
+ return executor.execute(input, options);
480
489
  }
481
490
  /** Load the server once; a failed load is tried again on the next call. */
482
491
  load() {
@@ -521,12 +530,13 @@ var LazyWebMcpTools = class {
521
530
  const { execute, ...descriptor } = tool;
522
531
  const placeholder = this.placeholders.get(tool.name);
523
532
  const kept = placeholder && !placeholder.adopted && placeholder.fingerprint === fingerprintOf(descriptor, options?.exposedTo) ? placeholder : void 0;
524
- this.executors.set(tool.name, execute);
533
+ const executor = { execute, exposedTo: options?.exposedTo ?? [] };
534
+ this.executors.set(tool.name, executor);
525
535
  options?.signal?.addEventListener(
526
536
  "abort",
527
537
  () => {
528
538
  if (attempt.failed) return;
529
- if (this.executors.get(tool.name) === execute) this.executors.delete(tool.name);
539
+ if (this.executors.get(tool.name) === executor) this.executors.delete(tool.name);
530
540
  if (kept) this.release(tool.name, kept);
531
541
  },
532
542
  { once: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-webmcp",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "WebMCP plugin for FrontMCP - expose an in-browser FrontMCP server's tools to browser agents through document.modelContext",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -60,14 +60,14 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@frontmcp/utils": "1.12.0"
63
+ "@frontmcp/utils": "1.12.1"
64
64
  },
65
65
  "peerDependencies": {
66
- "@frontmcp/lazy-zod": "1.12.0",
67
- "@frontmcp/sdk": "1.12.0"
66
+ "@frontmcp/lazy-zod": "1.12.1",
67
+ "@frontmcp/sdk": "1.12.1"
68
68
  },
69
69
  "devDependencies": {
70
- "@frontmcp/sdk": "1.12.0",
70
+ "@frontmcp/sdk": "1.12.1",
71
71
  "reflect-metadata": "^0.2.2"
72
72
  }
73
73
  }
package/register.js CHANGED
@@ -87,23 +87,32 @@ var LazyWebMcpTools = class {
87
87
  const placeholder = {
88
88
  fingerprint: fingerprintOf(tool, exposedTo),
89
89
  controller: new AbortController(),
90
- adopted: false
90
+ adopted: false,
91
+ exposedTo: exposedTo ?? []
91
92
  };
92
93
  this.placeholders.set(tool.name, placeholder);
93
94
  try {
94
95
  await this.modelContext.registerTool(
95
- { ...tool, execute: (input, options) => this.call(tool.name, input, options) },
96
+ { ...tool, execute: (input, options) => this.call(tool.name, placeholder, input, options) },
96
97
  { signal: placeholder.controller.signal, ...exposedTo && { exposedTo } }
97
98
  );
98
99
  } catch {
99
100
  this.release(tool.name, placeholder);
100
101
  }
101
102
  }
102
- async call(name, input, options) {
103
+ /**
104
+ * A call an agent made through a listed tool, run by the plugin once the server is loaded, unless the plugin no
105
+ * longer offers the tool to every origin the listed one was offered to: that call must come again through the
106
+ * plugin's own registration.
107
+ */
108
+ async call(name, placeholder, input, options) {
103
109
  await this.load();
104
- const execute = this.executors.get(name);
105
- if (!execute) throw new Error(`Tool "${name}" not found`);
106
- return execute(input, options);
110
+ const executor = this.executors.get(name);
111
+ if (!executor) throw new Error(`Tool "${name}" not found`);
112
+ if (!placeholder.exposedTo.every((origin) => executor.exposedTo.includes(origin))) {
113
+ throw new Error(`Tool "${name}" is no longer offered to every origin it was listed for: call it again`);
114
+ }
115
+ return executor.execute(input, options);
107
116
  }
108
117
  /** Load the server once; a failed load is tried again on the next call. */
109
118
  load() {
@@ -148,12 +157,13 @@ var LazyWebMcpTools = class {
148
157
  const { execute, ...descriptor } = tool;
149
158
  const placeholder = this.placeholders.get(tool.name);
150
159
  const kept = placeholder && !placeholder.adopted && placeholder.fingerprint === fingerprintOf(descriptor, options?.exposedTo) ? placeholder : void 0;
151
- this.executors.set(tool.name, execute);
160
+ const executor = { execute, exposedTo: options?.exposedTo ?? [] };
161
+ this.executors.set(tool.name, executor);
152
162
  options?.signal?.addEventListener(
153
163
  "abort",
154
164
  () => {
155
165
  if (attempt.failed) return;
156
- if (this.executors.get(tool.name) === execute) this.executors.delete(tool.name);
166
+ if (this.executors.get(tool.name) === executor) this.executors.delete(tool.name);
157
167
  if (kept) this.release(tool.name, kept);
158
168
  },
159
169
  { once: true }
@@ -1 +1 @@
1
- {"version":3,"file":"webmcp.lazy.d.ts","sourceRoot":"","sources":["../src/webmcp.lazy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,YAAY,EAEZ,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAExB,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,GAAG,OAAO,IAAI,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEpG,0CAA0C;AAC1C,MAAM,WAAW,0BAA0B;IACzC,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAyCD;;;;;;;;;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