mcp-use 1.0.4 → 1.0.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 (34) hide show
  1. package/README.md +98 -1
  2. package/dist/index.cjs +118 -689
  3. package/dist/index.d.ts +10 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +118 -54
  6. package/dist/src/agents/mcp_agent.d.ts +1 -1
  7. package/dist/src/agents/mcp_agent.d.ts.map +1 -1
  8. package/dist/src/server/adapters/mcp-ui-adapter.d.ts +66 -0
  9. package/dist/src/server/adapters/mcp-ui-adapter.d.ts.map +1 -0
  10. package/dist/src/server/index.cjs +292 -14
  11. package/dist/src/server/index.d.ts +4 -2
  12. package/dist/src/server/index.d.ts.map +1 -1
  13. package/dist/src/server/index.js +913 -4
  14. package/dist/src/server/mcp-server.d.ts +91 -2
  15. package/dist/src/server/mcp-server.d.ts.map +1 -1
  16. package/dist/src/server/types/common.d.ts +27 -0
  17. package/dist/src/server/types/common.d.ts.map +1 -0
  18. package/dist/src/server/types/index.d.ts +8 -0
  19. package/dist/src/server/types/index.d.ts.map +1 -0
  20. package/dist/src/server/types/prompt.d.ts +14 -0
  21. package/dist/src/server/types/prompt.d.ts.map +1 -0
  22. package/dist/src/server/types/resource.d.ts +155 -0
  23. package/dist/src/server/types/resource.d.ts.map +1 -0
  24. package/dist/src/server/types/tool.d.ts +14 -0
  25. package/dist/src/server/types/tool.d.ts.map +1 -0
  26. package/dist/src/server/types.d.ts +3 -76
  27. package/dist/src/server/types.d.ts.map +1 -1
  28. package/dist/tests/helpers/widget-generators.d.ts +24 -0
  29. package/dist/tests/helpers/widget-generators.d.ts.map +1 -0
  30. package/dist/tests/mcp-ui-adapter.test.d.ts +8 -0
  31. package/dist/tests/mcp-ui-adapter.test.d.ts.map +1 -0
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +33 -36
  34. package/dist/chunk-MZPKOZE4.js +0 -644
@@ -1,4 +1,4 @@
1
- import type { PromptDefinition, ResourceDefinition, ResourceTemplateDefinition, ServerConfig, ToolDefinition } from './types.js';
1
+ import type { PromptDefinition, ResourceDefinition, ResourceTemplateDefinition, ServerConfig, ToolDefinition, UIResourceDefinition } from './types/index.js';
2
2
  import { type Express } from 'express';
3
3
  export declare class McpServer {
4
4
  private server;
@@ -157,12 +157,101 @@ export declare class McpServer {
157
157
  * ```
158
158
  */
159
159
  prompt(promptDefinition: PromptDefinition): this;
160
+ /**
161
+ * Register a UI widget as both a tool and a resource
162
+ *
163
+ * Creates a unified interface for MCP-UI compatible widgets that can be accessed
164
+ * either as tools (with parameters) or as resources (static access). The tool
165
+ * allows dynamic parameter passing while the resource provides discoverable access.
166
+ *
167
+ * @param definition - Configuration for the UI widget
168
+ * @param definition.name - Unique identifier for the resource
169
+ * @param definition.widget - Widget name (matches directory in dist/resources/mcp-use/widgets)
170
+ * @param definition.title - Human-readable title for the widget
171
+ * @param definition.description - Description of the widget's functionality
172
+ * @param definition.props - Widget properties configuration with types and defaults
173
+ * @param definition.size - Preferred iframe size [width, height] (e.g., ['800px', '600px'])
174
+ * @param definition.annotations - Resource annotations for discovery
175
+ * @returns The server instance for method chaining
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * server.uiResource({
180
+ * name: 'kanban-board',
181
+ * widget: 'kanban-board',
182
+ * title: 'Kanban Board',
183
+ * description: 'Interactive task management board',
184
+ * props: {
185
+ * initialTasks: {
186
+ * type: 'array',
187
+ * description: 'Initial tasks to display',
188
+ * required: false
189
+ * },
190
+ * theme: {
191
+ * type: 'string',
192
+ * default: 'light'
193
+ * }
194
+ * },
195
+ * size: ['900px', '600px']
196
+ * })
197
+ * ```
198
+ */
199
+ uiResource(definition: UIResourceDefinition): this;
200
+ /**
201
+ * Create a UIResource object for a widget with the given parameters
202
+ *
203
+ * This method is shared between tool and resource handlers to avoid duplication.
204
+ * It creates a consistent UIResource structure that can be rendered by MCP-UI
205
+ * compatible clients.
206
+ *
207
+ * @private
208
+ * @param definition - UIResource definition
209
+ * @param params - Parameters to pass to the widget via URL
210
+ * @returns UIResource object compatible with MCP-UI
211
+ */
212
+ private createWidgetUIResource;
213
+ /**
214
+ * Build a complete URL for a widget including query parameters
215
+ *
216
+ * Constructs the full URL to access a widget's iframe, encoding any provided
217
+ * parameters as query string parameters. Complex objects are JSON-stringified
218
+ * for transmission.
219
+ *
220
+ * @private
221
+ * @param widget - Widget name/identifier
222
+ * @param params - Parameters to encode in the URL
223
+ * @returns Complete URL with encoded parameters
224
+ */
225
+ private buildWidgetUrl;
226
+ /**
227
+ * Convert widget props definition to tool input schema
228
+ *
229
+ * Transforms the widget props configuration into the format expected by
230
+ * the tool registration system, mapping types and handling defaults.
231
+ *
232
+ * @private
233
+ * @param props - Widget props configuration
234
+ * @returns Array of InputDefinition objects for tool registration
235
+ */
236
+ private convertPropsToInputs;
237
+ /**
238
+ * Apply default values to widget props
239
+ *
240
+ * Extracts default values from the props configuration to use when
241
+ * the resource is accessed without parameters.
242
+ *
243
+ * @private
244
+ * @param props - Widget props configuration
245
+ * @returns Object with default values for each prop
246
+ */
247
+ private applyDefaultProps;
160
248
  /**
161
249
  * Mount MCP server endpoints at /mcp
162
250
  *
163
251
  * Sets up the HTTP transport layer for the MCP server, creating endpoints for
164
252
  * Server-Sent Events (SSE) streaming, POST message handling, and DELETE session cleanup.
165
- * Uses stateless mode for session management, making it suitable for stateless deployments.
253
+ * Each request gets its own transport instance to prevent state conflicts between
254
+ * concurrent client connections.
166
255
  *
167
256
  * This method is called automatically when the server starts listening and ensures
168
257
  * that MCP clients can communicate with the server over HTTP.
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAA;AAGnB,OAAgB,EAAE,KAAK,OAAO,EAA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;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,UAAU,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAyElD;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;IAsBtB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAY5B;;;;;;;;;OASG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;;;;;;;;;;;;;;;;;;OAmBG;YACW,QAAQ;IAyDtB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,cAAc;IAqBtB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,iBAAiB;IAsCzB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,qBAAqB;IAmC7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,sBAAsB;IAmC9B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,gBAAgB;CAyBzB;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,OAAO,CAAA;AAExE;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,iBAAiB,CAOnG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Common type definitions shared across different MCP components
3
+ */
4
+ export interface ServerConfig {
5
+ name: string;
6
+ version: string;
7
+ description?: string;
8
+ }
9
+ export interface InputDefinition {
10
+ name: string;
11
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
12
+ description?: string;
13
+ required?: boolean;
14
+ default?: any;
15
+ }
16
+ /**
17
+ * Annotations provide hints to clients about how to use or display resources
18
+ */
19
+ export interface ResourceAnnotations {
20
+ /** Intended audience(s) for this resource */
21
+ audience?: ('user' | 'assistant')[];
22
+ /** Priority from 0.0 (least important) to 1.0 (most important) */
23
+ priority?: number;
24
+ /** ISO 8601 formatted timestamp of last modification */
25
+ lastModified?: string;
26
+ }
27
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/server/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAA;IACnC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Centralized type exports for MCP server
3
+ */
4
+ export { ServerConfig, InputDefinition, ResourceAnnotations } from './common.js';
5
+ export { ResourceHandler, ResourceTemplateHandler, ResourceTemplateConfig, ResourceTemplateDefinition, ResourceDefinition, UIResourceContent, WidgetProps, UIEncoding, RemoteDomFramework, UIResourceDefinition, ExternalUrlUIResource, RawHtmlUIResource, RemoteDomUIResource, WidgetConfig, WidgetManifest, DiscoverWidgetsOptions } from './resource.js';
6
+ export { ToolHandler, ToolDefinition } from './tool.js';
7
+ export { PromptHandler, PromptDefinition } from './prompt.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACpB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAElB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,sBAAsB,EACvB,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,WAAW,EACX,cAAc,EACf,MAAM,WAAW,CAAA;AAGlB,OAAO,EACL,aAAa,EACb,gBAAgB,EACjB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { InputDefinition } from './common.js';
3
+ export type PromptHandler = (params: Record<string, any>) => Promise<GetPromptResult>;
4
+ export interface PromptDefinition {
5
+ /** Unique identifier for the prompt */
6
+ name: string;
7
+ /** Description of what the prompt does */
8
+ description?: string;
9
+ /** Argument definitions */
10
+ args?: InputDefinition[];
11
+ /** Async function that generates the prompt */
12
+ fn: PromptHandler;
13
+ }
14
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/server/types/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;AAErF,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,eAAe,EAAE,CAAA;IACxB,+CAA+C;IAC/C,EAAE,EAAE,aAAa,CAAA;CAClB"}
@@ -0,0 +1,155 @@
1
+ import type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { ResourceAnnotations } from './common.js';
3
+ export type UIResourceContent = {
4
+ type: 'resource';
5
+ resource: {
6
+ uri: string;
7
+ mimeType: string;
8
+ } & ({
9
+ text: string;
10
+ blob?: never;
11
+ } | {
12
+ blob: string;
13
+ text?: never;
14
+ });
15
+ };
16
+ export type ResourceHandler = () => Promise<ReadResourceResult>;
17
+ export type ResourceTemplateHandler = (uri: URL, params: Record<string, any>) => Promise<ReadResourceResult>;
18
+ /**
19
+ * Configuration for a resource template
20
+ */
21
+ export interface ResourceTemplateConfig {
22
+ /** URI template with {param} placeholders (e.g., "user://{userId}/profile") */
23
+ uriTemplate: string;
24
+ /** Name of the resource */
25
+ name?: string;
26
+ /** MIME type of the resource content */
27
+ mimeType?: string;
28
+ /** Description of the resource */
29
+ description?: string;
30
+ }
31
+ export interface ResourceTemplateDefinition {
32
+ name: string;
33
+ resourceTemplate: ResourceTemplateConfig;
34
+ title?: string;
35
+ description?: string;
36
+ annotations?: ResourceAnnotations;
37
+ fn: ResourceTemplateHandler;
38
+ }
39
+ export interface ResourceDefinition {
40
+ /** Unique identifier for the resource */
41
+ name: string;
42
+ /** URI pattern for accessing the resource (e.g., 'config://app-settings') */
43
+ uri: string;
44
+ /** Optional title for the resource */
45
+ title?: string;
46
+ /** Optional description of the resource */
47
+ description?: string;
48
+ /** MIME type of the resource content (required) */
49
+ mimeType: string;
50
+ /** Optional annotations for the resource */
51
+ annotations?: ResourceAnnotations;
52
+ /** Async function that returns the resource content */
53
+ fn: ResourceHandler;
54
+ }
55
+ /**
56
+ * UIResource-specific types
57
+ */
58
+ export interface WidgetProps {
59
+ [key: string]: {
60
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
61
+ required?: boolean;
62
+ default?: any;
63
+ description?: string;
64
+ };
65
+ }
66
+ /**
67
+ * Encoding options for UI resources
68
+ */
69
+ export type UIEncoding = 'text' | 'blob';
70
+ /**
71
+ * Framework options for Remote DOM resources
72
+ */
73
+ export type RemoteDomFramework = 'react' | 'webcomponents';
74
+ /**
75
+ * Base properties shared by all UI resource types
76
+ */
77
+ interface BaseUIResourceDefinition {
78
+ /** Unique identifier for the resource */
79
+ name: string;
80
+ /** Human-readable title */
81
+ title?: string;
82
+ /** Description of what the widget does */
83
+ description?: string;
84
+ /** Widget properties/parameters configuration */
85
+ props?: WidgetProps;
86
+ /** Preferred frame size [width, height] (e.g., ['800px', '600px']) */
87
+ size?: [string, string];
88
+ /** Resource annotations for discovery and presentation */
89
+ annotations?: ResourceAnnotations;
90
+ /** Encoding for the resource content (defaults to 'text') */
91
+ encoding?: UIEncoding;
92
+ }
93
+ /**
94
+ * External URL UI resource - serves widget via iframe
95
+ */
96
+ export interface ExternalUrlUIResource extends BaseUIResourceDefinition {
97
+ type: 'externalUrl';
98
+ /** Widget identifier (e.g., 'kanban-board', 'chart') */
99
+ widget: string;
100
+ }
101
+ /**
102
+ * Raw HTML UI resource - direct HTML content
103
+ */
104
+ export interface RawHtmlUIResource extends BaseUIResourceDefinition {
105
+ type: 'rawHtml';
106
+ /** HTML content to render */
107
+ htmlContent: string;
108
+ }
109
+ /**
110
+ * Remote DOM UI resource - scripted UI components
111
+ */
112
+ export interface RemoteDomUIResource extends BaseUIResourceDefinition {
113
+ type: 'remoteDom';
114
+ /** JavaScript code for remote DOM manipulation */
115
+ script: string;
116
+ /** Framework for remote DOM (defaults to 'react') */
117
+ framework?: RemoteDomFramework;
118
+ }
119
+ /**
120
+ * Discriminated union of all UI resource types
121
+ */
122
+ export type UIResourceDefinition = ExternalUrlUIResource | RawHtmlUIResource | RemoteDomUIResource;
123
+ export interface WidgetConfig {
124
+ /** Widget directory name */
125
+ name: string;
126
+ /** Absolute path to widget directory */
127
+ path: string;
128
+ /** Widget manifest if present */
129
+ manifest?: WidgetManifest;
130
+ /** Main component file name */
131
+ component?: string;
132
+ }
133
+ export interface WidgetManifest {
134
+ name: string;
135
+ title?: string;
136
+ description?: string;
137
+ version?: string;
138
+ props?: WidgetProps;
139
+ size?: [string, string];
140
+ assets?: {
141
+ main?: string;
142
+ scripts?: string[];
143
+ styles?: string[];
144
+ };
145
+ }
146
+ export interface DiscoverWidgetsOptions {
147
+ /** Path to widgets directory (defaults to dist/resources/mcp-use/widgets) */
148
+ path?: string;
149
+ /** Automatically register widgets without manifests */
150
+ autoRegister?: boolean;
151
+ /** Filter widgets by name pattern */
152
+ filter?: string | RegExp;
153
+ }
154
+ export {};
155
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../../src/server/types/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAA;QACX,QAAQ,EAAE,MAAM,CAAA;KACjB,GAAG,CACA;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,KAAK,CAAA;KAAE,GAC9B;QAAE,IAA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M,oBAAoB,GAC5B,qBAAqB,GACrB,iBAAiB,GACjB,mBAAmB,CAAA;AAEvB,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACzB"}
@@ -0,0 +1,14 @@
1
+ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { InputDefinition } from './common.js';
3
+ export type ToolHandler = (params: Record<string, any>) => Promise<CallToolResult>;
4
+ export interface ToolDefinition {
5
+ /** Unique identifier for the tool */
6
+ name: string;
7
+ /** Description of what the tool does */
8
+ description?: string;
9
+ /** Input parameter definitions */
10
+ inputs?: InputDefinition[];
11
+ /** Async function that executes the tool */
12
+ fn: ToolHandler;
13
+ }
14
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../src/server/types/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAElF,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kCAAkC;IAClC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;IAC1B,4CAA4C;IAC5C,EAAE,EAAE,WAAW,CAAA;CAChB"}
@@ -1,79 +1,6 @@
1
- import type { CallToolResult, GetPromptResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
2
- export interface ServerConfig {
3
- name: string;
4
- version: string;
5
- description?: string;
6
- }
7
- export interface InputDefinition {
8
- name: string;
9
- type: 'string' | 'number' | 'boolean' | 'object' | 'array';
10
- description?: string;
11
- required?: boolean;
12
- default?: any;
13
- }
14
1
  /**
15
- * Annotations provide hints to clients about how to use or display resources
2
+ * Legacy types export file - maintained for backward compatibility
3
+ * New code should import from './types/index.js' instead
16
4
  */
17
- export interface ResourceAnnotations {
18
- /** Intended audience(s) for this resource */
19
- audience?: ('user' | 'assistant')[];
20
- /** Priority from 0.0 (least important) to 1.0 (most important) */
21
- priority?: number;
22
- /** ISO 8601 formatted timestamp of last modification */
23
- lastModified?: string;
24
- }
25
- /**
26
- * Configuration for a resource template
27
- */
28
- export interface ResourceTemplateConfig {
29
- /** URI template with {param} placeholders (e.g., "user://{userId}/profile") */
30
- uriTemplate: string;
31
- /** Name of the resource */
32
- name?: string;
33
- /** MIME type of the resource content */
34
- mimeType?: string;
35
- /** Description of the resource */
36
- description?: string;
37
- }
38
- export interface ResourceTemplateDefinition {
39
- name: string;
40
- resourceTemplate: ResourceTemplateConfig;
41
- title?: string;
42
- description?: string;
43
- annotations?: ResourceAnnotations;
44
- fn: ResourceTemplateHandler;
45
- }
46
- export interface ResourceDefinition {
47
- /** Unique identifier for the resource */
48
- name: string;
49
- /** URI pattern for accessing the resource (e.g., 'config://app-settings') */
50
- uri: string;
51
- /** Resource metadata including MIME type and description */
52
- /** Optional title for the resource */
53
- title?: string;
54
- /** Optional description of the resource */
55
- description?: string;
56
- /** MIME type of the resource content (required) */
57
- mimeType: string;
58
- /** Optional annotations for the resource */
59
- annotations?: ResourceAnnotations;
60
- /** Async function that returns the resource content */
61
- fn: ResourceHandler;
62
- }
63
- export interface ToolDefinition {
64
- name: string;
65
- description?: string;
66
- inputs?: InputDefinition[];
67
- fn: ToolHandler;
68
- }
69
- export interface PromptDefinition {
70
- name: string;
71
- description?: string;
72
- args?: InputDefinition[];
73
- fn: PromptHandler;
74
- }
75
- export type ResourceHandler = () => Promise<ReadResourceResult>;
76
- export type ResourceTemplateHandler = (uri: URL, params: Record<string, any>) => Promise<ReadResourceResult>;
77
- export type ToolHandler = (params: Record<string, any>) => Promise<CallToolResult>;
78
- export type PromptHandler = (params: Record<string, any>) => Promise<GetPromptResult>;
5
+ export * from './types/index.js';
79
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,oCAAoC,CAAA;AAC5G,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI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,uDAAuD;IACvD,EAAE,EAAE,eAAe,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;IAC1B,EAAE,EAAE,WAAW,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,eAAe,EAAE,CAAA;IACxB,EAAE,EAAE,aAAa,CAAA;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAC/D,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAC5G,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAClF,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Test Helper Utilities for Widget Generation
3
+ *
4
+ * These functions generate HTML and JavaScript content for testing purposes.
5
+ * They are not part of the core UIResource creation flow.
6
+ */
7
+ import type { UIResourceDefinition } from 'mcp-use/server';
8
+ /**
9
+ * Generate HTML content for a widget (utility function for tests)
10
+ *
11
+ * @param definition - Base UI resource definition
12
+ * @param props - Widget properties to inject
13
+ * @returns Generated HTML string
14
+ */
15
+ export declare function generateWidgetHtml(definition: Pick<UIResourceDefinition, 'name' | 'title' | 'description' | 'size'>, props?: Record<string, any>): string;
16
+ /**
17
+ * Generate a Remote DOM script for a widget (utility function for tests)
18
+ *
19
+ * @param definition - Base UI resource definition
20
+ * @param props - Widget properties to inject
21
+ * @returns Generated JavaScript string
22
+ */
23
+ export declare function generateRemoteDomScript(definition: Pick<UIResourceDefinition, 'name' | 'title' | 'description'>, props?: Record<string, any>): string;
24
+ //# sourceMappingURL=widget-generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-generators.d.ts","sourceRoot":"","sources":["../../../tests/helpers/widget-generators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE1D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,MAAM,CAAC,EACjF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,MAAM,CA+DR;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC,EACxE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,MAAM,CAyCR"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tests for MCP-UI Adapter
3
+ *
4
+ * These tests verify that the adapter pure functions correctly generate UIResource objects
5
+ * matching the @mcp-ui/server format for all content types.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=mcp-ui-adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-ui-adapter.test.d.ts","sourceRoot":"","sources":["../../tests/mcp-ui-adapter.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}