@mcp-weave/webui 0.1.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/dist/index.mjs ADDED
@@ -0,0 +1,2189 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
28
+ var require_Reflect = __commonJS({
29
+ "../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js"() {
30
+ "use strict";
31
+ var Reflect2;
32
+ (function(Reflect3) {
33
+ (function(factory) {
34
+ var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
35
+ var exporter = makeExporter(Reflect3);
36
+ if (typeof root.Reflect !== "undefined") {
37
+ exporter = makeExporter(root.Reflect, exporter);
38
+ }
39
+ factory(exporter, root);
40
+ if (typeof root.Reflect === "undefined") {
41
+ root.Reflect = Reflect3;
42
+ }
43
+ function makeExporter(target, previous) {
44
+ return function(key, value) {
45
+ Object.defineProperty(target, key, { configurable: true, writable: true, value });
46
+ if (previous)
47
+ previous(key, value);
48
+ };
49
+ }
50
+ function functionThis() {
51
+ try {
52
+ return Function("return this;")();
53
+ } catch (_) {
54
+ }
55
+ }
56
+ function indirectEvalThis() {
57
+ try {
58
+ return (void 0, eval)("(function() { return this; })()");
59
+ } catch (_) {
60
+ }
61
+ }
62
+ function sloppyModeThis() {
63
+ return functionThis() || indirectEvalThis();
64
+ }
65
+ })(function(exporter, root) {
66
+ var hasOwn = Object.prototype.hasOwnProperty;
67
+ var supportsSymbol = typeof Symbol === "function";
68
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
69
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
70
+ var supportsCreate = typeof Object.create === "function";
71
+ var supportsProto = { __proto__: [] } instanceof Array;
72
+ var downLevel = !supportsCreate && !supportsProto;
73
+ var HashMap = {
74
+ // create an object in dictionary mode (a.k.a. "slow" mode in v8)
75
+ create: supportsCreate ? function() {
76
+ return MakeDictionary(/* @__PURE__ */ Object.create(null));
77
+ } : supportsProto ? function() {
78
+ return MakeDictionary({ __proto__: null });
79
+ } : function() {
80
+ return MakeDictionary({});
81
+ },
82
+ has: downLevel ? function(map, key) {
83
+ return hasOwn.call(map, key);
84
+ } : function(map, key) {
85
+ return key in map;
86
+ },
87
+ get: downLevel ? function(map, key) {
88
+ return hasOwn.call(map, key) ? map[key] : void 0;
89
+ } : function(map, key) {
90
+ return map[key];
91
+ }
92
+ };
93
+ var functionPrototype = Object.getPrototypeOf(Function);
94
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
95
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
96
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
97
+ var registrySymbol = supportsSymbol ? /* @__PURE__ */ Symbol.for("@reflect-metadata:registry") : void 0;
98
+ var metadataRegistry = GetOrCreateMetadataRegistry();
99
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
100
+ function decorate(decorators, target, propertyKey, attributes) {
101
+ if (!IsUndefined(propertyKey)) {
102
+ if (!IsArray(decorators))
103
+ throw new TypeError();
104
+ if (!IsObject(target))
105
+ throw new TypeError();
106
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
107
+ throw new TypeError();
108
+ if (IsNull(attributes))
109
+ attributes = void 0;
110
+ propertyKey = ToPropertyKey(propertyKey);
111
+ return DecorateProperty(decorators, target, propertyKey, attributes);
112
+ } else {
113
+ if (!IsArray(decorators))
114
+ throw new TypeError();
115
+ if (!IsConstructor(target))
116
+ throw new TypeError();
117
+ return DecorateConstructor(decorators, target);
118
+ }
119
+ }
120
+ exporter("decorate", decorate);
121
+ function metadata(metadataKey, metadataValue) {
122
+ function decorator(target, propertyKey) {
123
+ if (!IsObject(target))
124
+ throw new TypeError();
125
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
126
+ throw new TypeError();
127
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
128
+ }
129
+ return decorator;
130
+ }
131
+ exporter("metadata", metadata);
132
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
133
+ if (!IsObject(target))
134
+ throw new TypeError();
135
+ if (!IsUndefined(propertyKey))
136
+ propertyKey = ToPropertyKey(propertyKey);
137
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
138
+ }
139
+ exporter("defineMetadata", defineMetadata);
140
+ function hasMetadata(metadataKey, target, propertyKey) {
141
+ if (!IsObject(target))
142
+ throw new TypeError();
143
+ if (!IsUndefined(propertyKey))
144
+ propertyKey = ToPropertyKey(propertyKey);
145
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
146
+ }
147
+ exporter("hasMetadata", hasMetadata);
148
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
149
+ if (!IsObject(target))
150
+ throw new TypeError();
151
+ if (!IsUndefined(propertyKey))
152
+ propertyKey = ToPropertyKey(propertyKey);
153
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
154
+ }
155
+ exporter("hasOwnMetadata", hasOwnMetadata);
156
+ function getMetadata(metadataKey, target, propertyKey) {
157
+ if (!IsObject(target))
158
+ throw new TypeError();
159
+ if (!IsUndefined(propertyKey))
160
+ propertyKey = ToPropertyKey(propertyKey);
161
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
162
+ }
163
+ exporter("getMetadata", getMetadata);
164
+ function getOwnMetadata(metadataKey, target, propertyKey) {
165
+ if (!IsObject(target))
166
+ throw new TypeError();
167
+ if (!IsUndefined(propertyKey))
168
+ propertyKey = ToPropertyKey(propertyKey);
169
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
170
+ }
171
+ exporter("getOwnMetadata", getOwnMetadata);
172
+ function getMetadataKeys(target, propertyKey) {
173
+ if (!IsObject(target))
174
+ throw new TypeError();
175
+ if (!IsUndefined(propertyKey))
176
+ propertyKey = ToPropertyKey(propertyKey);
177
+ return OrdinaryMetadataKeys(target, propertyKey);
178
+ }
179
+ exporter("getMetadataKeys", getMetadataKeys);
180
+ function getOwnMetadataKeys(target, propertyKey) {
181
+ if (!IsObject(target))
182
+ throw new TypeError();
183
+ if (!IsUndefined(propertyKey))
184
+ propertyKey = ToPropertyKey(propertyKey);
185
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
186
+ }
187
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
188
+ function deleteMetadata(metadataKey, target, propertyKey) {
189
+ if (!IsObject(target))
190
+ throw new TypeError();
191
+ if (!IsUndefined(propertyKey))
192
+ propertyKey = ToPropertyKey(propertyKey);
193
+ if (!IsObject(target))
194
+ throw new TypeError();
195
+ if (!IsUndefined(propertyKey))
196
+ propertyKey = ToPropertyKey(propertyKey);
197
+ var provider = GetMetadataProvider(
198
+ target,
199
+ propertyKey,
200
+ /*Create*/
201
+ false
202
+ );
203
+ if (IsUndefined(provider))
204
+ return false;
205
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
206
+ }
207
+ exporter("deleteMetadata", deleteMetadata);
208
+ function DecorateConstructor(decorators, target) {
209
+ for (var i = decorators.length - 1; i >= 0; --i) {
210
+ var decorator = decorators[i];
211
+ var decorated = decorator(target);
212
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
213
+ if (!IsConstructor(decorated))
214
+ throw new TypeError();
215
+ target = decorated;
216
+ }
217
+ }
218
+ return target;
219
+ }
220
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
221
+ for (var i = decorators.length - 1; i >= 0; --i) {
222
+ var decorator = decorators[i];
223
+ var decorated = decorator(target, propertyKey, descriptor);
224
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
225
+ if (!IsObject(decorated))
226
+ throw new TypeError();
227
+ descriptor = decorated;
228
+ }
229
+ }
230
+ return descriptor;
231
+ }
232
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
233
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
234
+ if (hasOwn2)
235
+ return true;
236
+ var parent = OrdinaryGetPrototypeOf(O);
237
+ if (!IsNull(parent))
238
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
239
+ return false;
240
+ }
241
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
242
+ var provider = GetMetadataProvider(
243
+ O,
244
+ P,
245
+ /*Create*/
246
+ false
247
+ );
248
+ if (IsUndefined(provider))
249
+ return false;
250
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
251
+ }
252
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
253
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
254
+ if (hasOwn2)
255
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
256
+ var parent = OrdinaryGetPrototypeOf(O);
257
+ if (!IsNull(parent))
258
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
259
+ return void 0;
260
+ }
261
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
262
+ var provider = GetMetadataProvider(
263
+ O,
264
+ P,
265
+ /*Create*/
266
+ false
267
+ );
268
+ if (IsUndefined(provider))
269
+ return;
270
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
271
+ }
272
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
273
+ var provider = GetMetadataProvider(
274
+ O,
275
+ P,
276
+ /*Create*/
277
+ true
278
+ );
279
+ provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
280
+ }
281
+ function OrdinaryMetadataKeys(O, P) {
282
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
283
+ var parent = OrdinaryGetPrototypeOf(O);
284
+ if (parent === null)
285
+ return ownKeys;
286
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
287
+ if (parentKeys.length <= 0)
288
+ return ownKeys;
289
+ if (ownKeys.length <= 0)
290
+ return parentKeys;
291
+ var set = new _Set();
292
+ var keys = [];
293
+ for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
294
+ var key = ownKeys_1[_i];
295
+ var hasKey = set.has(key);
296
+ if (!hasKey) {
297
+ set.add(key);
298
+ keys.push(key);
299
+ }
300
+ }
301
+ for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
302
+ var key = parentKeys_1[_a];
303
+ var hasKey = set.has(key);
304
+ if (!hasKey) {
305
+ set.add(key);
306
+ keys.push(key);
307
+ }
308
+ }
309
+ return keys;
310
+ }
311
+ function OrdinaryOwnMetadataKeys(O, P) {
312
+ var provider = GetMetadataProvider(
313
+ O,
314
+ P,
315
+ /*create*/
316
+ false
317
+ );
318
+ if (!provider) {
319
+ return [];
320
+ }
321
+ return provider.OrdinaryOwnMetadataKeys(O, P);
322
+ }
323
+ function Type(x) {
324
+ if (x === null)
325
+ return 1;
326
+ switch (typeof x) {
327
+ case "undefined":
328
+ return 0;
329
+ case "boolean":
330
+ return 2;
331
+ case "string":
332
+ return 3;
333
+ case "symbol":
334
+ return 4;
335
+ case "number":
336
+ return 5;
337
+ case "object":
338
+ return x === null ? 1 : 6;
339
+ default:
340
+ return 6;
341
+ }
342
+ }
343
+ function IsUndefined(x) {
344
+ return x === void 0;
345
+ }
346
+ function IsNull(x) {
347
+ return x === null;
348
+ }
349
+ function IsSymbol(x) {
350
+ return typeof x === "symbol";
351
+ }
352
+ function IsObject(x) {
353
+ return typeof x === "object" ? x !== null : typeof x === "function";
354
+ }
355
+ function ToPrimitive(input, PreferredType) {
356
+ switch (Type(input)) {
357
+ case 0:
358
+ return input;
359
+ case 1:
360
+ return input;
361
+ case 2:
362
+ return input;
363
+ case 3:
364
+ return input;
365
+ case 4:
366
+ return input;
367
+ case 5:
368
+ return input;
369
+ }
370
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
371
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
372
+ if (exoticToPrim !== void 0) {
373
+ var result = exoticToPrim.call(input, hint);
374
+ if (IsObject(result))
375
+ throw new TypeError();
376
+ return result;
377
+ }
378
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
379
+ }
380
+ function OrdinaryToPrimitive(O, hint) {
381
+ if (hint === "string") {
382
+ var toString_1 = O.toString;
383
+ if (IsCallable(toString_1)) {
384
+ var result = toString_1.call(O);
385
+ if (!IsObject(result))
386
+ return result;
387
+ }
388
+ var valueOf = O.valueOf;
389
+ if (IsCallable(valueOf)) {
390
+ var result = valueOf.call(O);
391
+ if (!IsObject(result))
392
+ return result;
393
+ }
394
+ } else {
395
+ var valueOf = O.valueOf;
396
+ if (IsCallable(valueOf)) {
397
+ var result = valueOf.call(O);
398
+ if (!IsObject(result))
399
+ return result;
400
+ }
401
+ var toString_2 = O.toString;
402
+ if (IsCallable(toString_2)) {
403
+ var result = toString_2.call(O);
404
+ if (!IsObject(result))
405
+ return result;
406
+ }
407
+ }
408
+ throw new TypeError();
409
+ }
410
+ function ToBoolean(argument) {
411
+ return !!argument;
412
+ }
413
+ function ToString(argument) {
414
+ return "" + argument;
415
+ }
416
+ function ToPropertyKey(argument) {
417
+ var key = ToPrimitive(
418
+ argument,
419
+ 3
420
+ /* String */
421
+ );
422
+ if (IsSymbol(key))
423
+ return key;
424
+ return ToString(key);
425
+ }
426
+ function IsArray(argument) {
427
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
428
+ }
429
+ function IsCallable(argument) {
430
+ return typeof argument === "function";
431
+ }
432
+ function IsConstructor(argument) {
433
+ return typeof argument === "function";
434
+ }
435
+ function IsPropertyKey(argument) {
436
+ switch (Type(argument)) {
437
+ case 3:
438
+ return true;
439
+ case 4:
440
+ return true;
441
+ default:
442
+ return false;
443
+ }
444
+ }
445
+ function SameValueZero(x, y) {
446
+ return x === y || x !== x && y !== y;
447
+ }
448
+ function GetMethod(V, P) {
449
+ var func = V[P];
450
+ if (func === void 0 || func === null)
451
+ return void 0;
452
+ if (!IsCallable(func))
453
+ throw new TypeError();
454
+ return func;
455
+ }
456
+ function GetIterator(obj) {
457
+ var method = GetMethod(obj, iteratorSymbol);
458
+ if (!IsCallable(method))
459
+ throw new TypeError();
460
+ var iterator = method.call(obj);
461
+ if (!IsObject(iterator))
462
+ throw new TypeError();
463
+ return iterator;
464
+ }
465
+ function IteratorValue(iterResult) {
466
+ return iterResult.value;
467
+ }
468
+ function IteratorStep(iterator) {
469
+ var result = iterator.next();
470
+ return result.done ? false : result;
471
+ }
472
+ function IteratorClose(iterator) {
473
+ var f = iterator["return"];
474
+ if (f)
475
+ f.call(iterator);
476
+ }
477
+ function OrdinaryGetPrototypeOf(O) {
478
+ var proto = Object.getPrototypeOf(O);
479
+ if (typeof O !== "function" || O === functionPrototype)
480
+ return proto;
481
+ if (proto !== functionPrototype)
482
+ return proto;
483
+ var prototype = O.prototype;
484
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
485
+ if (prototypeProto == null || prototypeProto === Object.prototype)
486
+ return proto;
487
+ var constructor = prototypeProto.constructor;
488
+ if (typeof constructor !== "function")
489
+ return proto;
490
+ if (constructor === O)
491
+ return proto;
492
+ return constructor;
493
+ }
494
+ function CreateMetadataRegistry() {
495
+ var fallback;
496
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
497
+ fallback = CreateFallbackProvider(root.Reflect);
498
+ }
499
+ var first;
500
+ var second;
501
+ var rest;
502
+ var targetProviderMap = new _WeakMap();
503
+ var registry = {
504
+ registerProvider,
505
+ getProvider,
506
+ setProvider
507
+ };
508
+ return registry;
509
+ function registerProvider(provider) {
510
+ if (!Object.isExtensible(registry)) {
511
+ throw new Error("Cannot add provider to a frozen registry.");
512
+ }
513
+ switch (true) {
514
+ case fallback === provider:
515
+ break;
516
+ case IsUndefined(first):
517
+ first = provider;
518
+ break;
519
+ case first === provider:
520
+ break;
521
+ case IsUndefined(second):
522
+ second = provider;
523
+ break;
524
+ case second === provider:
525
+ break;
526
+ default:
527
+ if (rest === void 0)
528
+ rest = new _Set();
529
+ rest.add(provider);
530
+ break;
531
+ }
532
+ }
533
+ function getProviderNoCache(O, P) {
534
+ if (!IsUndefined(first)) {
535
+ if (first.isProviderFor(O, P))
536
+ return first;
537
+ if (!IsUndefined(second)) {
538
+ if (second.isProviderFor(O, P))
539
+ return first;
540
+ if (!IsUndefined(rest)) {
541
+ var iterator = GetIterator(rest);
542
+ while (true) {
543
+ var next = IteratorStep(iterator);
544
+ if (!next) {
545
+ return void 0;
546
+ }
547
+ var provider = IteratorValue(next);
548
+ if (provider.isProviderFor(O, P)) {
549
+ IteratorClose(iterator);
550
+ return provider;
551
+ }
552
+ }
553
+ }
554
+ }
555
+ }
556
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
557
+ return fallback;
558
+ }
559
+ return void 0;
560
+ }
561
+ function getProvider(O, P) {
562
+ var providerMap = targetProviderMap.get(O);
563
+ var provider;
564
+ if (!IsUndefined(providerMap)) {
565
+ provider = providerMap.get(P);
566
+ }
567
+ if (!IsUndefined(provider)) {
568
+ return provider;
569
+ }
570
+ provider = getProviderNoCache(O, P);
571
+ if (!IsUndefined(provider)) {
572
+ if (IsUndefined(providerMap)) {
573
+ providerMap = new _Map();
574
+ targetProviderMap.set(O, providerMap);
575
+ }
576
+ providerMap.set(P, provider);
577
+ }
578
+ return provider;
579
+ }
580
+ function hasProvider(provider) {
581
+ if (IsUndefined(provider))
582
+ throw new TypeError();
583
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
584
+ }
585
+ function setProvider(O, P, provider) {
586
+ if (!hasProvider(provider)) {
587
+ throw new Error("Metadata provider not registered.");
588
+ }
589
+ var existingProvider = getProvider(O, P);
590
+ if (existingProvider !== provider) {
591
+ if (!IsUndefined(existingProvider)) {
592
+ return false;
593
+ }
594
+ var providerMap = targetProviderMap.get(O);
595
+ if (IsUndefined(providerMap)) {
596
+ providerMap = new _Map();
597
+ targetProviderMap.set(O, providerMap);
598
+ }
599
+ providerMap.set(P, provider);
600
+ }
601
+ return true;
602
+ }
603
+ }
604
+ function GetOrCreateMetadataRegistry() {
605
+ var metadataRegistry2;
606
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
607
+ metadataRegistry2 = root.Reflect[registrySymbol];
608
+ }
609
+ if (IsUndefined(metadataRegistry2)) {
610
+ metadataRegistry2 = CreateMetadataRegistry();
611
+ }
612
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
613
+ Object.defineProperty(root.Reflect, registrySymbol, {
614
+ enumerable: false,
615
+ configurable: false,
616
+ writable: false,
617
+ value: metadataRegistry2
618
+ });
619
+ }
620
+ return metadataRegistry2;
621
+ }
622
+ function CreateMetadataProvider(registry) {
623
+ var metadata2 = new _WeakMap();
624
+ var provider = {
625
+ isProviderFor: function(O, P) {
626
+ var targetMetadata = metadata2.get(O);
627
+ if (IsUndefined(targetMetadata))
628
+ return false;
629
+ return targetMetadata.has(P);
630
+ },
631
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
632
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
633
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
634
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
635
+ OrdinaryDeleteMetadata
636
+ };
637
+ metadataRegistry.registerProvider(provider);
638
+ return provider;
639
+ function GetOrCreateMetadataMap(O, P, Create) {
640
+ var targetMetadata = metadata2.get(O);
641
+ var createdTargetMetadata = false;
642
+ if (IsUndefined(targetMetadata)) {
643
+ if (!Create)
644
+ return void 0;
645
+ targetMetadata = new _Map();
646
+ metadata2.set(O, targetMetadata);
647
+ createdTargetMetadata = true;
648
+ }
649
+ var metadataMap = targetMetadata.get(P);
650
+ if (IsUndefined(metadataMap)) {
651
+ if (!Create)
652
+ return void 0;
653
+ metadataMap = new _Map();
654
+ targetMetadata.set(P, metadataMap);
655
+ if (!registry.setProvider(O, P, provider)) {
656
+ targetMetadata.delete(P);
657
+ if (createdTargetMetadata) {
658
+ metadata2.delete(O);
659
+ }
660
+ throw new Error("Wrong provider for target.");
661
+ }
662
+ }
663
+ return metadataMap;
664
+ }
665
+ function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
666
+ var metadataMap = GetOrCreateMetadataMap(
667
+ O,
668
+ P,
669
+ /*Create*/
670
+ false
671
+ );
672
+ if (IsUndefined(metadataMap))
673
+ return false;
674
+ return ToBoolean(metadataMap.has(MetadataKey));
675
+ }
676
+ function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
677
+ var metadataMap = GetOrCreateMetadataMap(
678
+ O,
679
+ P,
680
+ /*Create*/
681
+ false
682
+ );
683
+ if (IsUndefined(metadataMap))
684
+ return void 0;
685
+ return metadataMap.get(MetadataKey);
686
+ }
687
+ function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
688
+ var metadataMap = GetOrCreateMetadataMap(
689
+ O,
690
+ P,
691
+ /*Create*/
692
+ true
693
+ );
694
+ metadataMap.set(MetadataKey, MetadataValue);
695
+ }
696
+ function OrdinaryOwnMetadataKeys2(O, P) {
697
+ var keys = [];
698
+ var metadataMap = GetOrCreateMetadataMap(
699
+ O,
700
+ P,
701
+ /*Create*/
702
+ false
703
+ );
704
+ if (IsUndefined(metadataMap))
705
+ return keys;
706
+ var keysObj = metadataMap.keys();
707
+ var iterator = GetIterator(keysObj);
708
+ var k = 0;
709
+ while (true) {
710
+ var next = IteratorStep(iterator);
711
+ if (!next) {
712
+ keys.length = k;
713
+ return keys;
714
+ }
715
+ var nextValue = IteratorValue(next);
716
+ try {
717
+ keys[k] = nextValue;
718
+ } catch (e) {
719
+ try {
720
+ IteratorClose(iterator);
721
+ } finally {
722
+ throw e;
723
+ }
724
+ }
725
+ k++;
726
+ }
727
+ }
728
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
729
+ var metadataMap = GetOrCreateMetadataMap(
730
+ O,
731
+ P,
732
+ /*Create*/
733
+ false
734
+ );
735
+ if (IsUndefined(metadataMap))
736
+ return false;
737
+ if (!metadataMap.delete(MetadataKey))
738
+ return false;
739
+ if (metadataMap.size === 0) {
740
+ var targetMetadata = metadata2.get(O);
741
+ if (!IsUndefined(targetMetadata)) {
742
+ targetMetadata.delete(P);
743
+ if (targetMetadata.size === 0) {
744
+ metadata2.delete(targetMetadata);
745
+ }
746
+ }
747
+ }
748
+ return true;
749
+ }
750
+ }
751
+ function CreateFallbackProvider(reflect) {
752
+ var defineMetadata2 = reflect.defineMetadata, hasOwnMetadata2 = reflect.hasOwnMetadata, getOwnMetadata2 = reflect.getOwnMetadata, getOwnMetadataKeys2 = reflect.getOwnMetadataKeys, deleteMetadata2 = reflect.deleteMetadata;
753
+ var metadataOwner = new _WeakMap();
754
+ var provider = {
755
+ isProviderFor: function(O, P) {
756
+ var metadataPropertySet = metadataOwner.get(O);
757
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
758
+ return true;
759
+ }
760
+ if (getOwnMetadataKeys2(O, P).length) {
761
+ if (IsUndefined(metadataPropertySet)) {
762
+ metadataPropertySet = new _Set();
763
+ metadataOwner.set(O, metadataPropertySet);
764
+ }
765
+ metadataPropertySet.add(P);
766
+ return true;
767
+ }
768
+ return false;
769
+ },
770
+ OrdinaryDefineOwnMetadata: defineMetadata2,
771
+ OrdinaryHasOwnMetadata: hasOwnMetadata2,
772
+ OrdinaryGetOwnMetadata: getOwnMetadata2,
773
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
774
+ OrdinaryDeleteMetadata: deleteMetadata2
775
+ };
776
+ return provider;
777
+ }
778
+ function GetMetadataProvider(O, P, Create) {
779
+ var registeredProvider = metadataRegistry.getProvider(O, P);
780
+ if (!IsUndefined(registeredProvider)) {
781
+ return registeredProvider;
782
+ }
783
+ if (Create) {
784
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) {
785
+ return metadataProvider;
786
+ }
787
+ throw new Error("Illegal state.");
788
+ }
789
+ return void 0;
790
+ }
791
+ function CreateMapPolyfill() {
792
+ var cacheSentinel = {};
793
+ var arraySentinel = [];
794
+ var MapIterator = (
795
+ /** @class */
796
+ (function() {
797
+ function MapIterator2(keys, values, selector) {
798
+ this._index = 0;
799
+ this._keys = keys;
800
+ this._values = values;
801
+ this._selector = selector;
802
+ }
803
+ MapIterator2.prototype["@@iterator"] = function() {
804
+ return this;
805
+ };
806
+ MapIterator2.prototype[iteratorSymbol] = function() {
807
+ return this;
808
+ };
809
+ MapIterator2.prototype.next = function() {
810
+ var index = this._index;
811
+ if (index >= 0 && index < this._keys.length) {
812
+ var result = this._selector(this._keys[index], this._values[index]);
813
+ if (index + 1 >= this._keys.length) {
814
+ this._index = -1;
815
+ this._keys = arraySentinel;
816
+ this._values = arraySentinel;
817
+ } else {
818
+ this._index++;
819
+ }
820
+ return { value: result, done: false };
821
+ }
822
+ return { value: void 0, done: true };
823
+ };
824
+ MapIterator2.prototype.throw = function(error) {
825
+ if (this._index >= 0) {
826
+ this._index = -1;
827
+ this._keys = arraySentinel;
828
+ this._values = arraySentinel;
829
+ }
830
+ throw error;
831
+ };
832
+ MapIterator2.prototype.return = function(value) {
833
+ if (this._index >= 0) {
834
+ this._index = -1;
835
+ this._keys = arraySentinel;
836
+ this._values = arraySentinel;
837
+ }
838
+ return { value, done: true };
839
+ };
840
+ return MapIterator2;
841
+ })()
842
+ );
843
+ var Map2 = (
844
+ /** @class */
845
+ (function() {
846
+ function Map3() {
847
+ this._keys = [];
848
+ this._values = [];
849
+ this._cacheKey = cacheSentinel;
850
+ this._cacheIndex = -2;
851
+ }
852
+ Object.defineProperty(Map3.prototype, "size", {
853
+ get: function() {
854
+ return this._keys.length;
855
+ },
856
+ enumerable: true,
857
+ configurable: true
858
+ });
859
+ Map3.prototype.has = function(key) {
860
+ return this._find(
861
+ key,
862
+ /*insert*/
863
+ false
864
+ ) >= 0;
865
+ };
866
+ Map3.prototype.get = function(key) {
867
+ var index = this._find(
868
+ key,
869
+ /*insert*/
870
+ false
871
+ );
872
+ return index >= 0 ? this._values[index] : void 0;
873
+ };
874
+ Map3.prototype.set = function(key, value) {
875
+ var index = this._find(
876
+ key,
877
+ /*insert*/
878
+ true
879
+ );
880
+ this._values[index] = value;
881
+ return this;
882
+ };
883
+ Map3.prototype.delete = function(key) {
884
+ var index = this._find(
885
+ key,
886
+ /*insert*/
887
+ false
888
+ );
889
+ if (index >= 0) {
890
+ var size = this._keys.length;
891
+ for (var i = index + 1; i < size; i++) {
892
+ this._keys[i - 1] = this._keys[i];
893
+ this._values[i - 1] = this._values[i];
894
+ }
895
+ this._keys.length--;
896
+ this._values.length--;
897
+ if (SameValueZero(key, this._cacheKey)) {
898
+ this._cacheKey = cacheSentinel;
899
+ this._cacheIndex = -2;
900
+ }
901
+ return true;
902
+ }
903
+ return false;
904
+ };
905
+ Map3.prototype.clear = function() {
906
+ this._keys.length = 0;
907
+ this._values.length = 0;
908
+ this._cacheKey = cacheSentinel;
909
+ this._cacheIndex = -2;
910
+ };
911
+ Map3.prototype.keys = function() {
912
+ return new MapIterator(this._keys, this._values, getKey);
913
+ };
914
+ Map3.prototype.values = function() {
915
+ return new MapIterator(this._keys, this._values, getValue);
916
+ };
917
+ Map3.prototype.entries = function() {
918
+ return new MapIterator(this._keys, this._values, getEntry);
919
+ };
920
+ Map3.prototype["@@iterator"] = function() {
921
+ return this.entries();
922
+ };
923
+ Map3.prototype[iteratorSymbol] = function() {
924
+ return this.entries();
925
+ };
926
+ Map3.prototype._find = function(key, insert) {
927
+ if (!SameValueZero(this._cacheKey, key)) {
928
+ this._cacheIndex = -1;
929
+ for (var i = 0; i < this._keys.length; i++) {
930
+ if (SameValueZero(this._keys[i], key)) {
931
+ this._cacheIndex = i;
932
+ break;
933
+ }
934
+ }
935
+ }
936
+ if (this._cacheIndex < 0 && insert) {
937
+ this._cacheIndex = this._keys.length;
938
+ this._keys.push(key);
939
+ this._values.push(void 0);
940
+ }
941
+ return this._cacheIndex;
942
+ };
943
+ return Map3;
944
+ })()
945
+ );
946
+ return Map2;
947
+ function getKey(key, _) {
948
+ return key;
949
+ }
950
+ function getValue(_, value) {
951
+ return value;
952
+ }
953
+ function getEntry(key, value) {
954
+ return [key, value];
955
+ }
956
+ }
957
+ function CreateSetPolyfill() {
958
+ var Set2 = (
959
+ /** @class */
960
+ (function() {
961
+ function Set3() {
962
+ this._map = new _Map();
963
+ }
964
+ Object.defineProperty(Set3.prototype, "size", {
965
+ get: function() {
966
+ return this._map.size;
967
+ },
968
+ enumerable: true,
969
+ configurable: true
970
+ });
971
+ Set3.prototype.has = function(value) {
972
+ return this._map.has(value);
973
+ };
974
+ Set3.prototype.add = function(value) {
975
+ return this._map.set(value, value), this;
976
+ };
977
+ Set3.prototype.delete = function(value) {
978
+ return this._map.delete(value);
979
+ };
980
+ Set3.prototype.clear = function() {
981
+ this._map.clear();
982
+ };
983
+ Set3.prototype.keys = function() {
984
+ return this._map.keys();
985
+ };
986
+ Set3.prototype.values = function() {
987
+ return this._map.keys();
988
+ };
989
+ Set3.prototype.entries = function() {
990
+ return this._map.entries();
991
+ };
992
+ Set3.prototype["@@iterator"] = function() {
993
+ return this.keys();
994
+ };
995
+ Set3.prototype[iteratorSymbol] = function() {
996
+ return this.keys();
997
+ };
998
+ return Set3;
999
+ })()
1000
+ );
1001
+ return Set2;
1002
+ }
1003
+ function CreateWeakMapPolyfill() {
1004
+ var UUID_SIZE = 16;
1005
+ var keys = HashMap.create();
1006
+ var rootKey = CreateUniqueKey();
1007
+ return (
1008
+ /** @class */
1009
+ (function() {
1010
+ function WeakMap2() {
1011
+ this._key = CreateUniqueKey();
1012
+ }
1013
+ WeakMap2.prototype.has = function(target) {
1014
+ var table = GetOrCreateWeakMapTable(
1015
+ target,
1016
+ /*create*/
1017
+ false
1018
+ );
1019
+ return table !== void 0 ? HashMap.has(table, this._key) : false;
1020
+ };
1021
+ WeakMap2.prototype.get = function(target) {
1022
+ var table = GetOrCreateWeakMapTable(
1023
+ target,
1024
+ /*create*/
1025
+ false
1026
+ );
1027
+ return table !== void 0 ? HashMap.get(table, this._key) : void 0;
1028
+ };
1029
+ WeakMap2.prototype.set = function(target, value) {
1030
+ var table = GetOrCreateWeakMapTable(
1031
+ target,
1032
+ /*create*/
1033
+ true
1034
+ );
1035
+ table[this._key] = value;
1036
+ return this;
1037
+ };
1038
+ WeakMap2.prototype.delete = function(target) {
1039
+ var table = GetOrCreateWeakMapTable(
1040
+ target,
1041
+ /*create*/
1042
+ false
1043
+ );
1044
+ return table !== void 0 ? delete table[this._key] : false;
1045
+ };
1046
+ WeakMap2.prototype.clear = function() {
1047
+ this._key = CreateUniqueKey();
1048
+ };
1049
+ return WeakMap2;
1050
+ })()
1051
+ );
1052
+ function CreateUniqueKey() {
1053
+ var key;
1054
+ do
1055
+ key = "@@WeakMap@@" + CreateUUID();
1056
+ while (HashMap.has(keys, key));
1057
+ keys[key] = true;
1058
+ return key;
1059
+ }
1060
+ function GetOrCreateWeakMapTable(target, create) {
1061
+ if (!hasOwn.call(target, rootKey)) {
1062
+ if (!create)
1063
+ return void 0;
1064
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
1065
+ }
1066
+ return target[rootKey];
1067
+ }
1068
+ function FillRandomBytes(buffer, size) {
1069
+ for (var i = 0; i < size; ++i)
1070
+ buffer[i] = Math.random() * 255 | 0;
1071
+ return buffer;
1072
+ }
1073
+ function GenRandomBytes(size) {
1074
+ if (typeof Uint8Array === "function") {
1075
+ var array = new Uint8Array(size);
1076
+ if (typeof crypto !== "undefined") {
1077
+ crypto.getRandomValues(array);
1078
+ } else if (typeof msCrypto !== "undefined") {
1079
+ msCrypto.getRandomValues(array);
1080
+ } else {
1081
+ FillRandomBytes(array, size);
1082
+ }
1083
+ return array;
1084
+ }
1085
+ return FillRandomBytes(new Array(size), size);
1086
+ }
1087
+ function CreateUUID() {
1088
+ var data = GenRandomBytes(UUID_SIZE);
1089
+ data[6] = data[6] & 79 | 64;
1090
+ data[8] = data[8] & 191 | 128;
1091
+ var result = "";
1092
+ for (var offset = 0; offset < UUID_SIZE; ++offset) {
1093
+ var byte = data[offset];
1094
+ if (offset === 4 || offset === 6 || offset === 8)
1095
+ result += "-";
1096
+ if (byte < 16)
1097
+ result += "0";
1098
+ result += byte.toString(16).toLowerCase();
1099
+ }
1100
+ return result;
1101
+ }
1102
+ }
1103
+ function MakeDictionary(obj) {
1104
+ obj.__ = void 0;
1105
+ delete obj.__;
1106
+ return obj;
1107
+ }
1108
+ });
1109
+ })(Reflect2 || (Reflect2 = {}));
1110
+ }
1111
+ });
1112
+
1113
+ // src/index.ts
1114
+ var import_reflect_metadata2 = __toESM(require_Reflect());
1115
+
1116
+ // src/server.ts
1117
+ var import_reflect_metadata = __toESM(require_Reflect());
1118
+ import { EventEmitter } from "events";
1119
+ import * as http from "http";
1120
+ import * as url from "url";
1121
+ import {
1122
+ isMcpServer,
1123
+ getServerMetadata,
1124
+ getToolsMetadata,
1125
+ getResourcesMetadata,
1126
+ getPromptsMetadata
1127
+ } from "@mcp-weave/nestjs";
1128
+ var McpWebUI = class extends EventEmitter {
1129
+ serverClass;
1130
+ serverInstance;
1131
+ options;
1132
+ httpServer = null;
1133
+ serverInfo = null;
1134
+ callHistory = [];
1135
+ logs = [];
1136
+ constructor(serverClass, options = {}) {
1137
+ super();
1138
+ if (!isMcpServer(serverClass)) {
1139
+ throw new Error(`Class ${serverClass.name} is not decorated with @McpServer`);
1140
+ }
1141
+ this.serverClass = serverClass;
1142
+ this.options = {
1143
+ port: options.port ?? 3e3,
1144
+ host: options.host ?? "localhost",
1145
+ title: options.title ?? "MCP Server Dashboard",
1146
+ theme: options.theme ?? "dark",
1147
+ enableLogs: options.enableLogs ?? true
1148
+ };
1149
+ }
1150
+ /**
1151
+ * Initialize server instance and extract metadata
1152
+ */
1153
+ initialize() {
1154
+ this.serverInstance = new this.serverClass();
1155
+ const serverMeta = getServerMetadata(this.serverClass);
1156
+ const toolsMeta = getToolsMetadata(this.serverClass);
1157
+ const resourcesMeta = getResourcesMetadata(this.serverClass);
1158
+ const promptsMeta = getPromptsMetadata(this.serverClass);
1159
+ this.serverInfo = {
1160
+ name: serverMeta?.name ?? "Unknown Server",
1161
+ version: serverMeta?.version ?? "1.0.0",
1162
+ description: serverMeta?.description,
1163
+ tools: toolsMeta.map((t) => ({
1164
+ name: t.name,
1165
+ description: t.description,
1166
+ method: String(t.propertyKey),
1167
+ inputSchema: t.inputSchema
1168
+ })),
1169
+ resources: resourcesMeta.map((r) => ({
1170
+ uri: r.uri,
1171
+ name: r.name,
1172
+ description: r.description,
1173
+ mimeType: r.mimeType,
1174
+ method: String(r.propertyKey)
1175
+ })),
1176
+ prompts: promptsMeta.map((p) => ({
1177
+ name: p.name,
1178
+ description: p.description,
1179
+ method: String(p.propertyKey),
1180
+ arguments: p.arguments
1181
+ }))
1182
+ };
1183
+ }
1184
+ /**
1185
+ * Start the Web UI server
1186
+ */
1187
+ async start() {
1188
+ this.initialize();
1189
+ return new Promise((resolve, reject) => {
1190
+ this.httpServer = http.createServer((req, res) => {
1191
+ this.handleRequest(req, res);
1192
+ });
1193
+ this.httpServer.on("error", reject);
1194
+ this.httpServer.listen(this.options.port, this.options.host, () => {
1195
+ const address = this.httpServer.address();
1196
+ if (address && typeof address === "object") {
1197
+ this.options.port = address.port;
1198
+ }
1199
+ this.log(`\u{1F3A8} MCP Web UI started at ${this.getUrl()}`);
1200
+ resolve();
1201
+ });
1202
+ });
1203
+ }
1204
+ /**
1205
+ * Stop the Web UI server
1206
+ */
1207
+ async stop() {
1208
+ return new Promise((resolve, reject) => {
1209
+ if (!this.httpServer) {
1210
+ resolve();
1211
+ return;
1212
+ }
1213
+ this.httpServer.close((err) => {
1214
+ this.httpServer = null;
1215
+ if (err) reject(err);
1216
+ else resolve();
1217
+ });
1218
+ });
1219
+ }
1220
+ /**
1221
+ * Get the URL of the dashboard
1222
+ */
1223
+ getUrl() {
1224
+ return `http://${this.options.host}:${this.options.port}`;
1225
+ }
1226
+ /**
1227
+ * Get server information
1228
+ */
1229
+ getServerInfo() {
1230
+ return this.serverInfo;
1231
+ }
1232
+ /**
1233
+ * Get call history
1234
+ */
1235
+ getCallHistory() {
1236
+ return this.callHistory;
1237
+ }
1238
+ /**
1239
+ * Log a message
1240
+ */
1241
+ log(message) {
1242
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1243
+ const logEntry = `[${timestamp}] ${message}`;
1244
+ this.logs.push(logEntry);
1245
+ if (this.logs.length > 1e3) {
1246
+ this.logs.shift();
1247
+ }
1248
+ this.emit("log", logEntry);
1249
+ }
1250
+ /**
1251
+ * Handle HTTP requests
1252
+ */
1253
+ handleRequest(req, res) {
1254
+ const parsedUrl = url.parse(req.url ?? "/", true);
1255
+ const pathname = parsedUrl.pathname ?? "/";
1256
+ res.setHeader("Access-Control-Allow-Origin", "*");
1257
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
1258
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
1259
+ if (req.method === "OPTIONS") {
1260
+ res.writeHead(200);
1261
+ res.end();
1262
+ return;
1263
+ }
1264
+ if (pathname === "/" && req.method === "GET") {
1265
+ this.serveDashboard(res);
1266
+ } else if (pathname === "/api/info" && req.method === "GET") {
1267
+ this.serveServerInfo(res);
1268
+ } else if (pathname === "/api/tools" && req.method === "GET") {
1269
+ this.serveTools(res);
1270
+ } else if (pathname === "/api/resources" && req.method === "GET") {
1271
+ this.serveResources(res);
1272
+ } else if (pathname === "/api/prompts" && req.method === "GET") {
1273
+ this.servePrompts(res);
1274
+ } else if (pathname === "/api/call-tool" && req.method === "POST") {
1275
+ this.handleCallTool(req, res);
1276
+ } else if (pathname === "/api/read-resource" && req.method === "POST") {
1277
+ this.handleReadResource(req, res);
1278
+ } else if (pathname === "/api/get-prompt" && req.method === "POST") {
1279
+ this.handleGetPrompt(req, res);
1280
+ } else if (pathname === "/api/history" && req.method === "GET") {
1281
+ this.serveHistory(res);
1282
+ } else if (pathname === "/api/logs" && req.method === "GET") {
1283
+ this.serveLogs(res);
1284
+ } else {
1285
+ res.writeHead(404, { "Content-Type": "application/json" });
1286
+ res.end(JSON.stringify({ error: "Not Found" }));
1287
+ }
1288
+ }
1289
+ /**
1290
+ * Serve the main dashboard HTML
1291
+ */
1292
+ serveDashboard(res) {
1293
+ const html = this.generateDashboardHTML();
1294
+ res.writeHead(200, { "Content-Type": "text/html" });
1295
+ res.end(html);
1296
+ }
1297
+ /**
1298
+ * Serve server info as JSON
1299
+ */
1300
+ serveServerInfo(res) {
1301
+ res.writeHead(200, { "Content-Type": "application/json" });
1302
+ res.end(JSON.stringify(this.serverInfo));
1303
+ }
1304
+ /**
1305
+ * Serve tools list
1306
+ */
1307
+ serveTools(res) {
1308
+ res.writeHead(200, { "Content-Type": "application/json" });
1309
+ res.end(JSON.stringify(this.serverInfo?.tools ?? []));
1310
+ }
1311
+ /**
1312
+ * Serve resources list
1313
+ */
1314
+ serveResources(res) {
1315
+ res.writeHead(200, { "Content-Type": "application/json" });
1316
+ res.end(JSON.stringify(this.serverInfo?.resources ?? []));
1317
+ }
1318
+ /**
1319
+ * Serve prompts list
1320
+ */
1321
+ servePrompts(res) {
1322
+ res.writeHead(200, { "Content-Type": "application/json" });
1323
+ res.end(JSON.stringify(this.serverInfo?.prompts ?? []));
1324
+ }
1325
+ /**
1326
+ * Serve call history
1327
+ */
1328
+ serveHistory(res) {
1329
+ res.writeHead(200, { "Content-Type": "application/json" });
1330
+ res.end(JSON.stringify(this.callHistory));
1331
+ }
1332
+ /**
1333
+ * Serve server logs
1334
+ */
1335
+ serveLogs(res) {
1336
+ res.writeHead(200, { "Content-Type": "application/json" });
1337
+ res.end(JSON.stringify(this.logs));
1338
+ }
1339
+ /**
1340
+ * Handle tool call request
1341
+ */
1342
+ async handleCallTool(req, res) {
1343
+ try {
1344
+ const body = await this.readBody(req);
1345
+ const { name, input } = JSON.parse(body);
1346
+ const tool = this.serverInfo?.tools.find((t) => t.name === name);
1347
+ if (!tool) {
1348
+ res.writeHead(404, { "Content-Type": "application/json" });
1349
+ res.end(JSON.stringify({ error: `Tool '${name}' not found` }));
1350
+ return;
1351
+ }
1352
+ const startTime = Date.now();
1353
+ const historyEntry = {
1354
+ id: this.generateId(),
1355
+ type: "tool",
1356
+ name,
1357
+ input,
1358
+ timestamp: /* @__PURE__ */ new Date(),
1359
+ duration: 0
1360
+ };
1361
+ try {
1362
+ this.log(`Calling tool: ${name}`);
1363
+ this.emit("tool:call", name, input);
1364
+ const method = this.serverInstance[tool.method];
1365
+ const result = await method.call(this.serverInstance, input);
1366
+ historyEntry.output = result;
1367
+ historyEntry.duration = Date.now() - startTime;
1368
+ this.callHistory.unshift(historyEntry);
1369
+ this.log(`Tool ${name} completed in ${historyEntry.duration}ms`);
1370
+ this.emit("tool:result", name, result);
1371
+ res.writeHead(200, { "Content-Type": "application/json" });
1372
+ res.end(JSON.stringify({ success: true, result }));
1373
+ } catch (error) {
1374
+ historyEntry.error = error instanceof Error ? error.message : String(error);
1375
+ historyEntry.duration = Date.now() - startTime;
1376
+ this.callHistory.unshift(historyEntry);
1377
+ this.log(`Tool ${name} failed: ${historyEntry.error}`);
1378
+ res.writeHead(500, { "Content-Type": "application/json" });
1379
+ res.end(JSON.stringify({ success: false, error: historyEntry.error }));
1380
+ }
1381
+ } catch (error) {
1382
+ res.writeHead(400, { "Content-Type": "application/json" });
1383
+ res.end(JSON.stringify({ error: "Invalid request body" }));
1384
+ }
1385
+ }
1386
+ /**
1387
+ * Handle resource read request
1388
+ */
1389
+ async handleReadResource(req, res) {
1390
+ try {
1391
+ const body = await this.readBody(req);
1392
+ const { uri } = JSON.parse(body);
1393
+ const resource = this.serverInfo?.resources.find((r) => {
1394
+ const pattern = r.uri.replace(/{[^}]+}/g, "[^/]+");
1395
+ const regex = new RegExp(`^${pattern}$`);
1396
+ return regex.test(uri);
1397
+ });
1398
+ if (!resource) {
1399
+ res.writeHead(404, { "Content-Type": "application/json" });
1400
+ res.end(JSON.stringify({ error: `Resource matching '${uri}' not found` }));
1401
+ return;
1402
+ }
1403
+ const startTime = Date.now();
1404
+ const historyEntry = {
1405
+ id: this.generateId(),
1406
+ type: "resource",
1407
+ name: uri,
1408
+ timestamp: /* @__PURE__ */ new Date(),
1409
+ duration: 0
1410
+ };
1411
+ try {
1412
+ this.log(`Reading resource: ${uri}`);
1413
+ this.emit("resource:read", uri);
1414
+ const params = this.extractUriParams(resource.uri, uri);
1415
+ const method = this.serverInstance[resource.method];
1416
+ const result = await method.call(this.serverInstance, params);
1417
+ historyEntry.output = result;
1418
+ historyEntry.duration = Date.now() - startTime;
1419
+ this.callHistory.unshift(historyEntry);
1420
+ this.log(`Resource ${uri} read in ${historyEntry.duration}ms`);
1421
+ res.writeHead(200, { "Content-Type": "application/json" });
1422
+ res.end(JSON.stringify({ success: true, result }));
1423
+ } catch (error) {
1424
+ historyEntry.error = error instanceof Error ? error.message : String(error);
1425
+ historyEntry.duration = Date.now() - startTime;
1426
+ this.callHistory.unshift(historyEntry);
1427
+ this.log(`Resource ${uri} failed: ${historyEntry.error}`);
1428
+ res.writeHead(500, { "Content-Type": "application/json" });
1429
+ res.end(JSON.stringify({ success: false, error: historyEntry.error }));
1430
+ }
1431
+ } catch (error) {
1432
+ res.writeHead(400, { "Content-Type": "application/json" });
1433
+ res.end(JSON.stringify({ error: "Invalid request body" }));
1434
+ }
1435
+ }
1436
+ /**
1437
+ * Handle prompt get request
1438
+ */
1439
+ async handleGetPrompt(req, res) {
1440
+ try {
1441
+ const body = await this.readBody(req);
1442
+ const { name, args } = JSON.parse(body);
1443
+ const prompt = this.serverInfo?.prompts.find((p) => p.name === name);
1444
+ if (!prompt) {
1445
+ res.writeHead(404, { "Content-Type": "application/json" });
1446
+ res.end(JSON.stringify({ error: `Prompt '${name}' not found` }));
1447
+ return;
1448
+ }
1449
+ const startTime = Date.now();
1450
+ const historyEntry = {
1451
+ id: this.generateId(),
1452
+ type: "prompt",
1453
+ name,
1454
+ input: args,
1455
+ timestamp: /* @__PURE__ */ new Date(),
1456
+ duration: 0
1457
+ };
1458
+ try {
1459
+ this.log(`Getting prompt: ${name}`);
1460
+ this.emit("prompt:get", name, args);
1461
+ const method = this.serverInstance[prompt.method];
1462
+ const result = await method.call(this.serverInstance, args);
1463
+ historyEntry.output = result;
1464
+ historyEntry.duration = Date.now() - startTime;
1465
+ this.callHistory.unshift(historyEntry);
1466
+ this.log(`Prompt ${name} completed in ${historyEntry.duration}ms`);
1467
+ res.writeHead(200, { "Content-Type": "application/json" });
1468
+ res.end(JSON.stringify({ success: true, result }));
1469
+ } catch (error) {
1470
+ historyEntry.error = error instanceof Error ? error.message : String(error);
1471
+ historyEntry.duration = Date.now() - startTime;
1472
+ this.callHistory.unshift(historyEntry);
1473
+ this.log(`Prompt ${name} failed: ${historyEntry.error}`);
1474
+ res.writeHead(500, { "Content-Type": "application/json" });
1475
+ res.end(JSON.stringify({ success: false, error: historyEntry.error }));
1476
+ }
1477
+ } catch (error) {
1478
+ res.writeHead(400, { "Content-Type": "application/json" });
1479
+ res.end(JSON.stringify({ error: "Invalid request body" }));
1480
+ }
1481
+ }
1482
+ /**
1483
+ * Read request body
1484
+ */
1485
+ readBody(req) {
1486
+ return new Promise((resolve, reject) => {
1487
+ let body = "";
1488
+ req.on("data", (chunk) => body += chunk);
1489
+ req.on("end", () => resolve(body));
1490
+ req.on("error", reject);
1491
+ });
1492
+ }
1493
+ /**
1494
+ * Extract parameters from URI template
1495
+ */
1496
+ extractUriParams(template, uri) {
1497
+ const params = {};
1498
+ const templateParts = template.split("/");
1499
+ const uriParts = uri.split("/");
1500
+ templateParts.forEach((part, index) => {
1501
+ const match = part.match(/^{([^}]+)}$/);
1502
+ const uriPart = uriParts[index];
1503
+ if (match && match[1] && uriPart) {
1504
+ params[match[1]] = uriPart;
1505
+ }
1506
+ });
1507
+ return params;
1508
+ }
1509
+ /**
1510
+ * Generate unique ID
1511
+ */
1512
+ generateId() {
1513
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
1514
+ }
1515
+ /**
1516
+ * Generate the dashboard HTML
1517
+ */
1518
+ generateDashboardHTML() {
1519
+ const isDark = this.options.theme === "dark";
1520
+ return `<!DOCTYPE html>
1521
+ <html lang="en">
1522
+ <head>
1523
+ <meta charset="UTF-8">
1524
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1525
+ <title>${this.options.title}</title>
1526
+ <style>
1527
+ :root {
1528
+ --bg-primary: ${isDark ? "#1a1a2e" : "#ffffff"};
1529
+ --bg-secondary: ${isDark ? "#16213e" : "#f5f5f5"};
1530
+ --bg-card: ${isDark ? "#0f3460" : "#ffffff"};
1531
+ --text-primary: ${isDark ? "#ffffff" : "#1a1a2e"};
1532
+ --text-secondary: ${isDark ? "#a0a0a0" : "#666666"};
1533
+ --accent: #e94560;
1534
+ --accent-hover: #ff6b6b;
1535
+ --success: #4caf50;
1536
+ --error: #f44336;
1537
+ --border: ${isDark ? "#2a2a4a" : "#e0e0e0"};
1538
+ --code-bg: ${isDark ? "#0d1117" : "#f6f8fa"};
1539
+ }
1540
+
1541
+ * { box-sizing: border-box; margin: 0; padding: 0; }
1542
+
1543
+ body {
1544
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
1545
+ background: var(--bg-primary);
1546
+ color: var(--text-primary);
1547
+ line-height: 1.6;
1548
+ }
1549
+
1550
+ .container {
1551
+ max-width: 1400px;
1552
+ margin: 0 auto;
1553
+ padding: 20px;
1554
+ }
1555
+
1556
+ header {
1557
+ background: var(--bg-secondary);
1558
+ padding: 20px;
1559
+ border-bottom: 1px solid var(--border);
1560
+ margin-bottom: 20px;
1561
+ }
1562
+
1563
+ header h1 {
1564
+ color: var(--accent);
1565
+ font-size: 24px;
1566
+ display: flex;
1567
+ align-items: center;
1568
+ gap: 10px;
1569
+ }
1570
+
1571
+ .server-info {
1572
+ display: flex;
1573
+ gap: 20px;
1574
+ margin-top: 10px;
1575
+ color: var(--text-secondary);
1576
+ font-size: 14px;
1577
+ }
1578
+
1579
+ .badge {
1580
+ background: var(--accent);
1581
+ color: white;
1582
+ padding: 2px 8px;
1583
+ border-radius: 12px;
1584
+ font-size: 12px;
1585
+ }
1586
+
1587
+ .grid {
1588
+ display: grid;
1589
+ grid-template-columns: 300px 1fr 350px;
1590
+ gap: 20px;
1591
+ height: calc(100vh - 150px);
1592
+ }
1593
+
1594
+ .panel {
1595
+ background: var(--bg-card);
1596
+ border: 1px solid var(--border);
1597
+ border-radius: 8px;
1598
+ overflow: hidden;
1599
+ display: flex;
1600
+ flex-direction: column;
1601
+ }
1602
+
1603
+ .panel-header {
1604
+ background: var(--bg-secondary);
1605
+ padding: 12px 16px;
1606
+ font-weight: 600;
1607
+ border-bottom: 1px solid var(--border);
1608
+ display: flex;
1609
+ justify-content: space-between;
1610
+ align-items: center;
1611
+ }
1612
+
1613
+ .panel-content {
1614
+ padding: 16px;
1615
+ overflow-y: auto;
1616
+ flex: 1;
1617
+ }
1618
+
1619
+ .tabs {
1620
+ display: flex;
1621
+ gap: 0;
1622
+ background: var(--bg-secondary);
1623
+ border-bottom: 1px solid var(--border);
1624
+ }
1625
+
1626
+ .tab {
1627
+ padding: 10px 16px;
1628
+ cursor: pointer;
1629
+ border: none;
1630
+ background: transparent;
1631
+ color: var(--text-secondary);
1632
+ font-size: 14px;
1633
+ border-bottom: 2px solid transparent;
1634
+ transition: all 0.2s;
1635
+ }
1636
+
1637
+ .tab:hover { color: var(--text-primary); }
1638
+ .tab.active {
1639
+ color: var(--accent);
1640
+ border-bottom-color: var(--accent);
1641
+ }
1642
+
1643
+ .item {
1644
+ padding: 12px;
1645
+ border: 1px solid var(--border);
1646
+ border-radius: 6px;
1647
+ margin-bottom: 8px;
1648
+ cursor: pointer;
1649
+ transition: all 0.2s;
1650
+ }
1651
+
1652
+ .item:hover {
1653
+ border-color: var(--accent);
1654
+ background: var(--bg-secondary);
1655
+ }
1656
+
1657
+ .item.selected {
1658
+ border-color: var(--accent);
1659
+ background: var(--bg-secondary);
1660
+ }
1661
+
1662
+ .item-name {
1663
+ font-weight: 600;
1664
+ color: var(--accent);
1665
+ }
1666
+
1667
+ .item-desc {
1668
+ color: var(--text-secondary);
1669
+ font-size: 13px;
1670
+ margin-top: 4px;
1671
+ }
1672
+
1673
+ .form-group {
1674
+ margin-bottom: 16px;
1675
+ }
1676
+
1677
+ .form-group label {
1678
+ display: block;
1679
+ margin-bottom: 6px;
1680
+ font-weight: 500;
1681
+ font-size: 14px;
1682
+ }
1683
+
1684
+ .form-group input,
1685
+ .form-group textarea {
1686
+ width: 100%;
1687
+ padding: 10px 12px;
1688
+ border: 1px solid var(--border);
1689
+ border-radius: 6px;
1690
+ background: var(--bg-primary);
1691
+ color: var(--text-primary);
1692
+ font-family: inherit;
1693
+ font-size: 14px;
1694
+ }
1695
+
1696
+ .form-group textarea {
1697
+ min-height: 150px;
1698
+ font-family: 'Monaco', 'Menlo', monospace;
1699
+ font-size: 13px;
1700
+ }
1701
+
1702
+ .form-group input:focus,
1703
+ .form-group textarea:focus {
1704
+ outline: none;
1705
+ border-color: var(--accent);
1706
+ }
1707
+
1708
+ .btn {
1709
+ padding: 10px 20px;
1710
+ border: none;
1711
+ border-radius: 6px;
1712
+ font-weight: 600;
1713
+ cursor: pointer;
1714
+ transition: all 0.2s;
1715
+ font-size: 14px;
1716
+ }
1717
+
1718
+ .btn-primary {
1719
+ background: var(--accent);
1720
+ color: white;
1721
+ }
1722
+
1723
+ .btn-primary:hover { background: var(--accent-hover); }
1724
+ .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
1725
+
1726
+ .result {
1727
+ background: var(--code-bg);
1728
+ border-radius: 6px;
1729
+ padding: 16px;
1730
+ font-family: 'Monaco', 'Menlo', monospace;
1731
+ font-size: 13px;
1732
+ white-space: pre-wrap;
1733
+ word-break: break-all;
1734
+ max-height: 300px;
1735
+ overflow-y: auto;
1736
+ }
1737
+
1738
+ .result.success { border-left: 3px solid var(--success); }
1739
+ .result.error { border-left: 3px solid var(--error); }
1740
+
1741
+ .history-item {
1742
+ padding: 10px 12px;
1743
+ border: 1px solid var(--border);
1744
+ border-radius: 6px;
1745
+ margin-bottom: 8px;
1746
+ font-size: 13px;
1747
+ }
1748
+
1749
+ .history-item .type {
1750
+ display: inline-block;
1751
+ padding: 2px 6px;
1752
+ border-radius: 4px;
1753
+ font-size: 11px;
1754
+ text-transform: uppercase;
1755
+ font-weight: 600;
1756
+ }
1757
+
1758
+ .history-item .type.tool { background: #2196f3; color: white; }
1759
+ .history-item .type.resource { background: #9c27b0; color: white; }
1760
+ .history-item .type.prompt { background: #ff9800; color: white; }
1761
+
1762
+ .history-item .name {
1763
+ font-weight: 600;
1764
+ margin-left: 8px;
1765
+ }
1766
+
1767
+ .history-item .time {
1768
+ color: var(--text-secondary);
1769
+ font-size: 12px;
1770
+ margin-top: 4px;
1771
+ }
1772
+
1773
+ .history-item .duration {
1774
+ color: var(--success);
1775
+ }
1776
+
1777
+ .history-item.error .duration { color: var(--error); }
1778
+
1779
+ .empty-state {
1780
+ text-align: center;
1781
+ padding: 40px 20px;
1782
+ color: var(--text-secondary);
1783
+ }
1784
+
1785
+ .spinner {
1786
+ border: 3px solid var(--border);
1787
+ border-top: 3px solid var(--accent);
1788
+ border-radius: 50%;
1789
+ width: 24px;
1790
+ height: 24px;
1791
+ animation: spin 1s linear infinite;
1792
+ margin: 20px auto;
1793
+ }
1794
+
1795
+ @keyframes spin {
1796
+ 0% { transform: rotate(0deg); }
1797
+ 100% { transform: rotate(360deg); }
1798
+ }
1799
+
1800
+ .logs {
1801
+ font-family: 'Monaco', 'Menlo', monospace;
1802
+ font-size: 12px;
1803
+ background: var(--code-bg);
1804
+ padding: 12px;
1805
+ border-radius: 6px;
1806
+ max-height: 200px;
1807
+ overflow-y: auto;
1808
+ }
1809
+
1810
+ .log-entry {
1811
+ color: var(--text-secondary);
1812
+ margin-bottom: 4px;
1813
+ }
1814
+ </style>
1815
+ </head>
1816
+ <body>
1817
+ <header>
1818
+ <div class="container">
1819
+ <h1>\u{1F527} ${this.options.title}</h1>
1820
+ <div class="server-info" id="server-info">Loading...</div>
1821
+ </div>
1822
+ </header>
1823
+
1824
+ <div class="container">
1825
+ <div class="grid">
1826
+ <!-- Left Panel: Items List -->
1827
+ <div class="panel">
1828
+ <div class="tabs">
1829
+ <button class="tab active" data-tab="tools">Tools</button>
1830
+ <button class="tab" data-tab="resources">Resources</button>
1831
+ <button class="tab" data-tab="prompts">Prompts</button>
1832
+ </div>
1833
+ <div class="panel-content" id="items-list">
1834
+ <div class="empty-state">Loading...</div>
1835
+ </div>
1836
+ </div>
1837
+
1838
+ <!-- Center Panel: Tester -->
1839
+ <div class="panel">
1840
+ <div class="panel-header">
1841
+ <span id="tester-title">Select an item to test</span>
1842
+ </div>
1843
+ <div class="panel-content" id="tester">
1844
+ <div class="empty-state">
1845
+ <p>Select a tool, resource, or prompt from the left panel to test it.</p>
1846
+ </div>
1847
+ </div>
1848
+ </div>
1849
+
1850
+ <!-- Right Panel: History -->
1851
+ <div class="panel">
1852
+ <div class="panel-header">
1853
+ <span>Call History</span>
1854
+ <button class="btn" onclick="clearHistory()" style="padding: 4px 8px; font-size: 12px;">Clear</button>
1855
+ </div>
1856
+ <div class="panel-content" id="history">
1857
+ <div class="empty-state">No calls yet</div>
1858
+ </div>
1859
+ </div>
1860
+ </div>
1861
+ </div>
1862
+
1863
+ <script>
1864
+ // State
1865
+ let serverInfo = null;
1866
+ let currentTab = 'tools';
1867
+ let selectedItem = null;
1868
+ let isLoading = false;
1869
+ let history = [];
1870
+
1871
+ // Initialize
1872
+ async function init() {
1873
+ await loadServerInfo();
1874
+ await loadItems();
1875
+ setupTabs();
1876
+ pollHistory();
1877
+ }
1878
+
1879
+ // Load server info
1880
+ async function loadServerInfo() {
1881
+ try {
1882
+ const res = await fetch('/api/info');
1883
+ serverInfo = await res.json();
1884
+ document.getElementById('server-info').innerHTML = \`
1885
+ <span><strong>Name:</strong> \${serverInfo.name}</span>
1886
+ <span><strong>Version:</strong> \${serverInfo.version}</span>
1887
+ <span class="badge">\${serverInfo.tools.length} Tools</span>
1888
+ <span class="badge">\${serverInfo.resources.length} Resources</span>
1889
+ <span class="badge">\${serverInfo.prompts.length} Prompts</span>
1890
+ \`;
1891
+ } catch (err) {
1892
+ console.error('Failed to load server info:', err);
1893
+ }
1894
+ }
1895
+
1896
+ // Load items based on current tab
1897
+ async function loadItems() {
1898
+ const container = document.getElementById('items-list');
1899
+ let items = [];
1900
+
1901
+ if (currentTab === 'tools') {
1902
+ items = serverInfo?.tools || [];
1903
+ } else if (currentTab === 'resources') {
1904
+ items = serverInfo?.resources || [];
1905
+ } else if (currentTab === 'prompts') {
1906
+ items = serverInfo?.prompts || [];
1907
+ }
1908
+
1909
+ if (items.length === 0) {
1910
+ container.innerHTML = '<div class="empty-state">No ' + currentTab + ' available</div>';
1911
+ return;
1912
+ }
1913
+
1914
+ container.innerHTML = items.map((item, index) => \`
1915
+ <div class="item" onclick="selectItem('\${currentTab}', \${index})">
1916
+ <div class="item-name">\${item.name || item.uri}</div>
1917
+ <div class="item-desc">\${item.description || ''}</div>
1918
+ </div>
1919
+ \`).join('');
1920
+ }
1921
+
1922
+ // Setup tabs
1923
+ function setupTabs() {
1924
+ document.querySelectorAll('.tab').forEach(tab => {
1925
+ tab.addEventListener('click', () => {
1926
+ document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
1927
+ tab.classList.add('active');
1928
+ currentTab = tab.dataset.tab;
1929
+ loadItems();
1930
+ clearTester();
1931
+ });
1932
+ });
1933
+ }
1934
+
1935
+ // Select an item
1936
+ function selectItem(type, index) {
1937
+ let items = type === 'tools' ? serverInfo.tools :
1938
+ type === 'resources' ? serverInfo.resources :
1939
+ serverInfo.prompts;
1940
+ selectedItem = { type, item: items[index] };
1941
+ renderTester();
1942
+ }
1943
+
1944
+ // Clear tester
1945
+ function clearTester() {
1946
+ selectedItem = null;
1947
+ document.getElementById('tester-title').textContent = 'Select an item to test';
1948
+ document.getElementById('tester').innerHTML = \`
1949
+ <div class="empty-state">
1950
+ <p>Select a tool, resource, or prompt from the left panel to test it.</p>
1951
+ </div>
1952
+ \`;
1953
+ }
1954
+
1955
+ // Render tester for selected item
1956
+ function renderTester() {
1957
+ if (!selectedItem) return;
1958
+
1959
+ const { type, item } = selectedItem;
1960
+ document.getElementById('tester-title').textContent = item.name || item.uri;
1961
+
1962
+ let html = '';
1963
+
1964
+ if (type === 'tools') {
1965
+ html = \`
1966
+ <div class="form-group">
1967
+ <label>Description</label>
1968
+ <p style="color: var(--text-secondary); font-size: 14px;">\${item.description || 'No description'}</p>
1969
+ </div>
1970
+ <div class="form-group">
1971
+ <label>Input (JSON)</label>
1972
+ <textarea id="tool-input" placeholder='{"key": "value"}'>{}</textarea>
1973
+ </div>
1974
+ <button class="btn btn-primary" onclick="callTool()" id="call-btn">Call Tool</button>
1975
+ <div id="result-container" style="margin-top: 16px;"></div>
1976
+ \`;
1977
+ } else if (type === 'resources') {
1978
+ html = \`
1979
+ <div class="form-group">
1980
+ <label>URI Template</label>
1981
+ <p style="color: var(--text-secondary); font-size: 14px;">\${item.uri}</p>
1982
+ </div>
1983
+ <div class="form-group">
1984
+ <label>URI to Read</label>
1985
+ <input type="text" id="resource-uri" value="\${item.uri.replace(/{[^}]+}/g, 'example')}" />
1986
+ </div>
1987
+ <button class="btn btn-primary" onclick="readResource()" id="call-btn">Read Resource</button>
1988
+ <div id="result-container" style="margin-top: 16px;"></div>
1989
+ \`;
1990
+ } else if (type === 'prompts') {
1991
+ const args = item.arguments || [];
1992
+ html = \`
1993
+ <div class="form-group">
1994
+ <label>Description</label>
1995
+ <p style="color: var(--text-secondary); font-size: 14px;">\${item.description || 'No description'}</p>
1996
+ </div>
1997
+ <div class="form-group">
1998
+ <label>Arguments (JSON)</label>
1999
+ <textarea id="prompt-args" placeholder='{"arg1": "value1"}'>\${JSON.stringify(args.reduce((acc, a) => ({ ...acc, [a.name]: '' }), {}), null, 2)}</textarea>
2000
+ </div>
2001
+ <button class="btn btn-primary" onclick="getPrompt()" id="call-btn">Get Prompt</button>
2002
+ <div id="result-container" style="margin-top: 16px;"></div>
2003
+ \`;
2004
+ }
2005
+
2006
+ document.getElementById('tester').innerHTML = html;
2007
+ }
2008
+
2009
+ // Call tool
2010
+ async function callTool() {
2011
+ if (isLoading) return;
2012
+ isLoading = true;
2013
+
2014
+ const btn = document.getElementById('call-btn');
2015
+ btn.disabled = true;
2016
+ btn.textContent = 'Calling...';
2017
+
2018
+ try {
2019
+ const input = JSON.parse(document.getElementById('tool-input').value || '{}');
2020
+ const res = await fetch('/api/call-tool', {
2021
+ method: 'POST',
2022
+ headers: { 'Content-Type': 'application/json' },
2023
+ body: JSON.stringify({ name: selectedItem.item.name, input })
2024
+ });
2025
+ const data = await res.json();
2026
+ showResult(data);
2027
+ } catch (err) {
2028
+ showResult({ success: false, error: err.message });
2029
+ } finally {
2030
+ isLoading = false;
2031
+ btn.disabled = false;
2032
+ btn.textContent = 'Call Tool';
2033
+ }
2034
+ }
2035
+
2036
+ // Read resource
2037
+ async function readResource() {
2038
+ if (isLoading) return;
2039
+ isLoading = true;
2040
+
2041
+ const btn = document.getElementById('call-btn');
2042
+ btn.disabled = true;
2043
+ btn.textContent = 'Reading...';
2044
+
2045
+ try {
2046
+ const uri = document.getElementById('resource-uri').value;
2047
+ const res = await fetch('/api/read-resource', {
2048
+ method: 'POST',
2049
+ headers: { 'Content-Type': 'application/json' },
2050
+ body: JSON.stringify({ uri })
2051
+ });
2052
+ const data = await res.json();
2053
+ showResult(data);
2054
+ } catch (err) {
2055
+ showResult({ success: false, error: err.message });
2056
+ } finally {
2057
+ isLoading = false;
2058
+ btn.disabled = false;
2059
+ btn.textContent = 'Read Resource';
2060
+ }
2061
+ }
2062
+
2063
+ // Get prompt
2064
+ async function getPrompt() {
2065
+ if (isLoading) return;
2066
+ isLoading = true;
2067
+
2068
+ const btn = document.getElementById('call-btn');
2069
+ btn.disabled = true;
2070
+ btn.textContent = 'Getting...';
2071
+
2072
+ try {
2073
+ const args = JSON.parse(document.getElementById('prompt-args').value || '{}');
2074
+ const res = await fetch('/api/get-prompt', {
2075
+ method: 'POST',
2076
+ headers: { 'Content-Type': 'application/json' },
2077
+ body: JSON.stringify({ name: selectedItem.item.name, args })
2078
+ });
2079
+ const data = await res.json();
2080
+ showResult(data);
2081
+ } catch (err) {
2082
+ showResult({ success: false, error: err.message });
2083
+ } finally {
2084
+ isLoading = false;
2085
+ btn.disabled = false;
2086
+ btn.textContent = 'Get Prompt';
2087
+ }
2088
+ }
2089
+
2090
+ // Show result
2091
+ function showResult(data) {
2092
+ const container = document.getElementById('result-container');
2093
+ const success = data.success;
2094
+ const content = success ? JSON.stringify(data.result, null, 2) : data.error;
2095
+
2096
+ container.innerHTML = \`
2097
+ <div class="result \${success ? 'success' : 'error'}">
2098
+ \${escapeHtml(content)}
2099
+ </div>
2100
+ \`;
2101
+
2102
+ refreshHistory();
2103
+ }
2104
+
2105
+ // Escape HTML
2106
+ function escapeHtml(text) {
2107
+ const div = document.createElement('div');
2108
+ div.textContent = text;
2109
+ return div.innerHTML;
2110
+ }
2111
+
2112
+ // Poll history
2113
+ async function pollHistory() {
2114
+ await refreshHistory();
2115
+ setTimeout(pollHistory, 2000);
2116
+ }
2117
+
2118
+ // Refresh history
2119
+ async function refreshHistory() {
2120
+ try {
2121
+ const res = await fetch('/api/history');
2122
+ history = await res.json();
2123
+ renderHistory();
2124
+ } catch (err) {
2125
+ console.error('Failed to load history:', err);
2126
+ }
2127
+ }
2128
+
2129
+ // Render history
2130
+ function renderHistory() {
2131
+ const container = document.getElementById('history');
2132
+
2133
+ if (history.length === 0) {
2134
+ container.innerHTML = '<div class="empty-state">No calls yet</div>';
2135
+ return;
2136
+ }
2137
+
2138
+ container.innerHTML = history.slice(0, 50).map(entry => \`
2139
+ <div class="history-item \${entry.error ? 'error' : ''}">
2140
+ <span class="type \${entry.type}">\${entry.type}</span>
2141
+ <span class="name">\${entry.name}</span>
2142
+ <div class="time">
2143
+ \${new Date(entry.timestamp).toLocaleTimeString()} -
2144
+ <span class="duration">\${entry.duration}ms</span>
2145
+ \${entry.error ? '<span style="color: var(--error);"> - Error</span>' : ''}
2146
+ </div>
2147
+ </div>
2148
+ \`).join('');
2149
+ }
2150
+
2151
+ // Clear history
2152
+ function clearHistory() {
2153
+ history = [];
2154
+ renderHistory();
2155
+ }
2156
+
2157
+ // Start
2158
+ init();
2159
+ </script>
2160
+ </body>
2161
+ </html>`;
2162
+ }
2163
+ };
2164
+
2165
+ // src/index.ts
2166
+ var VERSION = "0.1.0";
2167
+ export {
2168
+ McpWebUI,
2169
+ VERSION
2170
+ };
2171
+ /*! Bundled license information:
2172
+
2173
+ reflect-metadata/Reflect.js:
2174
+ (*! *****************************************************************************
2175
+ Copyright (C) Microsoft. All rights reserved.
2176
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2177
+ this file except in compliance with the License. You may obtain a copy of the
2178
+ License at http://www.apache.org/licenses/LICENSE-2.0
2179
+
2180
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2181
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2182
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2183
+ MERCHANTABLITY OR NON-INFRINGEMENT.
2184
+
2185
+ See the Apache Version 2.0 License for specific language governing permissions
2186
+ and limitations under the License.
2187
+ ***************************************************************************** *)
2188
+ */
2189
+ //# sourceMappingURL=index.mjs.map