mcp-use 1.0.6 → 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.
- package/dist/{chunk-CWWNPIJZ.js → chunk-56ZYVEAJ.js} +17 -8
- package/dist/index.cjs +15 -6
- package/dist/index.js +3 -3
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/react/index.cjs +13 -4
- package/dist/src/react/index.js +1 -1
- package/dist/src/react/types.d.ts +5 -1
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/adapters/mcp-ui-adapter.d.ts +54 -4
- package/dist/src/server/adapters/mcp-ui-adapter.d.ts.map +1 -1
- package/dist/src/server/index.cjs +175 -42
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +175 -42
- package/dist/src/server/mcp-server.d.ts +46 -13
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/types/index.d.ts +3 -3
- package/dist/src/server/types/index.d.ts.map +1 -1
- package/dist/src/server/types/prompt.d.ts +5 -3
- package/dist/src/server/types/prompt.d.ts.map +1 -1
- package/dist/src/server/types/resource.d.ts +95 -9
- package/dist/src/server/types/resource.d.ts.map +1 -1
- package/dist/src/server/types/tool.d.ts +10 -3
- package/dist/src/server/types/tool.d.ts.map +1 -1
- package/dist/tests/stream_events.test.d.ts +10 -0
- package/dist/tests/stream_events.test.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -8,17 +8,17 @@ import {
|
|
|
8
8
|
// src/react/useMcp.ts
|
|
9
9
|
import {
|
|
10
10
|
CallToolResultSchema,
|
|
11
|
-
|
|
12
|
-
ListResourcesResultSchema,
|
|
13
|
-
ReadResourceResultSchema,
|
|
11
|
+
GetPromptResultSchema,
|
|
14
12
|
ListPromptsResultSchema,
|
|
15
|
-
|
|
13
|
+
ListResourcesResultSchema,
|
|
14
|
+
ListToolsResultSchema,
|
|
15
|
+
ReadResourceResultSchema
|
|
16
16
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
17
17
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
18
|
+
import { auth, UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
19
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
18
20
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
19
21
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
20
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
21
|
-
import { auth, UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
22
22
|
import { sanitizeUrl } from "strict-url-sanitise";
|
|
23
23
|
|
|
24
24
|
// src/utils/assert.ts
|
|
@@ -48,7 +48,11 @@ function useMcp(options) {
|
|
|
48
48
|
autoReconnect = DEFAULT_RECONNECT_DELAY,
|
|
49
49
|
transportType = "auto",
|
|
50
50
|
preventAutoAuth = false,
|
|
51
|
-
onPopupWindow
|
|
51
|
+
onPopupWindow,
|
|
52
|
+
timeout = 3e4,
|
|
53
|
+
// 30 seconds default for connection timeout
|
|
54
|
+
sseReadTimeout = 3e5
|
|
55
|
+
// 5 minutes default for SSE read timeout
|
|
52
56
|
} = options;
|
|
53
57
|
const [state, setState] = useState("discovering");
|
|
54
58
|
const [tools, setTools] = useState([]);
|
|
@@ -186,6 +190,9 @@ function useMcp(options) {
|
|
|
186
190
|
...customHeaders
|
|
187
191
|
}
|
|
188
192
|
}
|
|
193
|
+
// Note: The MCP SDK's SSEClientTransport doesn't expose timeout configuration directly
|
|
194
|
+
// Timeout handling is managed by the underlying EventSource and browser/Node.js fetch implementations
|
|
195
|
+
// The timeout and sseReadTimeout options are preserved for future use or custom implementations
|
|
189
196
|
};
|
|
190
197
|
const sanitizedUrl = sanitizeUrl(url);
|
|
191
198
|
const targetUrl = new URL(sanitizedUrl);
|
|
@@ -376,7 +383,9 @@ function useMcp(options) {
|
|
|
376
383
|
transportType,
|
|
377
384
|
preventAutoAuth,
|
|
378
385
|
onPopupWindow,
|
|
379
|
-
enabled
|
|
386
|
+
enabled,
|
|
387
|
+
timeout,
|
|
388
|
+
sseReadTimeout
|
|
380
389
|
]);
|
|
381
390
|
const callTool = useCallback(
|
|
382
391
|
async (name, args) => {
|
package/dist/index.cjs
CHANGED
|
@@ -3442,8 +3442,8 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3442
3442
|
if (opts.authToken) {
|
|
3443
3443
|
this.headers.Authorization = `Bearer ${opts.authToken}`;
|
|
3444
3444
|
}
|
|
3445
|
-
this.timeout = opts.timeout ??
|
|
3446
|
-
this.sseReadTimeout = opts.sseReadTimeout ??
|
|
3445
|
+
this.timeout = opts.timeout ?? 3e4;
|
|
3446
|
+
this.sseReadTimeout = opts.sseReadTimeout ?? 3e5;
|
|
3447
3447
|
this.clientInfo = opts.clientInfo ?? { name: "http-connector", version: "1.0.0" };
|
|
3448
3448
|
this.preferSse = opts.preferSse ?? false;
|
|
3449
3449
|
}
|
|
@@ -4725,10 +4725,10 @@ __name(onMcpAuthorization, "onMcpAuthorization");
|
|
|
4725
4725
|
// src/react/useMcp.ts
|
|
4726
4726
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
4727
4727
|
var import_react = require("react");
|
|
4728
|
+
var import_auth2 = require("@modelcontextprotocol/sdk/client/auth.js");
|
|
4729
|
+
var import_client3 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
4728
4730
|
var import_sse3 = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
4729
4731
|
var import_streamableHttp3 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
4730
|
-
var import_client3 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
4731
|
-
var import_auth2 = require("@modelcontextprotocol/sdk/client/auth.js");
|
|
4732
4732
|
var import_strict_url_sanitise2 = require("strict-url-sanitise");
|
|
4733
4733
|
|
|
4734
4734
|
// src/utils/assert.ts
|
|
@@ -4758,7 +4758,11 @@ function useMcp(options) {
|
|
|
4758
4758
|
autoReconnect = DEFAULT_RECONNECT_DELAY,
|
|
4759
4759
|
transportType = "auto",
|
|
4760
4760
|
preventAutoAuth = false,
|
|
4761
|
-
onPopupWindow
|
|
4761
|
+
onPopupWindow,
|
|
4762
|
+
timeout = 3e4,
|
|
4763
|
+
// 30 seconds default for connection timeout
|
|
4764
|
+
sseReadTimeout = 3e5
|
|
4765
|
+
// 5 minutes default for SSE read timeout
|
|
4762
4766
|
} = options;
|
|
4763
4767
|
const [state, setState] = (0, import_react.useState)("discovering");
|
|
4764
4768
|
const [tools, setTools] = (0, import_react.useState)([]);
|
|
@@ -4896,6 +4900,9 @@ function useMcp(options) {
|
|
|
4896
4900
|
...customHeaders
|
|
4897
4901
|
}
|
|
4898
4902
|
}
|
|
4903
|
+
// Note: The MCP SDK's SSEClientTransport doesn't expose timeout configuration directly
|
|
4904
|
+
// Timeout handling is managed by the underlying EventSource and browser/Node.js fetch implementations
|
|
4905
|
+
// The timeout and sseReadTimeout options are preserved for future use or custom implementations
|
|
4899
4906
|
};
|
|
4900
4907
|
const sanitizedUrl = (0, import_strict_url_sanitise2.sanitizeUrl)(url);
|
|
4901
4908
|
const targetUrl = new URL(sanitizedUrl);
|
|
@@ -5086,7 +5093,9 @@ function useMcp(options) {
|
|
|
5086
5093
|
transportType,
|
|
5087
5094
|
preventAutoAuth,
|
|
5088
5095
|
onPopupWindow,
|
|
5089
|
-
enabled
|
|
5096
|
+
enabled,
|
|
5097
|
+
timeout,
|
|
5098
|
+
sseReadTimeout
|
|
5090
5099
|
]);
|
|
5091
5100
|
const callTool = (0, import_react.useCallback)(
|
|
5092
5101
|
async (name, args) => {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useMcp
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-56ZYVEAJ.js";
|
|
4
4
|
import {
|
|
5
5
|
BrowserOAuthClientProvider,
|
|
6
6
|
onMcpAuthorization
|
|
@@ -2931,8 +2931,8 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2931
2931
|
if (opts.authToken) {
|
|
2932
2932
|
this.headers.Authorization = `Bearer ${opts.authToken}`;
|
|
2933
2933
|
}
|
|
2934
|
-
this.timeout = opts.timeout ??
|
|
2935
|
-
this.sseReadTimeout = opts.sseReadTimeout ??
|
|
2934
|
+
this.timeout = opts.timeout ?? 3e4;
|
|
2935
|
+
this.sseReadTimeout = opts.sseReadTimeout ?? 3e5;
|
|
2936
2936
|
this.clientInfo = opts.clientInfo ?? { name: "http-connector", version: "1.0.0" };
|
|
2937
2937
|
this.preferSse = opts.preferSse ?? false;
|
|
2938
2938
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/connectors/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/connectors/http.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,aAAa,CAAyC;gBAElD,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB;IAe5D,mFAAmF;IAC7E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAiFhB,yBAAyB;YAoDzB,cAAc;IA8B5B,IAAI,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM7C;IAED;;OAEG;IACH,gBAAgB,IAAI,iBAAiB,GAAG,KAAK,GAAG,IAAI;CAGrD"}
|
package/dist/src/react/index.cjs
CHANGED
|
@@ -29,10 +29,10 @@ module.exports = __toCommonJS(react_exports);
|
|
|
29
29
|
// src/react/useMcp.ts
|
|
30
30
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
31
31
|
var import_react = require("react");
|
|
32
|
+
var import_auth = require("@modelcontextprotocol/sdk/client/auth.js");
|
|
33
|
+
var import_client = require("@modelcontextprotocol/sdk/client/index.js");
|
|
32
34
|
var import_sse = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
33
35
|
var import_streamableHttp = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
34
|
-
var import_client = require("@modelcontextprotocol/sdk/client/index.js");
|
|
35
|
-
var import_auth = require("@modelcontextprotocol/sdk/client/auth.js");
|
|
36
36
|
var import_strict_url_sanitise2 = require("strict-url-sanitise");
|
|
37
37
|
|
|
38
38
|
// src/auth/browser-provider.ts
|
|
@@ -262,7 +262,11 @@ function useMcp(options) {
|
|
|
262
262
|
autoReconnect = DEFAULT_RECONNECT_DELAY,
|
|
263
263
|
transportType = "auto",
|
|
264
264
|
preventAutoAuth = false,
|
|
265
|
-
onPopupWindow
|
|
265
|
+
onPopupWindow,
|
|
266
|
+
timeout = 3e4,
|
|
267
|
+
// 30 seconds default for connection timeout
|
|
268
|
+
sseReadTimeout = 3e5
|
|
269
|
+
// 5 minutes default for SSE read timeout
|
|
266
270
|
} = options;
|
|
267
271
|
const [state, setState] = (0, import_react.useState)("discovering");
|
|
268
272
|
const [tools, setTools] = (0, import_react.useState)([]);
|
|
@@ -400,6 +404,9 @@ function useMcp(options) {
|
|
|
400
404
|
...customHeaders
|
|
401
405
|
}
|
|
402
406
|
}
|
|
407
|
+
// Note: The MCP SDK's SSEClientTransport doesn't expose timeout configuration directly
|
|
408
|
+
// Timeout handling is managed by the underlying EventSource and browser/Node.js fetch implementations
|
|
409
|
+
// The timeout and sseReadTimeout options are preserved for future use or custom implementations
|
|
403
410
|
};
|
|
404
411
|
const sanitizedUrl = (0, import_strict_url_sanitise2.sanitizeUrl)(url);
|
|
405
412
|
const targetUrl = new URL(sanitizedUrl);
|
|
@@ -590,7 +597,9 @@ function useMcp(options) {
|
|
|
590
597
|
transportType,
|
|
591
598
|
preventAutoAuth,
|
|
592
599
|
onPopupWindow,
|
|
593
|
-
enabled
|
|
600
|
+
enabled,
|
|
601
|
+
timeout,
|
|
602
|
+
sseReadTimeout
|
|
594
603
|
]);
|
|
595
604
|
const callTool = (0, import_react.useCallback)(
|
|
596
605
|
async (name, args) => {
|
package/dist/src/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Prompt, Resource, ResourceTemplate, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
2
|
export type UseMcpOptions = {
|
|
3
3
|
/** The /sse URL of your remote MCP server */
|
|
4
4
|
url?: string;
|
|
@@ -37,6 +37,10 @@ export type UseMcpOptions = {
|
|
|
37
37
|
* @param features The features string for the popup window.
|
|
38
38
|
*/
|
|
39
39
|
onPopupWindow?: (url: string, features: string, window: globalThis.Window | null) => void;
|
|
40
|
+
/** Connection timeout in milliseconds for establishing initial connection (default: 30000 / 30 seconds) */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
/** SSE read timeout in milliseconds to prevent idle connection drops (default: 300000 / 5 minutes) */
|
|
43
|
+
sseReadTimeout?: number;
|
|
40
44
|
};
|
|
41
45
|
export type UseMcpResult = {
|
|
42
46
|
/** List of tools available from the connected MCP server */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAElG,MAAM,MAAM,aAAa,GAAG;IAC1B,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6HAA6H;IAC7H,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iGAAiG;IACjG,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uDAAuD;IACvD,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,2FAA2F;IAC3F,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,4FAA4F;IAC5F,aAAa,CAA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sources":["../../../src/react/useMcp.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS9D,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CA2uB3D"}
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
* into @mcp-ui/server compatible resource objects.
|
|
6
6
|
*
|
|
7
7
|
* Ref: https://mcpui.dev/guide/server/typescript/usage-examples
|
|
8
|
+
* Apps SDK: https://mcpui.dev/guide/apps-sdk
|
|
9
|
+
* Official Apps SDK Docs: https://developers.openai.com/apps-sdk/build/mcp-server
|
|
8
10
|
*/
|
|
9
|
-
import
|
|
11
|
+
import { type AdaptersConfig } from '@mcp-ui/server';
|
|
12
|
+
import type { UIResourceContent, UIResourceDefinition, UIEncoding, AppsSdkMetadata } from '../types/resource.js';
|
|
10
13
|
/**
|
|
11
14
|
* Configuration for building widget URLs
|
|
12
15
|
*/
|
|
@@ -29,18 +32,22 @@ export declare function buildWidgetUrl(widget: string, props: Record<string, any
|
|
|
29
32
|
* @param uri - Resource URI (must start with ui://)
|
|
30
33
|
* @param iframeUrl - URL to load in iframe
|
|
31
34
|
* @param encoding - Encoding type ('text' or 'blob')
|
|
35
|
+
* @param adapters - Adapter configuration (e.g., Apps SDK)
|
|
36
|
+
* @param metadata - Additional metadata for the resource
|
|
32
37
|
* @returns UIResourceContent object
|
|
33
38
|
*/
|
|
34
|
-
export declare function createExternalUrlResource(uri: string, iframeUrl: string, encoding?: UIEncoding): UIResourceContent;
|
|
39
|
+
export declare function createExternalUrlResource(uri: string, iframeUrl: string, encoding?: UIEncoding, adapters?: AdaptersConfig, metadata?: AppsSdkMetadata): UIResourceContent;
|
|
35
40
|
/**
|
|
36
41
|
* Create a UIResource for raw HTML content
|
|
37
42
|
*
|
|
38
43
|
* @param uri - Resource URI (must start with ui://)
|
|
39
44
|
* @param htmlString - HTML content to render
|
|
40
45
|
* @param encoding - Encoding type ('text' or 'blob')
|
|
46
|
+
* @param adapters - Adapter configuration (e.g., Apps SDK)
|
|
47
|
+
* @param metadata - Additional metadata for the resource
|
|
41
48
|
* @returns UIResourceContent object
|
|
42
49
|
*/
|
|
43
|
-
export declare function createRawHtmlResource(uri: string, htmlString: string, encoding?: UIEncoding): UIResourceContent;
|
|
50
|
+
export declare function createRawHtmlResource(uri: string, htmlString: string, encoding?: UIEncoding, adapters?: AdaptersConfig, metadata?: AppsSdkMetadata): UIResourceContent;
|
|
44
51
|
/**
|
|
45
52
|
* Create a UIResource for Remote DOM scripting
|
|
46
53
|
*
|
|
@@ -48,9 +55,52 @@ export declare function createRawHtmlResource(uri: string, htmlString: string, e
|
|
|
48
55
|
* @param script - JavaScript code for remote DOM manipulation
|
|
49
56
|
* @param framework - Framework for remote DOM ('react' or 'webcomponents')
|
|
50
57
|
* @param encoding - Encoding type ('text' or 'blob')
|
|
58
|
+
* @param adapters - Adapter configuration (e.g., Apps SDK)
|
|
59
|
+
* @param metadata - Additional metadata for the resource
|
|
51
60
|
* @returns UIResourceContent object
|
|
52
61
|
*/
|
|
53
|
-
export declare function createRemoteDomResource(uri: string, script: string, framework?: 'react' | 'webcomponents', encoding?: UIEncoding): UIResourceContent;
|
|
62
|
+
export declare function createRemoteDomResource(uri: string, script: string, framework?: 'react' | 'webcomponents', encoding?: UIEncoding, adapters?: AdaptersConfig, metadata?: AppsSdkMetadata): UIResourceContent;
|
|
63
|
+
/**
|
|
64
|
+
* Create a UIResource for OpenAI Apps SDK
|
|
65
|
+
*
|
|
66
|
+
* This creates a resource compatible with OpenAI's Apps SDK using the
|
|
67
|
+
* text/html+skybridge mime type. The HTML template should contain the
|
|
68
|
+
* component code with embedded JS/CSS.
|
|
69
|
+
*
|
|
70
|
+
* The Apps SDK pattern:
|
|
71
|
+
* - Uses mime type text/html+skybridge
|
|
72
|
+
* - Tool's structuredContent gets injected as window.openai.toolOutput
|
|
73
|
+
* - Supports Apps SDK metadata (CSP, widget domain, description, etc.)
|
|
74
|
+
*
|
|
75
|
+
* @param uri - Resource URI (must start with ui://)
|
|
76
|
+
* @param htmlTemplate - HTML template with embedded component code
|
|
77
|
+
* @param metadata - Apps SDK metadata (CSP, description, domain, etc.)
|
|
78
|
+
* @returns UIResourceContent object
|
|
79
|
+
*
|
|
80
|
+
* @see https://developers.openai.com/apps-sdk/build/mcp-server
|
|
81
|
+
* @see https://mcpui.dev/guide/apps-sdk
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const resource = createAppsSdkResource(
|
|
86
|
+
* 'ui://widget/kanban-board.html',
|
|
87
|
+
* `
|
|
88
|
+
* <div id="kanban-root"></div>
|
|
89
|
+
* <style>${kanbanCSS}</style>
|
|
90
|
+
* <script type="module">${kanbanJS}</script>
|
|
91
|
+
* `,
|
|
92
|
+
* {
|
|
93
|
+
* 'openai/widgetDescription': 'Displays an interactive kanban board',
|
|
94
|
+
* 'openai/widgetCSP': {
|
|
95
|
+
* connect_domains: [],
|
|
96
|
+
* resource_domains: ['https://cdn.example.com']
|
|
97
|
+
* },
|
|
98
|
+
* 'openai/widgetPrefersBorder': true
|
|
99
|
+
* }
|
|
100
|
+
* )
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function createAppsSdkResource(uri: string, htmlTemplate: string, metadata?: AppsSdkMetadata): UIResourceContent;
|
|
54
104
|
/**
|
|
55
105
|
* Create a UIResource from a high-level definition
|
|
56
106
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-ui-adapter.d.ts","sourceRoot":"","sources":["../../../../src/server/adapters/mcp-ui-adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mcp-ui-adapter.d.ts","sourceRoot":"","sources":["../../../../src/server/adapters/mcp-ui-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAA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