xmcp 0.6.4 → 0.6.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 (41) hide show
  1. package/dist/cli.js +45 -29
  2. package/dist/compiler/config/index.d.ts +59 -0
  3. package/dist/compiler/config/schemas/template.d.ts +40 -0
  4. package/dist/compiler/config/schemas/transport/stdio.d.ts +5 -0
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +4 -4
  7. package/dist/runtime/adapter-express.js +15 -38
  8. package/dist/runtime/adapter-nestjs.js +17 -40
  9. package/dist/runtime/adapter-nextjs.js +16 -39
  10. package/dist/runtime/http.js +23 -46
  11. package/dist/runtime/stdio.js +16 -39
  12. package/dist/types/resource.d.ts +3 -3
  13. package/dist/types/tool.d.ts +4 -4
  14. package/dist/types/ui-meta.d.ts +22 -0
  15. package/package.json +2 -2
  16. package/src/compiler/client/component-compiler.ts +0 -4
  17. package/src/compiler/config/__tests__/config.test.ts +36 -0
  18. package/src/compiler/config/injection.ts +63 -1
  19. package/src/compiler/config/schemas/template.ts +17 -0
  20. package/src/compiler/config/schemas/transport/stdio.ts +1 -0
  21. package/src/compiler/generate-tools-code.ts +21 -1
  22. package/src/compiler/get-bundler-config/get-injected-variables.ts +3 -0
  23. package/src/compiler/index.ts +100 -24
  24. package/src/compiler/on-first-build.ts +34 -50
  25. package/src/compiler/start-http-server.ts +11 -4
  26. package/src/compiler/watcher-recovery.ts +72 -0
  27. package/src/index.ts +2 -1
  28. package/src/runtime/transports/stdio/index.ts +19 -0
  29. package/src/runtime/utils/react/generate-html.ts +0 -32
  30. package/src/runtime/utils/resources.ts +15 -15
  31. package/src/runtime/utils/server.ts +5 -8
  32. package/src/runtime/utils/tools.ts +55 -71
  33. package/src/runtime/utils/transformers/tool.ts +148 -30
  34. package/src/types/resource.ts +3 -3
  35. package/src/types/tool.ts +4 -4
  36. package/src/types/ui-meta.ts +26 -0
  37. package/dist/types/openai-meta.d.ts +0 -173
  38. package/src/runtime/utils/openai/flatten-meta.ts +0 -44
  39. package/src/runtime/utils/openai/split-meta.ts +0 -81
  40. package/src/runtime/utils/openai-resource-registry.ts +0 -58
  41. package/src/types/openai-meta.ts +0 -191
@@ -1,191 +0,0 @@
1
- /**
2
- * OpenAI tool invocation metadata
3
- */
4
- export interface OpenAIToolInvocation {
5
- /**
6
- * Message displayed while the tool is executing
7
- * @example "Hand-tossing a map..."
8
- */
9
- invoking?: string;
10
-
11
- /**
12
- * Message displayed after the tool completes
13
- * @example "Served a fresh map!"
14
- */
15
- invoked?: string;
16
- }
17
-
18
- /**
19
- * OpenAI metadata for MCP tools and resources.
20
- *
21
- * This interface defines metadata that can be specified in nested form in your tool/resource
22
- * configuration. The framework will automatically flatten it and split it appropriately:
23
- *
24
- * - Tool-specific metadata will be applied to the tool
25
- * - Resource-specific metadata will be applied to auto-generated resources
26
- *
27
- * @example
28
- * ```typescript
29
- * // In your tool definition:
30
- * export const metadata = {
31
- * name: "get_map",
32
- * description: "Gets a map",
33
- * _meta: {
34
- * openai: {
35
- * // Tool-specific: status messages during execution
36
- * toolInvocation: {
37
- * invoking: "Hand-tossing a map...",
38
- * invoked: "Served a fresh map!"
39
- * },
40
- * // Tool-specific: enables widget-to-tool communication
41
- * widgetAccessible: true,
42
- *
43
- * // Resource-specific: describes the widget
44
- * widgetDescription: "Interactive map viewer",
45
- * widgetPrefersBorder: true,
46
- * widgetCSP: {
47
- * connect_domains: ["https://api.mapbox.com"],
48
- * resource_domains: ["https://cdn.mapbox.com"]
49
- * }
50
- * }
51
- * }
52
- * };
53
- * ```
54
- */
55
- export interface OpenAIMetadata {
56
- // ==================== Tool-specific metadata ====================
57
-
58
- /**
59
- * Tool invocation status messages
60
- * - `openai/toolInvocation/invoking` - Loading state text (≤64 chars)
61
- * - `openai/toolInvocation/invoked` - Completion state text (≤64 chars)
62
- */
63
- toolInvocation?: OpenAIToolInvocation;
64
-
65
- /**
66
- * Whether the widget is accessible in the UI (enables widget-to-tool communication)
67
- * Maps to: `openai/widgetAccessible`
68
- * @default true
69
- */
70
- widgetAccessible?: boolean;
71
-
72
- /**
73
- * URI template for the widget resource for MCP Apps
74
- * Maps to: `ui/resourceUri`
75
- *
76
- * Auto-generated as `ui://widget/{toolName}.html` if not provided.
77
- *
78
- * @example "ui://widget/my-tool.html"
79
- */
80
- resourceUri?: string;
81
-
82
- /**
83
- * URI template for the widget resource
84
- * Maps to: `openai/outputTemplate`
85
- *
86
- * Auto-generated as `ui://widget/{toolName}.html` if not provided.
87
- *
88
- * @example "ui://widget/my-tool.html"
89
- */
90
- outputTemplate?: string;
91
-
92
- // ==================== Resource-specific metadata ====================
93
-
94
- /**
95
- * Human-readable widget summary
96
- * Maps to: `openai/widgetDescription`
97
- */
98
- widgetDescription?: string;
99
-
100
- /**
101
- * UI rendering hint for border preference
102
- * Maps to: `openai/widgetPrefersBorder`
103
- */
104
- widgetPrefersBorder?: boolean;
105
-
106
- /**
107
- * Content Security Policy configuration
108
- * Maps to: `openai/widgetCSP`
109
- *
110
- * Defines allowed domains for widget resources and connections.
111
- * These arrays map to CSP directives:
112
- * - `resource_domains` → script-src, img-src, font-src
113
- * - `connect_domains` → connect-src
114
- *
115
- * Generated CSP:
116
- * ```
117
- * script-src 'self' ${resource_domains}
118
- * img-src 'self' data: ${resource_domains}
119
- * font-src 'self' ${resource_domains}
120
- * connect-src 'self' ${connect_domains}
121
- * ```
122
- *
123
- * @example
124
- * ```typescript
125
- * widgetCSP: {
126
- * connect_domains: ["https://api.example.com"],
127
- * resource_domains: ["https://cdn.example.com", "https://fonts.googleapis.com"]
128
- * }
129
- * ```
130
- */
131
- widgetCSP?: {
132
- /** URLs allowed for fetch, WebSocket, and other connections (connect-src) */
133
- connect_domains?: string[];
134
- /** URLs allowed for scripts, images, and fonts (script-src, img-src, font-src) */
135
- resource_domains?: string[];
136
- };
137
-
138
- /**
139
- * Content Security Policy configuration (mcp-apps-only)
140
- *
141
- * Servers declare which external origins their UI needs to access.
142
- * Hosts use this to enforce appropriate CSP headers.
143
- */
144
- csp?: {
145
- /**
146
- * Origins for network requests
147
- *
148
- * - Empty or omitted = no external connections (secure default)
149
- * - Maps to CSP `connect-src` directive
150
- *
151
- * @example
152
- * ["https://api.weather.com", "wss://realtime.service.com"]
153
- */
154
- connectDomains?: string[];
155
- /**
156
- * Origins for static resources (images, scripts, stylesheets, fonts)
157
- *
158
- * - Empty or omitted = no external resources (secure default)
159
- * - Wildcard subdomains supported: `https://*.example.com`
160
- * - Maps to CSP `img-src`, `script-src`, `style-src`, `font-src` directives
161
- *
162
- * @example
163
- * ["https://cdn.jsdelivr.net", "https://*.cloudflare.com"]
164
- */
165
- resourceDomains?: string[];
166
- };
167
-
168
- /**
169
- * Optional dedicated subdomain for widget
170
- * Maps to: `openai/widgetDomain`
171
- */
172
- widgetDomain?: string;
173
-
174
- /**
175
- * Widget state object
176
- * Maps to: `openai/widgetState`
177
- */
178
- widgetState?: UnknownObject;
179
-
180
- // ==================== Shared/deprecated metadata ====================
181
-
182
- /**
183
- * Whether the result can produce a widget
184
- * @default true
185
- */
186
- resultCanProduceWidget?: boolean;
187
- }
188
-
189
- type UnknownObject = {
190
- [x: string]: unknown;
191
- };