mcp-use 2.0.0-beta.4 → 2.0.0-beta.6

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 (60) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-AQ2ZZM2P.js → chunk-DQ7LE4ZA.js} +57 -13
  3. package/dist/chunk-DQ7LE4ZA.js.map +1 -0
  4. package/dist/{chunk-SFI2T6TE.js → chunk-PMPGMSYA.js} +8 -1
  5. package/dist/chunk-PMPGMSYA.js.map +1 -0
  6. package/dist/cli/build.d.ts.map +1 -1
  7. package/dist/cli/dev.d.ts.map +1 -1
  8. package/dist/cli/tools-declaration.d.ts +22 -0
  9. package/dist/cli/tools-declaration.d.ts.map +1 -0
  10. package/dist/commands/build.js +5 -1
  11. package/dist/commands/build.js.map +1 -1
  12. package/dist/commands/dev.js +5 -1
  13. package/dist/commands/dev.js.map +1 -1
  14. package/dist/config.d.ts +41 -0
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/fetch-app.d.ts +17 -0
  17. package/dist/fetch-app.d.ts.map +1 -1
  18. package/dist/index.d.ts +14 -4
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +451 -57
  21. package/dist/index.js.map +1 -1
  22. package/dist/inspector-shell.d.ts +6 -0
  23. package/dist/inspector-shell.d.ts.map +1 -1
  24. package/dist/middleware/cors.d.ts +11 -0
  25. package/dist/middleware/cors.d.ts.map +1 -0
  26. package/dist/middleware/mcp-middleware.d.ts +135 -0
  27. package/dist/middleware/mcp-middleware.d.ts.map +1 -0
  28. package/dist/mount-mcp.d.ts +0 -4
  29. package/dist/mount-mcp.d.ts.map +1 -1
  30. package/dist/oauth/index.js +1 -1
  31. package/dist/{public-route-7IK5D7V7.js → public-route-26FUVRO5.js} +5 -3
  32. package/dist/public-route-26FUVRO5.js.map +1 -0
  33. package/dist/react/hooks/use-files.d.ts +25 -0
  34. package/dist/react/hooks/use-files.d.ts.map +1 -0
  35. package/dist/react/index.d.ts +2 -0
  36. package/dist/react/index.d.ts.map +1 -1
  37. package/dist/react/index.js +66 -2
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/react/runtime/view-runtime.d.ts +23 -0
  40. package/dist/react/runtime/view-runtime.d.ts.map +1 -1
  41. package/dist/react/types/file-types.d.ts +16 -0
  42. package/dist/react/types/file-types.d.ts.map +1 -0
  43. package/dist/react/types/register.d.ts +1 -1
  44. package/dist/react/types/register.d.ts.map +1 -1
  45. package/dist/resources.d.ts +22 -1
  46. package/dist/resources.d.ts.map +1 -1
  47. package/dist/server.d.ts +49 -1
  48. package/dist/server.d.ts.map +1 -1
  49. package/dist/tools.d.ts +12 -1
  50. package/dist/tools.d.ts.map +1 -1
  51. package/dist/views/public-route.d.ts +7 -3
  52. package/dist/views/public-route.d.ts.map +1 -1
  53. package/dist/views/routes.d.ts +2 -0
  54. package/dist/views/routes.d.ts.map +1 -1
  55. package/dist/views/wire.d.ts +7 -3
  56. package/dist/views/wire.d.ts.map +1 -1
  57. package/package.json +2 -2
  58. package/dist/chunk-AQ2ZZM2P.js.map +0 -1
  59. package/dist/chunk-SFI2T6TE.js.map +0 -1
  60. package/dist/public-route-7IK5D7V7.js.map +0 -1
@@ -34,6 +34,12 @@ export declare const DEFAULT_INSPECTOR_ASSETS_URL = "https://cdn.jsdelivr.net/np
34
34
  * strings and fragments are preserved.
35
35
  */
36
36
  export declare function inspectorStylesUrl(assetsUrl: string): string;
37
+ /** True for the default jsDelivr `@mcp-use/inspector@*` CDN bundle URL. */
38
+ export declare function isDefaultJsdelivrInspectorUrl(url: string): boolean;
39
+ /** Append a per-request cache-bust query param for the default jsDelivr CDN URL. */
40
+ export declare function withInspectorCacheBust(assetsUrl: string): string;
41
+ /** True for inspector UI shell routes (SPA), excluding `/inspector/api/*`. */
42
+ export declare function matchesInspectorShellPath(pathname: string, basePath: string): boolean;
37
43
  /** Inputs for {@link renderInspectorShell}. */
38
44
  export interface InspectorShellOptions {
39
45
  /** Server display name, used in the page title. */
@@ -1 +1 @@
1
- {"version":3,"file":"inspector-shell.d.ts","sourceRoot":"","sources":["../src/inspector-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,+EAA2F,CAAC;AAErI;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAuBD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAgE3E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChD,YAAY,GAAG,SAAS,CAgC1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C"}
1
+ {"version":3,"file":"inspector-shell.d.ts","sourceRoot":"","sources":["../src/inspector-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,+EAA2F,CAAC;AAErI;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,oFAAoF;AACpF,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAOT;AAED,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAuBD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAiE3E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChD,YAAY,GAAG,SAAS,CA+B1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C"}
@@ -0,0 +1,11 @@
1
+ import type { CorsOptions } from "../config.js";
2
+ import type { FetchMiddleware } from "../fetch-app.js";
3
+ /**
4
+ * Fetch middleware that adds CORS headers to every response.
5
+ *
6
+ * @internal Wired from {@link MCPServer} when `ServerConfig.cors` is set.
7
+ */
8
+ export declare function corsFetchMiddleware(options: CorsOptions): FetchMiddleware;
9
+ /** Whether global CORS middleware owns response headers for view assets. */
10
+ export declare function isGlobalCorsEnabled(cors: CorsOptions | undefined): boolean;
11
+ //# sourceMappingURL=cors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/middleware/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgFvD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CA0BzE;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAE1E"}
@@ -0,0 +1,135 @@
1
+ import type { AuthInfo } from "@modelcontextprotocol/server";
2
+ /**
3
+ * Context passed to every MCP middleware handler.
4
+ *
5
+ * `params` is mutable — middleware can modify params before calling `next()`
6
+ * and those changes will be visible to downstream middleware and the handler.
7
+ *
8
+ * `state` is a shared Map for passing arbitrary data across middleware in
9
+ * the same chain.
10
+ */
11
+ export interface MiddlewareContext {
12
+ /** MCP method name, e.g. "tools/call", "tools/list", "resources/read" */
13
+ method: string;
14
+ /** JSON-RPC request params (mutable — mutations are passed downstream) */
15
+ params: Record<string, unknown>;
16
+ /** OAuth info extracted from JWT, present when OAuth is configured */
17
+ auth?: AuthInfo;
18
+ /** Shared state Map for passing data across middleware in the same request */
19
+ state: Map<string, unknown>;
20
+ }
21
+ /** Params shape for `tools/call` method */
22
+ interface ToolsCallParams {
23
+ name: string;
24
+ arguments?: Record<string, unknown>;
25
+ _meta?: Record<string, unknown>;
26
+ }
27
+ /** Params shape for `resources/read` method */
28
+ interface ResourcesReadParams {
29
+ uri: string;
30
+ _meta?: Record<string, unknown>;
31
+ }
32
+ /** Params shape for `prompts/get` method */
33
+ interface PromptsGetParams {
34
+ name: string;
35
+ arguments?: Record<string, string>;
36
+ _meta?: Record<string, unknown>;
37
+ }
38
+ /** Context with narrowed `params` for `tools/call` */
39
+ export interface ToolsCallMiddlewareContext extends MiddlewareContext {
40
+ method: "tools/call";
41
+ params: ToolsCallParams & Record<string, unknown>;
42
+ }
43
+ /** Context with narrowed `params` for `resources/read` */
44
+ export interface ResourcesReadMiddlewareContext extends MiddlewareContext {
45
+ method: "resources/read";
46
+ params: ResourcesReadParams & Record<string, unknown>;
47
+ }
48
+ /** Context with narrowed `params` for `prompts/get` */
49
+ export interface PromptsGetMiddlewareContext extends MiddlewareContext {
50
+ method: "prompts/get";
51
+ params: PromptsGetParams & Record<string, unknown>;
52
+ }
53
+ /**
54
+ * Map from MCP middleware pattern strings to their narrowed context type.
55
+ * Used by `McpMiddlewareFnFor<P>` to infer the correct `ctx` parameter.
56
+ */
57
+ export interface McpMiddlewarePatternMap {
58
+ "tools/call": ToolsCallMiddlewareContext;
59
+ "resources/read": ResourcesReadMiddlewareContext;
60
+ "prompts/get": PromptsGetMiddlewareContext;
61
+ }
62
+ /**
63
+ * A typed MCP middleware function whose `ctx` is narrowed based on the
64
+ * pattern string `P`. Falls back to the base `MiddlewareContext` for
65
+ * wildcard or unrecognized patterns.
66
+ */
67
+ export type McpMiddlewareFnFor<P extends string> = P extends keyof McpMiddlewarePatternMap ? (ctx: McpMiddlewarePatternMap[P], next: () => Promise<unknown>) => Promise<unknown> : McpMiddlewareFn;
68
+ /**
69
+ * A single MCP middleware function.
70
+ *
71
+ * Call `next()` to pass control to the next middleware (or handler).
72
+ * Return its result, or return a different value to override the response.
73
+ * Throw an error to reject the request.
74
+ */
75
+ export type McpMiddlewareFn = (ctx: MiddlewareContext, next: () => Promise<unknown>) => Promise<unknown>;
76
+ /**
77
+ * Internal storage entry for a registered MCP middleware.
78
+ * The pattern is stored with the `mcp:` prefix already stripped.
79
+ * @internal
80
+ */
81
+ export interface McpMiddlewareEntry {
82
+ /** Pattern after stripping "mcp:" — e.g. "tools/call", "tools/*", "*" */
83
+ pattern: string;
84
+ handler: McpMiddlewareFn;
85
+ }
86
+ /** Phase for MCP observer event listeners registered via `server.on()`. */
87
+ export type McpEventPhase = "before" | "complete";
88
+ /**
89
+ * Internal storage entry for a registered MCP observer event listener.
90
+ * @internal
91
+ */
92
+ export interface McpEventListenerEntry {
93
+ pattern: string;
94
+ phase: McpEventPhase;
95
+ handler: McpEventListenerFn | McpCompleteEventListenerFn;
96
+ }
97
+ /** Read-only observer invoked before the MCP handler runs. */
98
+ export type McpEventListenerFn = (ctx: Readonly<MiddlewareContext>) => void;
99
+ /** Read-only observer invoked after the MCP handler completes. */
100
+ export type McpCompleteEventListenerFn = (ctx: Readonly<MiddlewareContext>, result: unknown) => void;
101
+ /**
102
+ * Test whether a registered middleware pattern matches a given MCP method.
103
+ *
104
+ * Matching rules:
105
+ * - `"*"` matches any method
106
+ * - `"tools/*"` prefix-matches any method starting with `"tools/"`
107
+ * - `"tools/call"` exact-matches only `"tools/call"`
108
+ */
109
+ export declare function matchesPattern(pattern: string, method: string): boolean;
110
+ /**
111
+ * Compose a middleware chain for a given MCP method invocation.
112
+ *
113
+ * Filters `entries` to those matching `method`, then builds a `next()` chain
114
+ * with `innerFn` at the center. Returns the outermost callable.
115
+ *
116
+ * Middleware executes in FIFO registration order (first registered = outermost).
117
+ */
118
+ export declare function composeMiddleware(entries: McpMiddlewareEntry[], method: string, innerFn: () => Promise<unknown>): (ctx: MiddlewareContext) => Promise<unknown>;
119
+ /** Build a read-only snapshot of middleware context for observer events. */
120
+ export declare function freezeMiddlewareContext(ctx: MiddlewareContext): Readonly<MiddlewareContext>;
121
+ /**
122
+ * Run before/complete observer listeners around a middleware chain.
123
+ *
124
+ * Listener throws are logged and do not fail the MCP request.
125
+ */
126
+ export declare function runMcpOperation(middlewares: McpMiddlewareEntry[], events: McpEventListenerEntry[], method: string, ctx: MiddlewareContext, innerFn: () => Promise<unknown>): Promise<unknown>;
127
+ /** Strip `mcp:` prefix and optional `:complete` suffix from observer patterns. */
128
+ export declare function parseMcpPattern(raw: string): {
129
+ pattern: string;
130
+ phase: McpEventPhase;
131
+ };
132
+ /** Normalize middleware pattern strings (strip `mcp:` prefix). */
133
+ export declare function normalizeMcpMiddlewarePattern(raw: string): string;
134
+ export {};
135
+ //# sourceMappingURL=mcp-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/mcp-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,sEAAsE;IACtE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B;AAED,2CAA2C;AAC3C,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,+CAA+C;AAC/C,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,4CAA4C;AAC5C,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,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,EAAE,aAAa,CAAC;CACtB,CASA;AAED,kEAAkE;AAClE,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjE"}
@@ -44,8 +44,4 @@ export interface McpMount {
44
44
  * ```
45
45
  */
46
46
  export declare function createMcpMount(factory: McpServerFactory, options?: MountMcpOptions): McpMount;
47
- /**
48
- * @deprecated Use {@link createMcpMount} — returns the same mount without Hono.
49
- */
50
- export declare function mountMcp(factory: McpServerFactory, options?: MountMcpOptions): McpMount;
51
47
  //# sourceMappingURL=mount-mcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount-mcp.d.ts","sourceRoot":"","sources":["../src/mount-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM/E,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,SAAS,CAAC;CACvD;AAED,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,OAAO,EAAE,cAAc,CAAC;IACxB,uEAAuE;IACvE,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAiDV;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAEV"}
1
+ {"version":3,"file":"mount-mcp.d.ts","sourceRoot":"","sources":["../src/mount-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM/E,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,SAAS,CAAC;CACvD;AAED,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,OAAO,EAAE,cAAc,CAAC;IACxB,uEAAuE;IACvE,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAiDV"}
@@ -8,7 +8,7 @@ import {
8
8
  oauthMetadataResponse,
9
9
  requireBearerAuth,
10
10
  verifyBearerToken
11
- } from "../chunk-SFI2T6TE.js";
11
+ } from "../chunk-PMPGMSYA.js";
12
12
  import {
13
13
  oauthCustomProvider
14
14
  } from "../chunk-DPL7OEXC.js";
@@ -36,7 +36,7 @@ async function resolvePublicFilePath(publicRoot, subpath) {
36
36
  }
37
37
  return abs;
38
38
  }
39
- async function servePublicFile(diskPath) {
39
+ async function servePublicFile(diskPath, options = {}) {
40
40
  const { createReadStream } = await import("fs");
41
41
  const { extname } = await import("path");
42
42
  const { Readable } = await import("stream");
@@ -49,7 +49,9 @@ async function servePublicFile(diskPath) {
49
49
  headers: {
50
50
  "Content-Type": contentType,
51
51
  "Cache-Control": "public, max-age=0, must-revalidate",
52
- "Access-Control-Allow-Origin": "*"
52
+ ...options.deferCors !== true && {
53
+ "Access-Control-Allow-Origin": "*"
54
+ }
53
55
  }
54
56
  });
55
57
  }
@@ -57,4 +59,4 @@ export {
57
59
  resolvePublicFilePath,
58
60
  servePublicFile
59
61
  };
60
- //# sourceMappingURL=public-route-7IK5D7V7.js.map
62
+ //# sourceMappingURL=public-route-26FUVRO5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/views/public-route.ts"],"sourcesContent":["const PUBLIC_CONTENT_TYPES: Record<string, string> = {\n \".css\": \"text/css\",\n \".gif\": \"image/gif\",\n \".html\": \"text/html\",\n \".ico\": \"image/x-icon\",\n \".jpeg\": \"image/jpeg\",\n \".jpg\": \"image/jpeg\",\n \".js\": \"application/javascript\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".png\": \"image/png\",\n \".svg\": \"image/svg+xml\",\n \".txt\": \"text/plain\",\n \".webp\": \"image/webp\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n};\n\n/**\n * Resolve a request subpath to an on-disk file under `publicRoot`, rejecting\n * path traversal.\n *\n * @param publicRoot - Absolute path to the `public/` directory on disk.\n * @param subpath - Request path after the `/public/` route prefix.\n * @returns Absolute file path when safe and present, otherwise `null`.\n *\n * @internal\n */\nexport async function resolvePublicFilePath(\n publicRoot: string,\n subpath: string\n): Promise<string | null> {\n const { existsSync } = await import(\"node:fs\");\n const { resolve, sep } = await import(\"node:path\");\n\n if (subpath === \"\" || subpath.includes(\"..\") || subpath.includes(\"\\\\\")) {\n return null;\n }\n const clean = subpath.replace(/^\\/+/, \"\");\n if (clean === \"\" || clean.endsWith(\"/\")) {\n return null;\n }\n const root = resolve(publicRoot);\n const abs = resolve(root, clean);\n if (abs !== root && !abs.startsWith(root + sep)) {\n return null;\n }\n if (!existsSync(abs)) {\n return null;\n }\n return abs;\n}\n\n/**\n * Serve one file from the project's `public/` directory.\n *\n * @param diskPath - Absolute path resolved by {@link resolvePublicFilePath}.\n * @param options - When `deferCors` is true, omit hardcoded `ACAO: *` so global\n * {@link ServerConfig.cors} middleware owns CORS headers.\n * @returns A `Response` with `Cache-Control: public, max-age=0, must-revalidate`\n * and optionally `Access-Control-Allow-Origin: *` so cross-origin sandboxed\n * view iframes can load public files (module scripts and fetches use CORS mode).\n *\n * @internal\n */\nexport async function servePublicFile(\n diskPath: string,\n options: { deferCors?: boolean } = {}\n): Promise<Response> {\n const { createReadStream } = await import(\"node:fs\");\n const { extname } = await import(\"node:path\");\n const { Readable } = await import(\"node:stream\");\n\n const ext = extname(diskPath);\n const contentType = PUBLIC_CONTENT_TYPES[ext] ?? \"application/octet-stream\";\n const nodeStream = createReadStream(diskPath);\n const webStream = Readable.toWeb(nodeStream) as ReadableStream;\n return new Response(webStream, {\n status: 200,\n headers: {\n \"Content-Type\": contentType,\n \"Cache-Control\": \"public, max-age=0, must-revalidate\",\n ...(options.deferCors !== true && {\n \"Access-Control-Allow-Origin\": \"*\",\n }),\n },\n });\n}\n"],"mappings":";AAAA,IAAM,uBAA+C;AAAA,EACnD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AACZ;AAYA,eAAsB,sBACpB,YACA,SACwB;AACxB,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,IAAS;AAC7C,QAAM,EAAE,SAAS,IAAI,IAAI,MAAM,OAAO,MAAW;AAEjD,MAAI,YAAY,MAAM,QAAQ,SAAS,IAAI,KAAK,QAAQ,SAAS,IAAI,GAAG;AACtE,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,QAAQ,QAAQ,QAAQ,EAAE;AACxC,MAAI,UAAU,MAAM,MAAM,SAAS,GAAG,GAAG;AACvC,WAAO;AAAA,EACT;AACA,QAAM,OAAO,QAAQ,UAAU;AAC/B,QAAM,MAAM,QAAQ,MAAM,KAAK;AAC/B,MAAI,QAAQ,QAAQ,CAAC,IAAI,WAAW,OAAO,GAAG,GAAG;AAC/C,WAAO;AAAA,EACT;AACA,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcA,eAAsB,gBACpB,UACA,UAAmC,CAAC,GACjB;AACnB,QAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,IAAS;AACnD,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,MAAW;AAC5C,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,QAAa;AAE/C,QAAM,MAAM,QAAQ,QAAQ;AAC5B,QAAM,cAAc,qBAAqB,GAAG,KAAK;AACjD,QAAM,aAAa,iBAAiB,QAAQ;AAC5C,QAAM,YAAY,SAAS,MAAM,UAAU;AAC3C,SAAO,IAAI,SAAS,WAAW;AAAA,IAC7B,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,GAAI,QAAQ,cAAc,QAAQ;AAAA,QAChC,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,25 @@
1
+ import type { UseFilesResult } from "../types/file-types.js";
2
+ /**
3
+ * Upload and download files through ChatGPT's optional `window.openai`
4
+ * extension.
5
+ *
6
+ * File handling is not part of the MCP Apps bridge. Always check
7
+ * `isSupported` before calling either action; unsupported calls reject with a
8
+ * descriptive error. The hook does not read or update ChatGPT widget state and
9
+ * does not make uploaded files model-visible as a side effect.
10
+ *
11
+ * The returned actions are referentially stable for the lifetime of the
12
+ * mounted runtime.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const { isSupported, upload, getDownloadUrl } = useFiles();
17
+ *
18
+ * if (!isSupported) return <p>File handling requires ChatGPT.</p>;
19
+ *
20
+ * const { fileId } = await upload(file);
21
+ * const { downloadUrl } = await getDownloadUrl({ fileId });
22
+ * ```
23
+ */
24
+ export declare function useFiles(): UseFilesResult;
25
+ //# sourceMappingURL=use-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-files.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CAezC"}
@@ -16,6 +16,7 @@ export { ThemeProvider } from "./components/theme-provider.js";
16
16
  export { ViewControls } from "./components/view-controls.js";
17
17
  export { useCallTool, type CallToolHandle } from "./hooks/use-call-tool.js";
18
18
  export { useDisplayMode } from "./hooks/use-display-mode.js";
19
+ export { useFiles } from "./hooks/use-files.js";
19
20
  export { useHostContext, type HostContextHandle, } from "./hooks/use-host-context.js";
20
21
  export { useOpenExternal } from "./hooks/use-open-external.js";
21
22
  export { useSendFollowUp } from "./hooks/use-send-follow-up.js";
@@ -24,6 +25,7 @@ export { useViewTheme } from "./hooks/use-view-theme.js";
24
25
  export { useToolContext, type ToolContextHandle, } from "./hooks/use-tool-context.js";
25
26
  export { useViewTool, type ViewToolDefinition } from "./hooks/use-view-tool.js";
26
27
  export { type DeepPartial, type Register, type RegisteredTools, } from "./types/register.js";
28
+ export type { FileMetadata, UseFilesResult } from "./types/file-types.js";
27
29
  export type { DisplayMode, HostCapabilities, HostContext, HostInfo, SafeAreaInsets, } from "./types/host-types.js";
28
30
  export { ToolError, toolResultText, type CallToolResult, type CallToolSuccess, type ToolContextError, } from "./types/result-types.js";
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;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AE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,EACT,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,yBAAyB,CAAC"}
@@ -365,6 +365,19 @@ var defaultHostSnapshot = {
365
365
  isConnected: false,
366
366
  connectionError: void 0
367
367
  };
368
+ var defaultFilesSnapshot = {
369
+ isSupported: false
370
+ };
371
+ function getChatGptFilesApi() {
372
+ if (typeof window === "undefined") return void 0;
373
+ return window.openai;
374
+ }
375
+ function resolveFilesSnapshot() {
376
+ const api = getChatGptFilesApi();
377
+ return {
378
+ isSupported: typeof api?.uploadFile === "function" && typeof api.getFileDownloadUrl === "function"
379
+ };
380
+ }
368
381
  function resolveDisplayMode(hostContext) {
369
382
  return hostContext?.displayMode === "fullscreen" || hostContext?.displayMode === "pip" ? hostContext.displayMode : "inline";
370
383
  }
@@ -434,10 +447,12 @@ function createMcpAppRuntime(config, options) {
434
447
  displayMode: "inline",
435
448
  availableDisplayModes: ["inline"]
436
449
  };
450
+ let filesSnapshot = resolveFilesSnapshot();
437
451
  const toolChannel = createChannelStore();
438
452
  const hostChannel = createChannelStore();
439
453
  const themeChannel = createChannelStore();
440
454
  const displayChannel = createChannelStore();
455
+ const filesChannel = createChannelStore();
441
456
  function patchTool(patch) {
442
457
  if (!toolSnapshotChanged(toolSnapshot, patch)) {
443
458
  return;
@@ -613,6 +628,7 @@ function createMcpAppRuntime(config, options) {
613
628
  hostChannel.clear();
614
629
  themeChannel.clear();
615
630
  displayChannel.clear();
631
+ filesChannel.clear();
616
632
  toolSnapshot = { ...defaultToolSnapshot };
617
633
  hostSnapshot = { ...defaultHostSnapshot };
618
634
  themeSnapshot = "light";
@@ -620,6 +636,7 @@ function createMcpAppRuntime(config, options) {
620
636
  displayMode: "inline",
621
637
  availableDisplayModes: ["inline"]
622
638
  };
639
+ filesSnapshot = { ...defaultFilesSnapshot };
623
640
  if (activeRuntime === runtime) {
624
641
  activeRuntime = null;
625
642
  }
@@ -669,6 +686,30 @@ function createMcpAppRuntime(config, options) {
669
686
  const app2 = await connect();
670
687
  await app2.sendSizeChanged(params);
671
688
  }
689
+ async function uploadFile(file) {
690
+ if (disposed) {
691
+ throw new Error("View runtime has been disposed");
692
+ }
693
+ const api = getChatGptFilesApi();
694
+ if (!filesSnapshot.isSupported || typeof api?.uploadFile !== "function") {
695
+ throw new Error(
696
+ "[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment."
697
+ );
698
+ }
699
+ return api.uploadFile(file);
700
+ }
701
+ async function getFileDownloadUrl(file) {
702
+ if (disposed) {
703
+ throw new Error("View runtime has been disposed");
704
+ }
705
+ const api = getChatGptFilesApi();
706
+ if (!filesSnapshot.isSupported || typeof api?.getFileDownloadUrl !== "function") {
707
+ throw new Error(
708
+ "[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment."
709
+ );
710
+ }
711
+ return api.getFileDownloadUrl(file);
712
+ }
672
713
  const runtime = {
673
714
  config,
674
715
  modelContextStore,
@@ -682,12 +723,16 @@ function createMcpAppRuntime(config, options) {
682
723
  getThemeSnapshot: () => themeSnapshot,
683
724
  subscribeDisplay: displayChannel.subscribe,
684
725
  getDisplaySnapshot: () => displaySnapshot,
726
+ subscribeFiles: filesChannel.subscribe,
727
+ getFilesSnapshot: () => filesSnapshot,
685
728
  getApp: () => disposed ? null : app,
686
729
  callServerTool,
687
730
  sendMessage,
688
731
  openLink,
689
732
  requestDisplayMode,
690
733
  sendSizeChanged,
734
+ uploadFile,
735
+ getFileDownloadUrl,
691
736
  registerViewTool
692
737
  };
693
738
  return runtime;
@@ -1257,6 +1302,24 @@ function useCallTool(nameOrRef) {
1257
1302
  return { callTool, data, error, isPending };
1258
1303
  }
1259
1304
 
1305
+ // src/react/hooks/use-files.ts
1306
+ import { useMemo, useSyncExternalStore as useSyncExternalStore5 } from "react";
1307
+ function useFiles() {
1308
+ const runtime = useViewRuntime();
1309
+ const { isSupported } = useSyncExternalStore5(
1310
+ runtime.subscribeFiles,
1311
+ runtime.getFilesSnapshot
1312
+ );
1313
+ return useMemo(
1314
+ () => ({
1315
+ isSupported,
1316
+ upload: runtime.uploadFile,
1317
+ getDownloadUrl: runtime.getFileDownloadUrl
1318
+ }),
1319
+ [runtime, isSupported]
1320
+ );
1321
+ }
1322
+
1260
1323
  // src/react/hooks/use-open-external.ts
1261
1324
  import { useCallback as useCallback2 } from "react";
1262
1325
  function useOpenExternal() {
@@ -1291,10 +1354,10 @@ function useSendSizeChanged() {
1291
1354
  }
1292
1355
 
1293
1356
  // src/react/hooks/use-view-theme.ts
1294
- import { useSyncExternalStore as useSyncExternalStore5 } from "react";
1357
+ import { useSyncExternalStore as useSyncExternalStore6 } from "react";
1295
1358
  function useViewTheme() {
1296
1359
  const runtime = useViewRuntime();
1297
- return useSyncExternalStore5(runtime.subscribeTheme, runtime.getThemeSnapshot);
1360
+ return useSyncExternalStore6(runtime.subscribeTheme, runtime.getThemeSnapshot);
1298
1361
  }
1299
1362
 
1300
1363
  // src/react/hooks/use-view-tool.ts
@@ -1406,6 +1469,7 @@ export {
1406
1469
  toolResultText,
1407
1470
  useCallTool,
1408
1471
  useDisplayMode,
1472
+ useFiles,
1409
1473
  useHostContext,
1410
1474
  useOpenExternal,
1411
1475
  useSendFollowUp,