mcp-use 1.9.0 → 1.9.1-canary.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/.tsbuildinfo +1 -1
- package/dist/chunk-2EYAMIT3.js +76 -0
- package/dist/chunk-33U4IA4N.js +337 -0
- package/dist/chunk-362PI25Z.js +110 -0
- package/dist/chunk-LWVK6RXA.js +30 -0
- package/dist/context-storage-NA4MHWOZ.js +13 -0
- package/dist/conversion-5MA4VY3B.js +7 -0
- package/dist/conversion-OTRZZBUU.js +7 -0
- package/dist/src/server/context-storage.d.ts +8 -1
- package/dist/src/server/context-storage.d.ts.map +1 -1
- package/dist/src/server/endpoints/index.d.ts +7 -0
- package/dist/src/server/endpoints/index.d.ts.map +1 -0
- package/dist/src/server/endpoints/mount-mcp.d.ts +21 -0
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -0
- package/dist/src/server/index.cjs +4180 -3956
- package/dist/src/server/index.d.ts +4 -3
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +3590 -3040
- package/dist/src/server/inspector/index.d.ts +5 -0
- package/dist/src/server/inspector/index.d.ts.map +1 -0
- package/dist/src/server/inspector/mount.d.ts +33 -0
- package/dist/src/server/inspector/mount.d.ts.map +1 -0
- package/dist/src/server/logging.d.ts.map +1 -1
- package/dist/src/server/mcp-server.d.ts +91 -770
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/notifications/index.d.ts +7 -0
- package/dist/src/server/notifications/index.d.ts.map +1 -0
- package/dist/src/server/notifications/notification-registration.d.ts +82 -0
- package/dist/src/server/notifications/notification-registration.d.ts.map +1 -0
- package/dist/src/server/oauth/index.d.ts +1 -0
- package/dist/src/server/oauth/index.d.ts.map +1 -1
- package/dist/src/server/oauth/setup.d.ts +28 -0
- package/dist/src/server/oauth/setup.d.ts.map +1 -0
- package/dist/src/server/prompts/conversion.d.ts +22 -0
- package/dist/src/server/prompts/conversion.d.ts.map +1 -0
- package/dist/src/server/prompts/index.d.ts +60 -0
- package/dist/src/server/prompts/index.d.ts.map +1 -0
- package/dist/src/server/resources/conversion.d.ts +20 -0
- package/dist/src/server/resources/conversion.d.ts.map +1 -0
- package/dist/src/server/resources/index.d.ts +117 -0
- package/dist/src/server/resources/index.d.ts.map +1 -0
- package/dist/src/server/resources/subscriptions.d.ts +54 -0
- package/dist/src/server/resources/subscriptions.d.ts.map +1 -0
- package/dist/src/server/roots/index.d.ts +7 -0
- package/dist/src/server/roots/index.d.ts.map +1 -0
- package/dist/src/server/roots/roots-registration.d.ts +56 -0
- package/dist/src/server/roots/roots-registration.d.ts.map +1 -0
- package/dist/src/server/sessions/index.d.ts +6 -0
- package/dist/src/server/sessions/index.d.ts.map +1 -0
- package/dist/src/server/sessions/notifications.d.ts +25 -0
- package/dist/src/server/sessions/notifications.d.ts.map +1 -0
- package/dist/src/server/sessions/session-manager.d.ts +47 -0
- package/dist/src/server/sessions/session-manager.d.ts.map +1 -0
- package/dist/src/server/tools/index.d.ts +10 -0
- package/dist/src/server/tools/index.d.ts.map +1 -0
- package/dist/src/server/tools/schema-helpers.d.ts +54 -0
- package/dist/src/server/tools/schema-helpers.d.ts.map +1 -0
- package/dist/src/server/tools/tool-execution-helpers.d.ts +110 -0
- package/dist/src/server/tools/tool-execution-helpers.d.ts.map +1 -0
- package/dist/src/server/tools/tool-registration.d.ts +85 -0
- package/dist/src/server/tools/tool-registration.d.ts.map +1 -0
- package/dist/src/server/types/common.d.ts +24 -0
- package/dist/src/server/types/common.d.ts.map +1 -1
- package/dist/src/server/types/index.d.ts +5 -4
- package/dist/src/server/types/index.d.ts.map +1 -1
- package/dist/src/server/types/prompt.d.ts +61 -6
- package/dist/src/server/types/prompt.d.ts.map +1 -1
- package/dist/src/server/types/resource.d.ts +83 -8
- package/dist/src/server/types/resource.d.ts.map +1 -1
- package/dist/src/server/types/tool-context.d.ts +252 -0
- package/dist/src/server/types/tool-context.d.ts.map +1 -0
- package/dist/src/server/types/tool.d.ts +62 -5
- package/dist/src/server/types/tool.d.ts.map +1 -1
- package/dist/src/server/utils/hono-proxy.d.ts +21 -0
- package/dist/src/server/utils/hono-proxy.d.ts.map +1 -0
- package/dist/src/server/utils/index.d.ts +3 -0
- package/dist/src/server/utils/index.d.ts.map +1 -1
- package/dist/src/server/utils/jsonrpc-helpers.d.ts +94 -0
- package/dist/src/server/utils/jsonrpc-helpers.d.ts.map +1 -0
- package/dist/src/server/utils/response-helpers.d.ts +163 -7
- package/dist/src/server/utils/response-helpers.d.ts.map +1 -1
- package/dist/src/server/utils/server-helpers.d.ts +78 -0
- package/dist/src/server/utils/server-helpers.d.ts.map +1 -0
- package/dist/src/server/utils/server-lifecycle.d.ts +52 -0
- package/dist/src/server/utils/server-lifecycle.d.ts.map +1 -0
- package/dist/src/server/utils/session-helpers.d.ts +55 -0
- package/dist/src/server/utils/session-helpers.d.ts.map +1 -0
- package/dist/src/server/widgets/index.d.ts +30 -0
- package/dist/src/server/widgets/index.d.ts.map +1 -0
- package/dist/src/server/widgets/mcp-ui-adapter.d.ts.map +1 -0
- package/dist/src/server/widgets/mount-widgets-dev.d.ts +28 -0
- package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -0
- package/dist/src/server/widgets/mount-widgets-production.d.ts +27 -0
- package/dist/src/server/widgets/mount-widgets-production.d.ts.map +1 -0
- package/dist/src/server/widgets/setup-widget-routes.d.ts +23 -0
- package/dist/src/server/widgets/setup-widget-routes.d.ts.map +1 -0
- package/dist/src/server/widgets/ui-resource-registration.d.ts +75 -0
- package/dist/src/server/widgets/ui-resource-registration.d.ts.map +1 -0
- package/dist/src/server/widgets/widget-helpers.d.ts +277 -0
- package/dist/src/server/widgets/widget-helpers.d.ts.map +1 -0
- package/dist/src/server/widgets/widget-types.d.ts +49 -0
- package/dist/src/server/widgets/widget-types.d.ts.map +1 -0
- package/dist/tool-execution-helpers-BQJTPWPN.js +29 -0
- package/package.json +6 -5
- package/dist/chunk-F4UHAA5L.js +0 -854
- package/dist/oauth-U4NNKN4B.js +0 -30
- package/dist/src/server/adapters/mcp-ui-adapter.d.ts.map +0 -1
- /package/dist/src/server/{adapters → widgets}/mcp-ui-adapter.d.ts +0 -0
|
@@ -8,23 +8,30 @@ export interface TypedCallToolResult<T extends Record<string, unknown> = Record<
|
|
|
8
8
|
structuredContent?: T;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Create a text content response for MCP tools
|
|
11
|
+
* Create a text content response for MCP tools and resources
|
|
12
12
|
*
|
|
13
13
|
* @param content - The text content to return
|
|
14
14
|
* @returns CallToolResult with text content
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
|
+
* // For tools
|
|
18
19
|
* server.tool({
|
|
19
20
|
* name: 'greet',
|
|
20
21
|
* schema: z.object({ name: z.string() }),
|
|
21
22
|
* cb: async ({ name }) => text(`Hello, ${name}!`)
|
|
22
23
|
* })
|
|
24
|
+
*
|
|
25
|
+
* // For resources
|
|
26
|
+
* server.resource(
|
|
27
|
+
* { name: 'greeting', uri: 'app://greeting' },
|
|
28
|
+
* async () => text('Hello World!')
|
|
29
|
+
* )
|
|
23
30
|
* ```
|
|
24
31
|
*/
|
|
25
32
|
export declare function text(content: string): CallToolResult;
|
|
26
33
|
/**
|
|
27
|
-
* Create an image content response for MCP tools
|
|
34
|
+
* Create an image content response for MCP tools and resources
|
|
28
35
|
*
|
|
29
36
|
* @param data - The image data (data URL or base64)
|
|
30
37
|
* @param mimeType - MIME type (e.g., 'image/png', defaults to 'image/png')
|
|
@@ -32,30 +39,81 @@ export declare function text(content: string): CallToolResult;
|
|
|
32
39
|
*
|
|
33
40
|
* @example
|
|
34
41
|
* ```typescript
|
|
42
|
+
* // For tools
|
|
35
43
|
* server.tool({
|
|
36
44
|
* name: 'generate-image',
|
|
37
45
|
* cb: async () => image('data:image/png;base64,...', 'image/png')
|
|
38
46
|
* })
|
|
47
|
+
*
|
|
48
|
+
* // For resources
|
|
49
|
+
* server.resource(
|
|
50
|
+
* { name: 'logo', uri: 'asset://logo' },
|
|
51
|
+
* async () => image(base64Data, 'image/png')
|
|
52
|
+
* )
|
|
39
53
|
* ```
|
|
40
54
|
*/
|
|
41
55
|
export declare function image(data: string, mimeType?: string): CallToolResult;
|
|
56
|
+
/**
|
|
57
|
+
* Create an audio content response for MCP tools and resources
|
|
58
|
+
*
|
|
59
|
+
* Accepts either base64 data or a file path. File paths will be automatically
|
|
60
|
+
* detected and read asynchronously, returning a Promise<CallToolResult>.
|
|
61
|
+
*
|
|
62
|
+
* @param dataOrPath - Audio data as base64 string, or path to audio file
|
|
63
|
+
* @param mimeType - MIME type (e.g., 'audio/wav'). If not provided, defaults to 'audio/wav'
|
|
64
|
+
* for base64 data, or inferred from file extension for file paths
|
|
65
|
+
* @returns CallToolResult for base64 data, or Promise<CallToolResult> for file paths
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // With base64 data (synchronous)
|
|
70
|
+
* server.tool({
|
|
71
|
+
* name: 'generate-audio',
|
|
72
|
+
* cb: async () => audio(base64AudioData, 'audio/wav')
|
|
73
|
+
* })
|
|
74
|
+
*
|
|
75
|
+
* // With file path (asynchronous)
|
|
76
|
+
* server.resource(
|
|
77
|
+
* { name: 'notification', uri: 'audio://notification' },
|
|
78
|
+
* async () => await audio('./sounds/notification.wav')
|
|
79
|
+
* )
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function audio(dataOrPath: string, mimeType?: string): CallToolResult | Promise<CallToolResult>;
|
|
42
83
|
/**
|
|
43
84
|
* Create a resource content response for MCP tools
|
|
44
85
|
*
|
|
86
|
+
* Supports two usage patterns:
|
|
87
|
+
* 1. Three arguments: resource(uri, mimeType, text)
|
|
88
|
+
* 2. Two arguments: resource(uri, content) where content is a CallToolResult from helpers
|
|
89
|
+
*
|
|
45
90
|
* @param uri - The resource URI
|
|
46
|
-
* @param
|
|
47
|
-
* @param text - Optional text content for
|
|
91
|
+
* @param mimeTypeOrContent - MIME type (3-arg pattern) or CallToolResult (2-arg pattern)
|
|
92
|
+
* @param text - Optional text content (only for 3-arg pattern)
|
|
48
93
|
* @returns CallToolResult with resource content
|
|
49
94
|
*
|
|
50
95
|
* @example
|
|
51
96
|
* ```typescript
|
|
97
|
+
* // 3-arg pattern: Explicit mimeType and text
|
|
52
98
|
* server.tool({
|
|
53
99
|
* name: 'get-config',
|
|
54
|
-
* cb: async () => resource('
|
|
100
|
+
* cb: async () => resource('test://embedded', 'text/plain', 'This is text content')
|
|
101
|
+
* })
|
|
102
|
+
*
|
|
103
|
+
* // 2-arg pattern: Using text helper
|
|
104
|
+
* server.tool({
|
|
105
|
+
* name: 'get-greeting',
|
|
106
|
+
* cb: async () => resource('test://embedded', text('Hello'))
|
|
107
|
+
* })
|
|
108
|
+
*
|
|
109
|
+
* // 2-arg pattern: Using object helper
|
|
110
|
+
* server.tool({
|
|
111
|
+
* name: 'get-data',
|
|
112
|
+
* cb: async () => resource('test://data', object({ test: 'data', value: 123 }))
|
|
55
113
|
* })
|
|
56
114
|
* ```
|
|
57
115
|
*/
|
|
58
|
-
export declare function resource(uri: string,
|
|
116
|
+
export declare function resource(uri: string, mimeTypeOrContent: string | CallToolResult | TypedCallToolResult<any>, text?: string): CallToolResult;
|
|
59
117
|
/**
|
|
60
118
|
* Create an error response for MCP tools
|
|
61
119
|
*
|
|
@@ -77,13 +135,14 @@ export declare function resource(uri: string, mimeType?: string, text?: string):
|
|
|
77
135
|
*/
|
|
78
136
|
export declare function error(message: string): CallToolResult;
|
|
79
137
|
/**
|
|
80
|
-
* Create a JSON object response for MCP tools
|
|
138
|
+
* Create a JSON object response for MCP tools and resources
|
|
81
139
|
*
|
|
82
140
|
* @param data - The object to return as JSON
|
|
83
141
|
* @returns TypedCallToolResult with JSON text content and typed structuredContent
|
|
84
142
|
*
|
|
85
143
|
* @example
|
|
86
144
|
* ```typescript
|
|
145
|
+
* // For tools
|
|
87
146
|
* server.tool({
|
|
88
147
|
* name: 'get-user-info',
|
|
89
148
|
* cb: async (_args, _ctx, { auth }) => object({
|
|
@@ -91,12 +150,109 @@ export declare function error(message: string): CallToolResult;
|
|
|
91
150
|
* email: auth.user.email
|
|
92
151
|
* })
|
|
93
152
|
* })
|
|
153
|
+
*
|
|
154
|
+
* // For resources
|
|
155
|
+
* server.resource(
|
|
156
|
+
* { name: 'config', uri: 'config://settings' },
|
|
157
|
+
* async () => object({ theme: 'dark', version: '1.0' })
|
|
158
|
+
* )
|
|
94
159
|
* ```
|
|
95
160
|
*/
|
|
96
161
|
export declare function object<T extends Record<string, any>>(data: T): TypedCallToolResult<T>;
|
|
97
162
|
export declare function array<T extends any[]>(data: T): TypedCallToolResult<{
|
|
98
163
|
data: T;
|
|
99
164
|
}>;
|
|
165
|
+
/**
|
|
166
|
+
* Create an HTML content response for MCP tools and resources
|
|
167
|
+
*
|
|
168
|
+
* @param content - The HTML content to return
|
|
169
|
+
* @returns CallToolResult with HTML text content and MIME type metadata
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* server.resource(
|
|
174
|
+
* { name: 'page', uri: 'ui://dashboard' },
|
|
175
|
+
* async () => html('<h1>Dashboard</h1><p>Welcome</p>')
|
|
176
|
+
* )
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function html(content: string): CallToolResult;
|
|
180
|
+
/**
|
|
181
|
+
* Create a Markdown content response for MCP tools and resources
|
|
182
|
+
*
|
|
183
|
+
* @param content - The Markdown content to return
|
|
184
|
+
* @returns CallToolResult with Markdown text content and MIME type metadata
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* server.resource(
|
|
189
|
+
* { name: 'readme', uri: 'doc://readme' },
|
|
190
|
+
* async () => markdown('# Welcome\n\nGetting started...')
|
|
191
|
+
* )
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare function markdown(content: string): CallToolResult;
|
|
195
|
+
/**
|
|
196
|
+
* Create an XML content response for MCP tools and resources
|
|
197
|
+
*
|
|
198
|
+
* @param content - The XML content to return
|
|
199
|
+
* @returns CallToolResult with XML text content and MIME type metadata
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* server.resource(
|
|
204
|
+
* { name: 'sitemap', uri: 'data://sitemap' },
|
|
205
|
+
* async () => xml('<?xml version="1.0"?><root>...</root>')
|
|
206
|
+
* )
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export declare function xml(content: string): CallToolResult;
|
|
210
|
+
/**
|
|
211
|
+
* Create a CSS content response for MCP tools and resources
|
|
212
|
+
*
|
|
213
|
+
* @param content - The CSS content to return
|
|
214
|
+
* @returns CallToolResult with CSS text content and MIME type metadata
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* server.resource(
|
|
219
|
+
* { name: 'styles', uri: 'asset://theme.css' },
|
|
220
|
+
* async () => css('body { margin: 0; }')
|
|
221
|
+
* )
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function css(content: string): CallToolResult;
|
|
225
|
+
/**
|
|
226
|
+
* Create a JavaScript content response for MCP tools and resources
|
|
227
|
+
*
|
|
228
|
+
* @param content - The JavaScript content to return
|
|
229
|
+
* @returns CallToolResult with JavaScript text content and MIME type metadata
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* server.resource(
|
|
234
|
+
* { name: 'script', uri: 'asset://main.js' },
|
|
235
|
+
* async () => javascript('console.log("Hello");')
|
|
236
|
+
* )
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export declare function javascript(content: string): CallToolResult;
|
|
240
|
+
/**
|
|
241
|
+
* Create a binary content response for MCP tools and resources
|
|
242
|
+
*
|
|
243
|
+
* @param base64Data - The base64-encoded binary data
|
|
244
|
+
* @param mimeType - The MIME type of the binary content
|
|
245
|
+
* @returns CallToolResult with binary content and MIME type metadata
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* server.resource(
|
|
250
|
+
* { name: 'document', uri: 'file://document.pdf' },
|
|
251
|
+
* async () => binary(base64PdfData, 'application/pdf')
|
|
252
|
+
* )
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export declare function binary(base64Data: string, mimeType: string): CallToolResult;
|
|
100
256
|
/**
|
|
101
257
|
* Configuration for widget response utility
|
|
102
258
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-helpers.d.ts","sourceRoot":"","sources":["../../../../src/server/utils/response-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"response-helpers.d.ts","sourceRoot":"","sources":["../../../../src/server/utils/response-helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* General utility functions for the MCP server.
|
|
5
|
+
*/
|
|
6
|
+
import { type Hono as HonoType } from "hono";
|
|
7
|
+
import { cors } from "hono/cors";
|
|
8
|
+
/**
|
|
9
|
+
* Get default CORS configuration for MCP server
|
|
10
|
+
*
|
|
11
|
+
* @returns CORS options object for Hono cors middleware
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDefaultCorsOptions(): Parameters<typeof cors>[0];
|
|
14
|
+
/**
|
|
15
|
+
* Create and configure a new Hono app instance with default middleware
|
|
16
|
+
*
|
|
17
|
+
* Sets up CORS and request logging middleware for the MCP server.
|
|
18
|
+
*
|
|
19
|
+
* @param requestLogger - Request logging middleware function
|
|
20
|
+
* @returns Configured Hono app instance
|
|
21
|
+
*/
|
|
22
|
+
export declare function createHonoApp(requestLogger: any): HonoType;
|
|
23
|
+
/**
|
|
24
|
+
* Get the server base URL with fallback to host:port if not configured
|
|
25
|
+
*
|
|
26
|
+
* @param serverBaseUrl - Explicitly configured base URL
|
|
27
|
+
* @param serverHost - Server hostname
|
|
28
|
+
* @param serverPort - Server port
|
|
29
|
+
* @returns The complete base URL for the server
|
|
30
|
+
*/
|
|
31
|
+
export declare function getServerBaseUrl(serverBaseUrl: string | undefined, serverHost: string, serverPort: number | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get additional CSP URLs from environment variable
|
|
34
|
+
* Supports comma-separated list or single URL
|
|
35
|
+
*
|
|
36
|
+
* @returns Array of URLs to add to CSP resource_domains
|
|
37
|
+
*/
|
|
38
|
+
export declare function getCSPUrls(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Wait for transport.handleRequest to complete and response to be written
|
|
41
|
+
*
|
|
42
|
+
* Wraps the transport.handleRequest call in a Promise that only resolves when
|
|
43
|
+
* expressRes.end() is called, ensuring all async operations complete before
|
|
44
|
+
* we attempt to read the response.
|
|
45
|
+
*
|
|
46
|
+
* @param transport - The transport instance
|
|
47
|
+
* @param expressReq - Express-like request object
|
|
48
|
+
* @param expressRes - Express-like response object
|
|
49
|
+
* @param body - Optional request body
|
|
50
|
+
* @returns Promise that resolves when the request is complete
|
|
51
|
+
*/
|
|
52
|
+
export declare function waitForRequestComplete(transport: any, expressReq: any, expressRes: any, body?: any): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Log registered tools, prompts, and resources to console
|
|
55
|
+
*
|
|
56
|
+
* @param registeredTools - Array of registered tool names
|
|
57
|
+
* @param registeredPrompts - Array of registered prompt names
|
|
58
|
+
* @param registeredResources - Array of registered resource names
|
|
59
|
+
*/
|
|
60
|
+
export declare function logRegisteredItems(registeredTools: string[], registeredPrompts: string[], registeredResources: string[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* Parse parameter values from a URI based on a template
|
|
63
|
+
*
|
|
64
|
+
* Extracts parameter values from an actual URI by matching it against a URI template.
|
|
65
|
+
* The template contains placeholders like {param} which are extracted as key-value pairs.
|
|
66
|
+
*
|
|
67
|
+
* @param template - URI template with placeholders (e.g., "user://{userId}/posts/{postId}")
|
|
68
|
+
* @param uri - Actual URI to parse (e.g., "user://123/posts/456")
|
|
69
|
+
* @returns Object mapping parameter names to their values
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const params = parseTemplateUri("user://{userId}/posts/{postId}", "user://123/posts/456")
|
|
74
|
+
* // Returns: { userId: "123", postId: "456" }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseTemplateUri(template: string, uri: string): Record<string, string>;
|
|
78
|
+
//# sourceMappingURL=server-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-helpers.d.ts","sourceRoot":"","sources":["../../../../src/server/utils/server-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,KAAK,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAgBlE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,GAAG,GAAG,QAAQ,CAU1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,CAYR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAerC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,GAAG,EACd,UAAU,EAAE,GAAG,EACf,UAAU,EAAE,GAAG,EACf,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EAAE,EACzB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,mBAAmB,EAAE,MAAM,EAAE,GAC5B,IAAI,CAqBN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Lifecycle Utilities
|
|
3
|
+
*
|
|
4
|
+
* Runtime-aware helpers for server startup, path rewriting, and CORS handling.
|
|
5
|
+
*/
|
|
6
|
+
import type { Hono as HonoType } from "hono";
|
|
7
|
+
export declare function isProductionMode(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Get Deno-specific CORS headers
|
|
10
|
+
*
|
|
11
|
+
* @returns CORS headers object for Deno responses
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDenoCorsHeaders(): Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply CORS headers to a response
|
|
16
|
+
*
|
|
17
|
+
* @param response - The response to add CORS headers to
|
|
18
|
+
* @returns New response with CORS headers applied
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyDenoCorsHeaders(response: Response): Response;
|
|
21
|
+
/**
|
|
22
|
+
* Create a Supabase path rewriter function
|
|
23
|
+
*
|
|
24
|
+
* Supabase includes the function name in the path (e.g., /functions/v1/mcp-server/mcp or /mcp-server/mcp)
|
|
25
|
+
* This function strips the function name prefix to get the actual route path.
|
|
26
|
+
*
|
|
27
|
+
* @returns Function that rewrites Supabase paths to actual route paths
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSupabasePathRewriter(): (pathname: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Rewrite request path for Supabase environment
|
|
32
|
+
*
|
|
33
|
+
* @param req - The original request
|
|
34
|
+
* @returns New request with rewritten path if needed
|
|
35
|
+
*/
|
|
36
|
+
export declare function rewriteSupabaseRequest(req: Request): Request;
|
|
37
|
+
/**
|
|
38
|
+
* Start the server based on runtime environment
|
|
39
|
+
*
|
|
40
|
+
* @param app - Hono application instance
|
|
41
|
+
* @param port - Port number to listen on
|
|
42
|
+
* @param host - Hostname to bind to
|
|
43
|
+
* @param options - Additional options for server startup
|
|
44
|
+
* @param options.onDenoRequest - Optional callback to transform requests in Deno (e.g., for path rewriting)
|
|
45
|
+
* @param options.onDenoResponse - Optional callback to transform responses in Deno (e.g., for CORS)
|
|
46
|
+
* @returns Promise that resolves when server is started
|
|
47
|
+
*/
|
|
48
|
+
export declare function startServer(app: HonoType, port: number, host: string, options?: {
|
|
49
|
+
onDenoRequest?: (req: Request) => Request | Promise<Request>;
|
|
50
|
+
onDenoResponse?: (res: Response) => Response | Promise<Response>;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=server-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/server/utils/server-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AAG7C,wBAAgB,gBAAgB,IAAI,OAAO,CAK1C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM3D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAYjE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,IAAI,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAkBzE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAkB5D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAClE,GACA,OAAO,CAAC,IAAI,CAAC,CAmDf"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common utilities for working with MCP sessions.
|
|
5
|
+
*/
|
|
6
|
+
import type { SessionData } from "../sessions/session-manager.js";
|
|
7
|
+
/**
|
|
8
|
+
* Get a session from the sessions map, or return null if not found
|
|
9
|
+
*
|
|
10
|
+
* This is a safe session lookup helper that ensures consistent handling
|
|
11
|
+
* of missing sessions across the codebase.
|
|
12
|
+
*
|
|
13
|
+
* @param sessions - Map of active sessions
|
|
14
|
+
* @param sessionId - The session ID to look up
|
|
15
|
+
* @returns The session data if found, null otherwise
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const session = getSessionOrNull(sessions, sessionId);
|
|
20
|
+
* if (!session) {
|
|
21
|
+
* return createSessionNotFoundError();
|
|
22
|
+
* }
|
|
23
|
+
* // Use session safely
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSessionOrNull(sessions: Map<string, SessionData>, sessionId: string): SessionData | null;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a session exists
|
|
29
|
+
*
|
|
30
|
+
* @param sessions - Map of active sessions
|
|
31
|
+
* @param sessionId - The session ID to check
|
|
32
|
+
* @returns true if the session exists, false otherwise
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* if (hasSession(sessions, sessionId)) {
|
|
37
|
+
* console.log('Session exists');
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function hasSession(sessions: Map<string, SessionData>, sessionId: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get all active session IDs
|
|
44
|
+
*
|
|
45
|
+
* @param sessions - Map of active sessions
|
|
46
|
+
* @returns Array of session IDs
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const sessionIds = getAllSessionIds(sessions);
|
|
51
|
+
* console.log(`${sessionIds.length} active sessions`);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getAllSessionIds(sessions: Map<string, SessionData>): string[];
|
|
55
|
+
//# sourceMappingURL=session-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-helpers.d.ts","sourceRoot":"","sources":["../../../../src/server/utils/session-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClC,SAAS,EAAE,MAAM,GAChB,WAAW,GAAG,IAAI,CAEpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClC,SAAS,EAAE,MAAM,GAChB,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,EAAE,CAE7E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget mounting and serving utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for mounting and serving MCP widgets in both
|
|
5
|
+
* development and production modes.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from "../mcp-server.js";
|
|
8
|
+
export { mountWidgetsDev, type MountWidgetsDevOptions, } from "./mount-widgets-dev.js";
|
|
9
|
+
export { mountWidgetsProduction, type MountWidgetsProductionOptions, } from "./mount-widgets-production.js";
|
|
10
|
+
export { setupWidgetRoutes } from "./setup-widget-routes.js";
|
|
11
|
+
export { createUIResourceFromDefinition, buildWidgetUrl, createExternalUrlResource, createRawHtmlResource, createRemoteDomResource, createAppsSdkResource, type UrlConfig, } from "./mcp-ui-adapter.js";
|
|
12
|
+
export { generateWidgetUri, convertPropsToInputs, applyDefaultProps, readBuildManifest, createWidgetUIResource, getContentType, processWidgetHtml, createWidgetRegistration, ensureWidgetMetadata, readWidgetHtml, registerWidgetFromTemplate, setupPublicRoutes, type WidgetServerConfig, } from "./widget-helpers.js";
|
|
13
|
+
export { uiResourceRegistration, type UIResourceServerContext, } from "./ui-resource-registration.js";
|
|
14
|
+
export { type ServerConfig, type MountWidgetsOptions, type RegisterWidgetCallback, } from "./widget-types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Mount widget files - automatically chooses between dev and production mode
|
|
17
|
+
*
|
|
18
|
+
* In development mode: creates Vite dev servers with HMR support
|
|
19
|
+
* In production mode: serves pre-built static widgets
|
|
20
|
+
*
|
|
21
|
+
* @param options - Configuration options
|
|
22
|
+
* @param options.baseRoute - Base route for widgets (defaults to '/mcp-use/widgets')
|
|
23
|
+
* @param options.resourcesDir - Directory containing widget files (defaults to 'resources')
|
|
24
|
+
* @returns Promise that resolves when all widgets are mounted
|
|
25
|
+
*/
|
|
26
|
+
export declare function mountWidgets(server: McpServer, options?: {
|
|
27
|
+
baseRoute?: string;
|
|
28
|
+
resourcesDir?: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/widgets/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,8BAA8B,EAC9B,cAAc,EACd,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-ui-adapter.d.ts","sourceRoot":"","sources":["../../../../src/server/widgets/mcp-ui-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACtC,MAAM,EAAE,SAAS,GAChB,MAAM,CAYR;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,UAAmB,EAC7B,QAAQ,CAAC,EAAE,cAAc,EACzB,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,UAAmB,EAC7B,QAAQ,CAAC,EAAE,cAAc,EACzB,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,GAAG,eAAyB,EAC9C,QAAQ,GAAE,UAAmB,EAC7B,QAAQ,CAAC,EAAE,cAAc,EACzB,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,eAAe,GACzB,iBAAiB,CAkBnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,CAClD,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAyD5B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development mode widget mounting with Vite HMR
|
|
3
|
+
*
|
|
4
|
+
* This module handles serving widgets from the resources/ directory in development mode
|
|
5
|
+
* with hot module replacement (HMR) support. It uses Vite to transform and serve
|
|
6
|
+
* React/TSX widget files with live reloading during development.
|
|
7
|
+
*/
|
|
8
|
+
import type { Hono as HonoType } from "hono";
|
|
9
|
+
import type { ServerConfig, MountWidgetsOptions, RegisterWidgetCallback } from "./widget-types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for development widget mounting
|
|
12
|
+
*/
|
|
13
|
+
export type MountWidgetsDevOptions = MountWidgetsOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Mount widgets from resources/ directory in development mode with Vite HMR
|
|
16
|
+
*
|
|
17
|
+
* Discovers TSX widget files and folders with widget.tsx, creates temporary entry files,
|
|
18
|
+
* and sets up a shared Vite dev server with hot module replacement. Each widget is
|
|
19
|
+
* registered as both a tool and resource for MCP-UI compatibility.
|
|
20
|
+
*
|
|
21
|
+
* @param app - Hono app instance to mount routes on
|
|
22
|
+
* @param serverConfig - Server configuration (baseUrl, port, CSP URLs)
|
|
23
|
+
* @param registerWidget - Callback to register each discovered widget
|
|
24
|
+
* @param options - Optional configuration (baseRoute, resourcesDir)
|
|
25
|
+
* @returns Promise that resolves when all widgets are mounted
|
|
26
|
+
*/
|
|
27
|
+
export declare function mountWidgetsDev(app: HonoType, serverConfig: ServerConfig, registerWidget: RegisterWidgetCallback, options?: MountWidgetsDevOptions): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=mount-widgets-dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-widgets-dev.d.ts","sourceRoot":"","sources":["../../../../src/server/widgets/mount-widgets-dev.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAiB,MAAM,MAAM,CAAC;AAQ5D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAI3B;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,sBAAsB,EACtC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAyXf"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production mode widget mounting
|
|
3
|
+
*
|
|
4
|
+
* This module handles serving pre-built widgets from the dist/resources/widgets/ directory.
|
|
5
|
+
* Widgets are built using the 'mcp-use build' command and served as static files in production.
|
|
6
|
+
*/
|
|
7
|
+
import type { Hono as HonoType } from "hono";
|
|
8
|
+
import type { ServerConfig, MountWidgetsOptions, RegisterWidgetCallback } from "./widget-types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for production widget mounting
|
|
11
|
+
*/
|
|
12
|
+
export type MountWidgetsProductionOptions = MountWidgetsOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Mount pre-built widgets from dist/resources/widgets/ directory in production mode
|
|
15
|
+
*
|
|
16
|
+
* Serves static widget bundles that were built using the build command.
|
|
17
|
+
* Reads the manifest file to discover available widgets and their metadata,
|
|
18
|
+
* then registers each widget as both a tool and resource.
|
|
19
|
+
*
|
|
20
|
+
* @param app - Hono app instance (not used directly, kept for consistency)
|
|
21
|
+
* @param serverConfig - Server configuration (baseUrl, CSP URLs, buildId)
|
|
22
|
+
* @param registerWidget - Callback to register each discovered widget
|
|
23
|
+
* @param options - Optional configuration (baseRoute)
|
|
24
|
+
* @returns Promise that resolves when all widgets are mounted
|
|
25
|
+
*/
|
|
26
|
+
export declare function mountWidgetsProduction(app: HonoType, serverConfig: ServerConfig, registerWidget: RegisterWidgetCallback, options?: MountWidgetsProductionOptions): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=mount-widgets-production.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-widgets-production.d.ts","sourceRoot":"","sources":["../../../../src/server/widgets/mount-widgets-production.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AAI7C,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,sBAAsB,EACtC,OAAO,CAAC,EAAE,6BAA6B,GACtC,OAAO,CAAC,IAAI,CAAC,CAuGf"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static widget route handlers
|
|
3
|
+
*
|
|
4
|
+
* This module sets up HTTP routes for serving widget assets, HTML files,
|
|
5
|
+
* and public resources in production mode.
|
|
6
|
+
*/
|
|
7
|
+
import type { Hono as HonoType } from "hono";
|
|
8
|
+
import type { ServerConfig } from "./widget-types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Setup static file serving routes for widgets
|
|
11
|
+
*
|
|
12
|
+
* Creates HTTP routes to serve:
|
|
13
|
+
* - Widget assets (JS, CSS, images) from dist/resources/widgets/{widget}/assets/
|
|
14
|
+
* - Widget HTML files from dist/resources/widgets/{widget}/index.html
|
|
15
|
+
* - Public files from dist/public/ or public/ directories
|
|
16
|
+
*
|
|
17
|
+
* These routes are used in production mode to serve pre-built widget bundles.
|
|
18
|
+
*
|
|
19
|
+
* @param app - Hono app instance to mount routes on
|
|
20
|
+
* @param serverConfig - Server configuration (baseUrl)
|
|
21
|
+
*/
|
|
22
|
+
export declare function setupWidgetRoutes(app: HonoType, serverConfig: ServerConfig): void;
|
|
23
|
+
//# sourceMappingURL=setup-widget-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-widget-routes.d.ts","sourceRoot":"","sources":["../../../../src/server/widgets/setup-widget-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAW,MAAM,MAAM,CAAC;AAOtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,YAAY,GACzB,IAAI,CA0FN"}
|