@miragon/mcp-toolkit-core 0.10.1 → 1.1.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.
Files changed (76) hide show
  1. package/README.md +7 -7
  2. package/dist/framework/render-view.d.ts +1 -1
  3. package/dist/framework/render-view.d.ts.map +1 -1
  4. package/dist/framework/render-view.js +3 -0
  5. package/dist/framework/render-view.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/middleware/role-filter.d.ts +16 -32
  11. package/dist/middleware/role-filter.d.ts.map +1 -1
  12. package/dist/middleware/role-filter.js +10 -22
  13. package/dist/middleware/role-filter.js.map +1 -1
  14. package/dist/tools/backend-registry.d.ts +9 -3
  15. package/dist/tools/backend-registry.d.ts.map +1 -1
  16. package/dist/tools/backend-registry.js +13 -12
  17. package/dist/tools/backend-registry.js.map +1 -1
  18. package/dist/tools/create-framework-app.d.ts +51 -38
  19. package/dist/tools/create-framework-app.d.ts.map +1 -1
  20. package/dist/tools/create-framework-app.js +79 -78
  21. package/dist/tools/create-framework-app.js.map +1 -1
  22. package/dist/tools/index.d.ts +4 -5
  23. package/dist/tools/index.d.ts.map +1 -1
  24. package/dist/tools/index.js +3 -3
  25. package/dist/tools/index.js.map +1 -1
  26. package/dist/tools/install-toolkit.d.ts +77 -0
  27. package/dist/tools/install-toolkit.d.ts.map +1 -0
  28. package/dist/tools/install-toolkit.js +85 -0
  29. package/dist/tools/install-toolkit.js.map +1 -0
  30. package/dist/tools/register-catalogue-tool.d.ts +1 -1
  31. package/dist/tools/register-catalogue-tool.d.ts.map +1 -1
  32. package/dist/tools/register-catalogue-tool.js +2 -3
  33. package/dist/tools/register-catalogue-tool.js.map +1 -1
  34. package/dist/tools/register-dashboard-tools.d.ts +1 -1
  35. package/dist/tools/register-dashboard-tools.d.ts.map +1 -1
  36. package/dist/tools/register-dashboard-tools.js +6 -6
  37. package/dist/tools/register-dashboard-tools.js.map +1 -1
  38. package/dist/tools/register-framework-tools.d.ts +15 -47
  39. package/dist/tools/register-framework-tools.d.ts.map +1 -1
  40. package/dist/tools/register-framework-tools.js +31 -63
  41. package/dist/tools/register-framework-tools.js.map +1 -1
  42. package/dist/tools/register-tool.d.ts +1 -1
  43. package/dist/tools/register-tool.d.ts.map +1 -1
  44. package/dist/tools/register-tool.js +14 -8
  45. package/dist/tools/register-tool.js.map +1 -1
  46. package/dist/tools/register-widget-tool.d.ts +35 -11
  47. package/dist/tools/register-widget-tool.d.ts.map +1 -1
  48. package/dist/tools/register-widget-tool.js +57 -30
  49. package/dist/tools/register-widget-tool.js.map +1 -1
  50. package/dist/tools/tool-results.d.ts +46 -0
  51. package/dist/tools/tool-results.d.ts.map +1 -0
  52. package/dist/tools/tool-results.js +39 -0
  53. package/dist/tools/tool-results.js.map +1 -0
  54. package/dist/tools/with-tool-errors.d.ts +12 -6
  55. package/dist/tools/with-tool-errors.d.ts.map +1 -1
  56. package/dist/tools/with-tool-errors.js +12 -6
  57. package/dist/tools/with-tool-errors.js.map +1 -1
  58. package/dist/types/app.d.ts +10 -7
  59. package/dist/types/app.d.ts.map +1 -1
  60. package/dist/types/index.d.ts +2 -2
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/index.js +1 -1
  63. package/dist/types/index.js.map +1 -1
  64. package/dist/types/meta.d.ts +73 -56
  65. package/dist/types/meta.d.ts.map +1 -1
  66. package/dist/types/meta.js +49 -53
  67. package/dist/types/meta.js.map +1 -1
  68. package/package.json +13 -6
  69. package/dist/tools/app-resource-uri.d.ts +0 -28
  70. package/dist/tools/app-resource-uri.d.ts.map +0 -1
  71. package/dist/tools/app-resource-uri.js +0 -30
  72. package/dist/tools/app-resource-uri.js.map +0 -1
  73. package/dist/tools/tool-call-name.d.ts +0 -53
  74. package/dist/tools/tool-call-name.d.ts.map +0 -1
  75. package/dist/tools/tool-call-name.js +0 -92
  76. package/dist/tools/tool-call-name.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Toolkit-owned `CallToolResult` builders, byte-for-byte equivalent to the
3
+ * mcp-use v1 response helpers (`text` / `object` / `error`) the registrars
4
+ * used to import. The v2 migration guide deprecates those helpers in favour
5
+ * of raw result structures; owning the three shapes the toolkit actually
6
+ * emits keeps the wire output identical across the swap and survives their
7
+ * eventual upstream removal.
8
+ */
9
+ /** A plain-text tool result (`text/plain` mime hint), as mcp-use's `text()` emitted. */
10
+ export function textResult(content) {
11
+ return {
12
+ content: [{ type: "text", text: content }],
13
+ _meta: { mimeType: "text/plain" },
14
+ };
15
+ }
16
+ /**
17
+ * An object tool result: pretty-printed JSON text plus `structuredContent`,
18
+ * as mcp-use's `object()` emitted for non-array payloads (the registrars wrap
19
+ * arrays into `{ data }` before calling this — see `toStructuredContent`).
20
+ */
21
+ export function objectResult(data) {
22
+ return {
23
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
24
+ structuredContent: data,
25
+ _meta: { mimeType: "application/json" },
26
+ };
27
+ }
28
+ /**
29
+ * An error tool result. The literal `isError: true` matters: tools with an
30
+ * `outputSchema` (every view-bound tool) have a callback type demanding
31
+ * either matching `structuredContent` or an explicit `isError: true` result.
32
+ */
33
+ export function errorResult(message) {
34
+ return {
35
+ isError: true,
36
+ content: [{ type: "text", text: message }],
37
+ };
38
+ }
39
+ //# sourceMappingURL=tool-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-results.js","sourceRoot":"","sources":["../../src/tools/tool-results.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wFAAwF;AACxF,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACnD,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE;KAClC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAoC,IAAO;IACrE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACzE,iBAAiB,EAAE,IAAI;QACvB,KAAK,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE;KACxC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO;QACL,OAAO,EAAE,IAAa;QACtB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KACpD,CAAA;AACH,CAAC"}
@@ -1,16 +1,22 @@
1
- import { error } from "mcp-use/server";
1
+ import { errorResult } from "./tool-results.js";
2
2
  /**
3
3
  * Wraps a raw `server.tool()` handler so thrown exceptions surface as the same
4
- * `error("[code] message")` tool result the toolkit's registrars produce. This
5
- * is the single source of truth for the registrar error format — both
4
+ * `[code] message` error result the toolkit's registrars produce. This is the
5
+ * single source of truth for the registrar error format — both
6
6
  * `createToolRegistrar` and `createWidgetToolRegistrar` route their `catch`
7
7
  * paths through here, and tools that bypass the registrars (widget tools,
8
- * `*_data` feeds) can wrap their handlers to follow the house "use `error()`,
9
- * don't throw" convention.
8
+ * `*_data` feeds) can wrap their handlers to follow the house "return an
9
+ * error result, don't throw" convention.
10
10
  *
11
11
  * Code precedence matches the registrars: an HTTP-ish `status` (e.g. `404`)
12
12
  * wins over a domain error `code` (e.g. `ENGINE_NOT_SELECTED`); both may be a
13
13
  * `string` or `number`. When neither is present the message is returned as-is.
14
+ *
15
+ * The error branch (`errorResult`) carries a literal `isError: true`: tools
16
+ * with an `outputSchema` — every view-bound tool since the native-views move —
17
+ * have a callback type demanding either matching `structuredContent` or an
18
+ * explicit `isError: true` result, and the literal is what lets wrapped
19
+ * handlers register without casts.
14
20
  */
15
- export declare function withToolErrors<TArgs extends unknown[], TResult>(handler: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<TResult | ReturnType<typeof error>>;
21
+ export declare function withToolErrors<TArgs extends unknown[], TResult>(handler: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<TResult | ReturnType<typeof errorResult>>;
16
22
  //# sourceMappingURL=with-tool-errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-tool-errors.d.ts","sourceRoot":"","sources":["../../src/tools/with-tool-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EAC7D,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAWjE"}
1
+ {"version":3,"file":"with-tool-errors.d.ts","sourceRoot":"","sources":["../../src/tools/with-tool-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EAC7D,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAWvE"}
@@ -1,16 +1,22 @@
1
- import { error } from "mcp-use/server";
1
+ import { errorResult } from "./tool-results.js";
2
2
  /**
3
3
  * Wraps a raw `server.tool()` handler so thrown exceptions surface as the same
4
- * `error("[code] message")` tool result the toolkit's registrars produce. This
5
- * is the single source of truth for the registrar error format — both
4
+ * `[code] message` error result the toolkit's registrars produce. This is the
5
+ * single source of truth for the registrar error format — both
6
6
  * `createToolRegistrar` and `createWidgetToolRegistrar` route their `catch`
7
7
  * paths through here, and tools that bypass the registrars (widget tools,
8
- * `*_data` feeds) can wrap their handlers to follow the house "use `error()`,
9
- * don't throw" convention.
8
+ * `*_data` feeds) can wrap their handlers to follow the house "return an
9
+ * error result, don't throw" convention.
10
10
  *
11
11
  * Code precedence matches the registrars: an HTTP-ish `status` (e.g. `404`)
12
12
  * wins over a domain error `code` (e.g. `ENGINE_NOT_SELECTED`); both may be a
13
13
  * `string` or `number`. When neither is present the message is returned as-is.
14
+ *
15
+ * The error branch (`errorResult`) carries a literal `isError: true`: tools
16
+ * with an `outputSchema` — every view-bound tool since the native-views move —
17
+ * have a callback type demanding either matching `structuredContent` or an
18
+ * explicit `isError: true` result, and the literal is what lets wrapped
19
+ * handlers register without casts.
14
20
  */
15
21
  export function withToolErrors(handler) {
16
22
  return async (...args) => {
@@ -21,7 +27,7 @@ export function withToolErrors(handler) {
21
27
  const message = e instanceof Error ? e.message : String(e);
22
28
  const { status, code } = (e ?? {});
23
29
  const errorCode = status ?? code;
24
- return error(errorCode ? `[${errorCode}] ${message}` : message);
30
+ return errorResult(errorCode ? `[${errorCode}] ${message}` : message);
25
31
  }
26
32
  };
27
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"with-tool-errors.js","sourceRoot":"","sources":["../../src/tools/with-tool-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA6C;IAE7C,OAAO,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QAC/B,CAAC;QAAC,OAAO,CAAC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@ export interface AppPlugin<TServer = unknown> {
32
32
  appConfig?: Record<string, unknown>;
33
33
  registerTools?: (server: TServer) => void;
34
34
  /**
35
- * Registers the plugin's widget tools against the shared app resource.
36
- * The optional `metaDefaults` carry app-level widget `_meta` defaults
37
- * (currently the Apps SDK CSP) — forward them into
38
- * `createWidgetToolRegistrar` / `uiMeta` so every widget tool advertises
39
- * the same contract as the framework's own `render-view`. Implementations
40
- * may ignore the parameter; their tools then simply omit those keys.
35
+ * Registers the plugin's widget tools. Model-visible widget tools bind a
36
+ * view named after the tool (see `createWidgetToolRegistrar`);
37
+ * `createFrameworkApp` collects those bindings and primes the view registry
38
+ * with the shared app bundle. The optional `metaDefaults` carry app-level
39
+ * widget defaults (the Apps SDK CSP and its camelCase view-CSP sibling) —
40
+ * forward them into `createWidgetToolRegistrar` so every widget tool
41
+ * advertises the same contract as the framework's own `render-view`.
42
+ * Implementations may ignore the parameter; their tools then simply omit
43
+ * those keys.
41
44
  */
42
- registerWidgetTools?: (server: TServer, resourceUri: string, metaDefaults?: WidgetToolMetaDefaults) => void;
45
+ registerWidgetTools?: (server: TServer, metaDefaults?: WidgetToolMetaDefaults) => void;
43
46
  }
44
47
  //# sourceMappingURL=app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/types/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IAMZ,KAAK,EAAE,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAA;IACpC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,OAAO;IAC1C,UAAU,EAAE,aAAa,CAAA;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,CACpB,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,sBAAsB,KAClC,IAAI,CAAA;CACV"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/types/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IAMZ,KAAK,EAAE,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAA;IACpC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,OAAO;IAC1C,UAAU,EAAE,aAAa,CAAA;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAA;CACvF"}
@@ -5,6 +5,6 @@ export type { AppDefinition, AppPlugin } from "./app.js";
5
5
  export type { PipelineConfig, PipelineStepRef } from "./pipeline.js";
6
6
  export type { AppConfig, AppConfigEntry, ValidationResult } from "./config.js";
7
7
  export type { ViewStructuredContent, StepDataEntry, RefreshParams } from "./view-data.js";
8
- export { APP_ONLY_META, uiMeta } from "./meta.js";
9
- export type { UiMetaOptions, UiToolMeta, WidgetCspMeta, WidgetToolMetaDefaults } from "./meta.js";
8
+ export { appsSdkMeta, viewResourceUri, VIEW_RESOURCE_URI_PREFIX } from "./meta.js";
9
+ export type { AppsSdkMetaOptions, AppResourceCsp, WidgetCspMeta, WidgetToolMetaDefaults, } from "./meta.js";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3E,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAC/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC5E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACxD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9E,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3E,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAC/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC5E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACxD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9E,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAClF,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,sBAAsB,GACvB,MAAM,WAAW,CAAA"}
@@ -1,2 +1,2 @@
1
- export { APP_ONLY_META, uiMeta } from "./meta.js";
1
+ export { appsSdkMeta, viewResourceUri, VIEW_RESOURCE_URI_PREFIX } from "./meta.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA"}
@@ -1,36 +1,55 @@
1
1
  /**
2
- * Shared `_meta` shapes for widget tools: the SEP-1865 tool-visibility
3
- * convention plus the dual-protocol widget contract (MCP Apps + OpenAI
4
- * Apps SDK) that ext-apps hosts key on.
2
+ * Shared `_meta` shapes for widget tools.
5
3
  *
6
- * Browser-bundle-safe: this module is a pure object/function with no
7
- * `mcp-use/server` or `node:*` imports, so it can be re-exported from the core
8
- * Root barrel and consumed by UI bundles as well as server registrars. The
9
- * dual-protocol key literals are therefore written out here instead of being
10
- * imported from `mcp-use/server`; `meta.test.ts` pins them against the
11
- * adapters mcp-use itself emits (`McpAppsAdapter`/`AppsSdkAdapter`), so a
12
- * contract drift in a future mcp-use bump fails CI instead of silently
13
- * breaking widget rendering on Claude Desktop / claude.ai again.
4
+ * Since the native-views move the MCP Apps half of the widget contract
5
+ * (`_meta.ui.resourceUri`, flat `ui/resourceUri`, `_meta.ui.visibility`, the
6
+ * resource CSP) is emitted by mcp-use itself from the first-class
7
+ * `ToolDefinition.view` / `.visibility` fields — the toolkit no longer stamps
8
+ * any `ui` keys. What remains toolkit-owned is the OpenAI Apps SDK half
9
+ * (`openai/*` keys), which mcp-use does not derive: {@link appsSdkMeta} builds
10
+ * it, and mcp-use passes non-`ui` `_meta` entries through to `tools/list`
11
+ * untouched.
14
12
  *
15
- * SEP-1865 (`_meta.ui.visibility`): conforming MCP hosts hide tools marked
16
- * `visibility: ["app"]` from the LLM's `tools/list` while keeping them callable
17
- * from inside a widget iframe via `callTool`. Non-conforming hosts ignore the
18
- * marker and fall back to the tool description.
13
+ * Browser-bundle-safe: this module is pure objects/functions with no mcp-use
14
+ * or `node:*` imports, so it can be re-exported from the core root barrel and
15
+ * consumed by UI bundles as well as server registrars.
19
16
  */
20
17
  /**
21
- * App-only marker — hides a tool from the LLM tool surface while leaving it
22
- * callable from widgets. Deliberately carries no `resourceUri`: app-only tools
23
- * (`*_data` feeds, catalogue/refresh hooks) return JSON, they do not render UI.
18
+ * URI scheme prefix mcp-use uses for view resources. Mirrors
19
+ * `UI_RESOURCE_URI_PREFIX`, which mcp-use 2.x keeps in an internal `views/`
20
+ * module without a package export; the wire contract is pinned by
21
+ * `view-binding.test.ts` against a real server, so a drift in an upstream
22
+ * bump fails CI instead of silently breaking Apps SDK hosts.
24
23
  */
25
- export declare const APP_ONLY_META: {
26
- readonly ui: {
27
- readonly visibility: readonly ["app"];
28
- };
29
- };
24
+ export declare const VIEW_RESOURCE_URI_PREFIX = "ui://views/";
30
25
  /**
31
- * The Apps SDK `openai/widgetCSP` shape (snake_cased, as emitted on the wire
32
- * by mcp-use's `AppsSdkAdapter`). All domains are full origins
33
- * (e.g. `https://server.example`).
26
+ * The stable `ui://` resource URI mcp-use assigns to a registered view name —
27
+ * `ui://views/<name>.html`. Widget registrars use it to point the Apps SDK
28
+ * `openai/outputTemplate` key at the same resource the MCP Apps `view`
29
+ * binding renders.
30
+ */
31
+ export declare function viewResourceUri(viewName: string): string;
32
+ /**
33
+ * CSP advertised on a view resource, in the SEP-1865 camelCase shape mcp-use
34
+ * expects on `ToolDefinition.view.csp` (`_meta.ui.csp` on the wire). All
35
+ * entries are full origins (e.g. `https://server.example`). mcp-use appends
36
+ * the request-resolved server origin to connect/resource domains itself, so
37
+ * this only needs origins *other* than the server (e.g. a CDN or an API the
38
+ * widget fetches directly).
39
+ */
40
+ export interface AppResourceCsp {
41
+ /** Origins allowed for fetch/XHR/WebSocket from inside the widget iframe. */
42
+ connectDomains?: string[];
43
+ /** Origins allowed for images, scripts, stylesheets, fonts. */
44
+ resourceDomains?: string[];
45
+ /** Allowed iframe origins. */
46
+ frameDomains?: string[];
47
+ /** Allowed `base-uri` origins. */
48
+ baseUriDomains?: string[];
49
+ }
50
+ /**
51
+ * The Apps SDK `openai/widgetCSP` shape (snake_cased, as Apps SDK hosts read
52
+ * it). All domains are full origins (e.g. `https://server.example`).
34
53
  */
35
54
  export interface WidgetCspMeta {
36
55
  /** Origins allowed for fetch/XHR/WebSocket from inside the widget iframe. */
@@ -43,27 +62,32 @@ export interface WidgetCspMeta {
43
62
  base_uri_domains?: string[];
44
63
  }
45
64
  /**
46
- * Per-app widget-tool `_meta` defaults the framework threads into each
47
- * plugin's `registerWidgetTools` hook (third parameter) so every widget tool
48
- * can advertise them without knowing app-level configuration.
65
+ * Per-app widget-tool defaults the framework threads into each plugin's
66
+ * `registerWidgetTools` hook (second parameter) so every widget tool can
67
+ * advertise them without knowing app-level configuration.
49
68
  */
50
69
  export interface WidgetToolMetaDefaults {
51
70
  /** Content-security policy advertised to Apps SDK hosts (`openai/widgetCSP`). */
52
71
  widgetCSP?: WidgetCspMeta;
72
+ /**
73
+ * CSP for the tool's `view` binding (`_meta.ui.csp` on the view resource) —
74
+ * the camelCase sibling of {@link WidgetToolMetaDefaults.widgetCSP}, both
75
+ * derived from `createFrameworkApp`'s `app.csp`.
76
+ */
77
+ viewCsp?: AppResourceCsp;
53
78
  }
54
- /** Options for {@link uiMeta}. */
55
- export interface UiMetaOptions {
79
+ /** Options for {@link appsSdkMeta}. */
80
+ export interface AppsSdkMetaOptions {
56
81
  /**
57
- * The MCP UI resource URI hosting the widget bundle. When set, the host
58
- * renders the tool result into that resource instead of returning it.
82
+ * The `ui://` resource URI of the view rendering this tool's result —
83
+ * `viewResourceUri(<view name>)` for a view-bound tool. Emitted as
84
+ * `openai/outputTemplate` so Apps SDK hosts render the widget instead of
85
+ * the raw result.
59
86
  */
60
- resourceUri?: string;
61
- /** When `true`, marks the tool app-only via SEP-1865 `visibility: ["app"]`. */
62
- appOnly?: boolean;
87
+ resourceUri: string;
63
88
  /**
64
89
  * Display name used to derive the default `invoking`/`invoked` status
65
- * strings (mirroring mcp-use's `Loading <name>...` / `<name> ready`
66
- * defaults). Typically the tool title.
90
+ * strings (`Loading <name>...` / `<name> ready`). Typically the tool title.
67
91
  */
68
92
  title?: string;
69
93
  /** Host status line while the tool call runs (`openai/toolInvocation/invoking`). */
@@ -75,25 +99,18 @@ export interface UiMetaOptions {
75
99
  /** Content-security policy advertised to Apps SDK hosts (`openai/widgetCSP`). */
76
100
  widgetCSP?: WidgetCspMeta;
77
101
  }
78
- /** Return shape of {@link uiMeta}: the nested `ui` block plus flat wire keys. */
79
- export interface UiToolMeta extends Record<string, unknown> {
80
- ui: Record<string, unknown>;
81
- }
82
102
  /**
83
- * Builds the `_meta` object for a tool from a {@link UiMetaOptions}, keeping
84
- * the SEP-1865 visibility / resourceUri literals in one place. Omitted fields
85
- * are left off entirely so the emitted `_meta` matches the hand-written
86
- * literals it replaces.
103
+ * Builds the OpenAI Apps SDK half of the widget-tool `_meta` — the `openai/*`
104
+ * keys Apps SDK hosts key on to recognise a tool as widget-producing and to
105
+ * deliver `structuredContent` to the iframe. The MCP Apps half (`_meta.ui`)
106
+ * is emitted natively by mcp-use from the tool's `view` / `visibility`
107
+ * fields; never stamp `ui` keys by hand — mcp-use overwrites that namespace
108
+ * on `tools/list`.
87
109
  *
88
- * Widget-RENDERING tools (a `resourceUri` and not app-only) additionally get
89
- * the dual-protocol widget contract that mcp-use emits natively for `mcpApps`
90
- * widgets — the flat SEP-1865 key plus the `openai/*` Apps SDK keys. Ext-apps
91
- * hosts (Claude Desktop / claude.ai) key on these to recognise the tool as
92
- * widget-producing and to deliver `structuredContent` to the iframe; without
93
- * them every widget hangs on its loading skeleton. App-only tools stay free
94
- * of the widget keys on purpose: their results are consumed by an already
95
- * rendered widget via `callTool`, and advertising an output template would
96
- * invite hosts to render them.
110
+ * Only for widget-RENDERING (model-visible, view-bound) tools. App-only tools
111
+ * stay free of these keys on purpose: their results are consumed by an
112
+ * already rendered widget via `callTool`, and advertising an output template
113
+ * would invite hosts to render them.
97
114
  */
98
- export declare function uiMeta(opts: UiMetaOptions): UiToolMeta;
115
+ export declare function appsSdkMeta(opts: AppsSdkMetaOptions): Record<string, unknown>;
99
116
  //# sourceMappingURL=meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/types/meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;CAA2C,CAAA;AAErE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,MAAM,EAAE,CA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AAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iFAAiF;IACjF,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAe7E"}
@@ -1,66 +1,62 @@
1
1
  /**
2
- * Shared `_meta` shapes for widget tools: the SEP-1865 tool-visibility
3
- * convention plus the dual-protocol widget contract (MCP Apps + OpenAI
4
- * Apps SDK) that ext-apps hosts key on.
2
+ * Shared `_meta` shapes for widget tools.
5
3
  *
6
- * Browser-bundle-safe: this module is a pure object/function with no
7
- * `mcp-use/server` or `node:*` imports, so it can be re-exported from the core
8
- * Root barrel and consumed by UI bundles as well as server registrars. The
9
- * dual-protocol key literals are therefore written out here instead of being
10
- * imported from `mcp-use/server`; `meta.test.ts` pins them against the
11
- * adapters mcp-use itself emits (`McpAppsAdapter`/`AppsSdkAdapter`), so a
12
- * contract drift in a future mcp-use bump fails CI instead of silently
13
- * breaking widget rendering on Claude Desktop / claude.ai again.
4
+ * Since the native-views move the MCP Apps half of the widget contract
5
+ * (`_meta.ui.resourceUri`, flat `ui/resourceUri`, `_meta.ui.visibility`, the
6
+ * resource CSP) is emitted by mcp-use itself from the first-class
7
+ * `ToolDefinition.view` / `.visibility` fields — the toolkit no longer stamps
8
+ * any `ui` keys. What remains toolkit-owned is the OpenAI Apps SDK half
9
+ * (`openai/*` keys), which mcp-use does not derive: {@link appsSdkMeta} builds
10
+ * it, and mcp-use passes non-`ui` `_meta` entries through to `tools/list`
11
+ * untouched.
14
12
  *
15
- * SEP-1865 (`_meta.ui.visibility`): conforming MCP hosts hide tools marked
16
- * `visibility: ["app"]` from the LLM's `tools/list` while keeping them callable
17
- * from inside a widget iframe via `callTool`. Non-conforming hosts ignore the
18
- * marker and fall back to the tool description.
13
+ * Browser-bundle-safe: this module is pure objects/functions with no mcp-use
14
+ * or `node:*` imports, so it can be re-exported from the core root barrel and
15
+ * consumed by UI bundles as well as server registrars.
19
16
  */
20
17
  /**
21
- * App-only marker — hides a tool from the LLM tool surface while leaving it
22
- * callable from widgets. Deliberately carries no `resourceUri`: app-only tools
23
- * (`*_data` feeds, catalogue/refresh hooks) return JSON, they do not render UI.
18
+ * URI scheme prefix mcp-use uses for view resources. Mirrors
19
+ * `UI_RESOURCE_URI_PREFIX`, which mcp-use 2.x keeps in an internal `views/`
20
+ * module without a package export; the wire contract is pinned by
21
+ * `view-binding.test.ts` against a real server, so a drift in an upstream
22
+ * bump fails CI instead of silently breaking Apps SDK hosts.
24
23
  */
25
- export const APP_ONLY_META = { ui: { visibility: ["app"] } };
24
+ export const VIEW_RESOURCE_URI_PREFIX = "ui://views/";
26
25
  /**
27
- * Builds the `_meta` object for a tool from a {@link UiMetaOptions}, keeping
28
- * the SEP-1865 visibility / resourceUri literals in one place. Omitted fields
29
- * are left off entirely so the emitted `_meta` matches the hand-written
30
- * literals it replaces.
26
+ * The stable `ui://` resource URI mcp-use assigns to a registered view name —
27
+ * `ui://views/<name>.html`. Widget registrars use it to point the Apps SDK
28
+ * `openai/outputTemplate` key at the same resource the MCP Apps `view`
29
+ * binding renders.
30
+ */
31
+ export function viewResourceUri(viewName) {
32
+ return `${VIEW_RESOURCE_URI_PREFIX}${viewName}.html`;
33
+ }
34
+ /**
35
+ * Builds the OpenAI Apps SDK half of the widget-tool `_meta` — the `openai/*`
36
+ * keys Apps SDK hosts key on to recognise a tool as widget-producing and to
37
+ * deliver `structuredContent` to the iframe. The MCP Apps half (`_meta.ui`)
38
+ * is emitted natively by mcp-use from the tool's `view` / `visibility`
39
+ * fields; never stamp `ui` keys by hand — mcp-use overwrites that namespace
40
+ * on `tools/list`.
31
41
  *
32
- * Widget-RENDERING tools (a `resourceUri` and not app-only) additionally get
33
- * the dual-protocol widget contract that mcp-use emits natively for `mcpApps`
34
- * widgets — the flat SEP-1865 key plus the `openai/*` Apps SDK keys. Ext-apps
35
- * hosts (Claude Desktop / claude.ai) key on these to recognise the tool as
36
- * widget-producing and to deliver `structuredContent` to the iframe; without
37
- * them every widget hangs on its loading skeleton. App-only tools stay free
38
- * of the widget keys on purpose: their results are consumed by an already
39
- * rendered widget via `callTool`, and advertising an output template would
40
- * invite hosts to render them.
42
+ * Only for widget-RENDERING (model-visible, view-bound) tools. App-only tools
43
+ * stay free of these keys on purpose: their results are consumed by an
44
+ * already rendered widget via `callTool`, and advertising an output template
45
+ * would invite hosts to render them.
41
46
  */
42
- export function uiMeta(opts) {
43
- const ui = {};
44
- if (opts.resourceUri !== undefined)
45
- ui.resourceUri = opts.resourceUri;
46
- if (opts.appOnly)
47
- ui.visibility = ["app"];
48
- const meta = { ui };
49
- if (opts.resourceUri !== undefined && !opts.appOnly) {
50
- meta["ui/resourceUri"] = opts.resourceUri;
51
- meta["openai/outputTemplate"] = opts.resourceUri;
52
- meta["openai/toolInvocation/invoking"] =
53
- opts.invoking ?? (opts.title ? `Loading ${opts.title}...` : "Loading view...");
54
- meta["openai/toolInvocation/invoked"] =
55
- opts.invoked ?? (opts.title ? `${opts.title} ready` : "View ready");
56
- meta["openai/widgetAccessible"] = true;
57
- meta["openai/resultCanProduceWidget"] = true;
58
- if (opts.widgetDescription !== undefined) {
59
- meta["openai/widgetDescription"] = opts.widgetDescription;
60
- }
61
- if (opts.widgetCSP !== undefined)
62
- meta["openai/widgetCSP"] = opts.widgetCSP;
47
+ export function appsSdkMeta(opts) {
48
+ const meta = {
49
+ "openai/outputTemplate": opts.resourceUri,
50
+ "openai/toolInvocation/invoking": opts.invoking ?? (opts.title ? `Loading ${opts.title}...` : "Loading view..."),
51
+ "openai/toolInvocation/invoked": opts.invoked ?? (opts.title ? `${opts.title} ready` : "View ready"),
52
+ "openai/widgetAccessible": true,
53
+ "openai/resultCanProduceWidget": true,
54
+ };
55
+ if (opts.widgetDescription !== undefined) {
56
+ meta["openai/widgetDescription"] = opts.widgetDescription;
63
57
  }
58
+ if (opts.widgetCSP !== undefined)
59
+ meta["openai/widgetCSP"] = opts.widgetCSP;
64
60
  return meta;
65
61
  }
66
62
  //# sourceMappingURL=meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/types/meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,EAAW,CAAA;AA0DrE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAC,I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"file":"meta.js","sourceRoot":"","sources":["../../src/types/meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,aAAa,CAAA;AAErD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,GAAG,wBAAwB,GAAG,QAAQ,OAAO,CAAA;AACtD,CAAC;AA4ED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,IAAI,GAA4B;QACpC,uBAAuB,EAAE,IAAI,CAAC,WAAW;QACzC,gCAAgC,EAC9B,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAChF,+BAA+B,EAC7B,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC;QACrE,yBAAyB,EAAE,IAAI;QAC/B,+BAA+B,EAAE,IAAI;KACtC,CAAA;IACD,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAA;IAC3D,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAAE,IAAI,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,SAAS,CAAA;IAC3E,OAAO,IAAI,CAAA;AACb,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@miragon/mcp-toolkit-core",
3
- "version": "0.10.1",
3
+ "version": "1.1.0",
4
4
  "description": "Framework runtime for MCP servers: plugin contract, step/widget registries, pipeline executor, render-view helpers.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Miragon/mcp-toolkit.git",
8
+ "directory": "packages/core"
9
+ },
5
10
  "type": "module",
6
11
  "sideEffects": false,
7
12
  "main": "dist/index.js",
@@ -28,18 +33,20 @@
28
33
  "access": "public"
29
34
  },
30
35
  "peerDependencies": {
31
- "@modelcontextprotocol/sdk": "1.29.0",
32
- "mcp-use": "1.34.5",
36
+ "mcp-use": "2.1.0",
33
37
  "zod": "4.4.3"
34
38
  },
35
39
  "devDependencies": {
36
- "@modelcontextprotocol/sdk": "1.29.0",
37
- "@types/node": "26.1.1",
38
- "mcp-use": "1.34.5",
40
+ "@modelcontextprotocol/server": "2.0.0",
41
+ "@types/node": "26.1.2",
42
+ "mcp-use": "2.1.0",
39
43
  "typescript": "6.0.3",
40
44
  "vitest": "4.1.10",
41
45
  "zod": "4.4.3"
42
46
  },
47
+ "engines": {
48
+ "node": ">=22.22.2"
49
+ },
43
50
  "scripts": {
44
51
  "build": "tsc -p tsconfig.build.json",
45
52
  "typecheck": "tsc --noEmit",
@@ -1,28 +0,0 @@
1
- export interface DeriveAppResourceUriInput {
2
- /** Server / app name used as the resource URI authority (`ui://<appName>/...`). */
3
- appName: string;
4
- /** Absolute path to the bundled `mcp-app.html` served under the URI. */
5
- htmlPath: string;
6
- /**
7
- * Resource URI used when the bundle file is missing (e.g. `dist` not built
8
- * yet in a dev loop). Defaults to `ui://<appName>/mcp-app.dev.html` so a
9
- * stable, obviously-non-production URI is still served. Pass a custom value
10
- * only when a different placeholder is needed.
11
- */
12
- devFallback?: string;
13
- }
14
- /**
15
- * Derives a content-hashed MCP UI resource URI for the widget bundle.
16
- *
17
- * MCP hosts cache the widget bundle by its resource URI; with a fixed URI a
18
- * host keeps serving a stale bundle even across server restarts. Hashing the
19
- * file content into the URI (`ui://<appName>/mcp-app.<hash>.html`) forces a
20
- * fresh fetch whenever the bundle actually changes — and only then.
21
- *
22
- * When the bundle file cannot be read (commonly `dist` not built yet), it
23
- * falls back to {@link DeriveAppResourceUriInput.devFallback} — a stable
24
- * `ui://<appName>/mcp-app.dev.html` by default — and emits a boot warning so
25
- * the missing file is visible in logs rather than silently degrading.
26
- */
27
- export declare function deriveAppResourceUri(input: DeriveAppResourceUriInput): string;
28
- //# sourceMappingURL=app-resource-uri.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-resource-uri.d.ts","sourceRoot":"","sources":["../../src/tools/app-resource-uri.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAc7E"}
@@ -1,30 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { readFileSync } from "node:fs";
3
- /**
4
- * Derives a content-hashed MCP UI resource URI for the widget bundle.
5
- *
6
- * MCP hosts cache the widget bundle by its resource URI; with a fixed URI a
7
- * host keeps serving a stale bundle even across server restarts. Hashing the
8
- * file content into the URI (`ui://<appName>/mcp-app.<hash>.html`) forces a
9
- * fresh fetch whenever the bundle actually changes — and only then.
10
- *
11
- * When the bundle file cannot be read (commonly `dist` not built yet), it
12
- * falls back to {@link DeriveAppResourceUriInput.devFallback} — a stable
13
- * `ui://<appName>/mcp-app.dev.html` by default — and emits a boot warning so
14
- * the missing file is visible in logs rather than silently degrading.
15
- */
16
- export function deriveAppResourceUri(input) {
17
- const { appName, htmlPath } = input;
18
- const devFallback = input.devFallback ?? `ui://${appName}/mcp-app.dev.html`;
19
- try {
20
- const hash = createHash("sha256").update(readFileSync(htmlPath)).digest("hex").slice(0, 10);
21
- return `ui://${appName}/mcp-app.${hash}.html`;
22
- }
23
- catch {
24
- console.warn(`[mcp-toolkit] could not read widget bundle at "${htmlPath}" — ` +
25
- `serving the dev fallback resource URI "${devFallback}". ` +
26
- `Build the bundle (dist/mcp-app.html) before shipping to production.`);
27
- return devFallback;
28
- }
29
- }
30
- //# sourceMappingURL=app-resource-uri.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-resource-uri.js","sourceRoot":"","sources":["../../src/tools/app-resource-uri.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAgBtC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IACnC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,QAAQ,OAAO,mBAAmB,CAAA;IAC3E,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAC3F,OAAO,QAAQ,OAAO,YAAY,IAAI,OAAO,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,IAAI,CACV,kDAAkD,QAAQ,MAAM;YAC9D,0CAA0C,WAAW,KAAK;YAC1D,qEAAqE,CACxE,CAAA;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;AACH,CAAC"}