@lantos1618/better-ui 0.4.0 → 0.5.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.
@@ -0,0 +1,144 @@
1
+ import { T as Tool, c as ToolContext } from '../tool-Ca2x-VNK.mjs';
2
+ import { z } from 'zod';
3
+ import 'react';
4
+
5
+ /**
6
+ * MCP (Model Context Protocol) Server for Better UI
7
+ *
8
+ * Exposes registered Better UI tools as MCP tools, allowing any MCP-compatible
9
+ * client (Claude Desktop, Cursor, VS Code, etc.) to discover and call them.
10
+ *
11
+ * Protocol: JSON-RPC 2.0 over stdio (newline-delimited JSON)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { createMCPServer } from '@lantos1618/better-ui/mcp';
16
+ * import { weatherTool, searchTool } from './tools';
17
+ *
18
+ * const server = createMCPServer({
19
+ * name: 'my-tools',
20
+ * version: '1.0.0',
21
+ * tools: { weather: weatherTool, search: searchTool },
22
+ * });
23
+ *
24
+ * server.start(); // Listens on stdin/stdout
25
+ * ```
26
+ */
27
+
28
+ interface MCPServerConfig {
29
+ /** Server name exposed to MCP clients */
30
+ name: string;
31
+ /** Server version */
32
+ version: string;
33
+ /** Tool registry — keys are tool names */
34
+ tools: Record<string, Tool>;
35
+ /** Optional context passed to every tool execution */
36
+ context?: Partial<ToolContext>;
37
+ /** Called when the server starts */
38
+ onStart?: () => void;
39
+ /** Called on errors */
40
+ onError?: (error: Error) => void;
41
+ }
42
+ interface JsonRpcRequest {
43
+ jsonrpc: '2.0';
44
+ id?: string | number | null;
45
+ method: string;
46
+ params?: Record<string, unknown>;
47
+ }
48
+ interface JsonRpcResponse {
49
+ jsonrpc: '2.0';
50
+ id: string | number | null;
51
+ result?: unknown;
52
+ error?: {
53
+ code: number;
54
+ message: string;
55
+ data?: unknown;
56
+ };
57
+ }
58
+ interface MCPToolSchema {
59
+ name: string;
60
+ description?: string;
61
+ inputSchema: Record<string, unknown>;
62
+ }
63
+ declare class MCPServer {
64
+ private config;
65
+ private initialized;
66
+ private running;
67
+ constructor(config: MCPServerConfig);
68
+ /** Start listening on stdin for JSON-RPC messages */
69
+ start(): void;
70
+ /** Stop the server */
71
+ stop(): void;
72
+ /** Handle a single JSON-RPC message. Returns a response or null for notifications. */
73
+ handleMessage(message: JsonRpcRequest): Promise<JsonRpcResponse | null>;
74
+ /** Get all tools as MCP tool schemas */
75
+ listTools(): MCPToolSchema[];
76
+ /** Execute a tool by name */
77
+ callTool(name: string, args: unknown): Promise<{
78
+ content: Array<{
79
+ type: string;
80
+ text: string;
81
+ }>;
82
+ }>;
83
+ private handleLine;
84
+ private handleInitialize;
85
+ private handleToolsList;
86
+ private handleToolsCall;
87
+ /**
88
+ * Create a Web Request handler for HTTP-based MCP transport.
89
+ * Compatible with Next.js route handlers, Deno, Bun, Cloudflare Workers, etc.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // Next.js route: app/api/mcp/route.ts
94
+ * import { server } from '@/lib/mcp';
95
+ * export const POST = server.httpHandler();
96
+ * ```
97
+ */
98
+ httpHandler(): (req: Request) => Promise<Response>;
99
+ }
100
+ /**
101
+ * Create an MCP server from a Better UI tool registry.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const server = createMCPServer({
106
+ * name: 'my-app',
107
+ * version: '1.0.0',
108
+ * tools: { weather: weatherTool, search: searchTool },
109
+ * });
110
+ *
111
+ * // For stdio transport (Claude Desktop, etc.)
112
+ * server.start();
113
+ * ```
114
+ */
115
+ declare function createMCPServer(config: MCPServerConfig): MCPServer;
116
+
117
+ /**
118
+ * Lightweight Zod-to-JSON-Schema converter.
119
+ * Handles common Zod types without requiring zod-to-json-schema dependency.
120
+ */
121
+
122
+ interface JsonSchema {
123
+ type?: string;
124
+ properties?: Record<string, JsonSchema>;
125
+ required?: string[];
126
+ items?: JsonSchema;
127
+ enum?: unknown[];
128
+ description?: string;
129
+ default?: unknown;
130
+ minimum?: number;
131
+ maximum?: number;
132
+ minLength?: number;
133
+ maxLength?: number;
134
+ pattern?: string;
135
+ format?: string;
136
+ anyOf?: JsonSchema[];
137
+ oneOf?: JsonSchema[];
138
+ nullable?: boolean;
139
+ additionalProperties?: boolean | JsonSchema;
140
+ [key: string]: unknown;
141
+ }
142
+ declare function zodToJsonSchema(schema: z.ZodType): JsonSchema;
143
+
144
+ export { MCPServer, type MCPServerConfig, createMCPServer, zodToJsonSchema };
@@ -0,0 +1,144 @@
1
+ import { T as Tool, c as ToolContext } from '../tool-Ca2x-VNK.js';
2
+ import { z } from 'zod';
3
+ import 'react';
4
+
5
+ /**
6
+ * MCP (Model Context Protocol) Server for Better UI
7
+ *
8
+ * Exposes registered Better UI tools as MCP tools, allowing any MCP-compatible
9
+ * client (Claude Desktop, Cursor, VS Code, etc.) to discover and call them.
10
+ *
11
+ * Protocol: JSON-RPC 2.0 over stdio (newline-delimited JSON)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { createMCPServer } from '@lantos1618/better-ui/mcp';
16
+ * import { weatherTool, searchTool } from './tools';
17
+ *
18
+ * const server = createMCPServer({
19
+ * name: 'my-tools',
20
+ * version: '1.0.0',
21
+ * tools: { weather: weatherTool, search: searchTool },
22
+ * });
23
+ *
24
+ * server.start(); // Listens on stdin/stdout
25
+ * ```
26
+ */
27
+
28
+ interface MCPServerConfig {
29
+ /** Server name exposed to MCP clients */
30
+ name: string;
31
+ /** Server version */
32
+ version: string;
33
+ /** Tool registry — keys are tool names */
34
+ tools: Record<string, Tool>;
35
+ /** Optional context passed to every tool execution */
36
+ context?: Partial<ToolContext>;
37
+ /** Called when the server starts */
38
+ onStart?: () => void;
39
+ /** Called on errors */
40
+ onError?: (error: Error) => void;
41
+ }
42
+ interface JsonRpcRequest {
43
+ jsonrpc: '2.0';
44
+ id?: string | number | null;
45
+ method: string;
46
+ params?: Record<string, unknown>;
47
+ }
48
+ interface JsonRpcResponse {
49
+ jsonrpc: '2.0';
50
+ id: string | number | null;
51
+ result?: unknown;
52
+ error?: {
53
+ code: number;
54
+ message: string;
55
+ data?: unknown;
56
+ };
57
+ }
58
+ interface MCPToolSchema {
59
+ name: string;
60
+ description?: string;
61
+ inputSchema: Record<string, unknown>;
62
+ }
63
+ declare class MCPServer {
64
+ private config;
65
+ private initialized;
66
+ private running;
67
+ constructor(config: MCPServerConfig);
68
+ /** Start listening on stdin for JSON-RPC messages */
69
+ start(): void;
70
+ /** Stop the server */
71
+ stop(): void;
72
+ /** Handle a single JSON-RPC message. Returns a response or null for notifications. */
73
+ handleMessage(message: JsonRpcRequest): Promise<JsonRpcResponse | null>;
74
+ /** Get all tools as MCP tool schemas */
75
+ listTools(): MCPToolSchema[];
76
+ /** Execute a tool by name */
77
+ callTool(name: string, args: unknown): Promise<{
78
+ content: Array<{
79
+ type: string;
80
+ text: string;
81
+ }>;
82
+ }>;
83
+ private handleLine;
84
+ private handleInitialize;
85
+ private handleToolsList;
86
+ private handleToolsCall;
87
+ /**
88
+ * Create a Web Request handler for HTTP-based MCP transport.
89
+ * Compatible with Next.js route handlers, Deno, Bun, Cloudflare Workers, etc.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // Next.js route: app/api/mcp/route.ts
94
+ * import { server } from '@/lib/mcp';
95
+ * export const POST = server.httpHandler();
96
+ * ```
97
+ */
98
+ httpHandler(): (req: Request) => Promise<Response>;
99
+ }
100
+ /**
101
+ * Create an MCP server from a Better UI tool registry.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const server = createMCPServer({
106
+ * name: 'my-app',
107
+ * version: '1.0.0',
108
+ * tools: { weather: weatherTool, search: searchTool },
109
+ * });
110
+ *
111
+ * // For stdio transport (Claude Desktop, etc.)
112
+ * server.start();
113
+ * ```
114
+ */
115
+ declare function createMCPServer(config: MCPServerConfig): MCPServer;
116
+
117
+ /**
118
+ * Lightweight Zod-to-JSON-Schema converter.
119
+ * Handles common Zod types without requiring zod-to-json-schema dependency.
120
+ */
121
+
122
+ interface JsonSchema {
123
+ type?: string;
124
+ properties?: Record<string, JsonSchema>;
125
+ required?: string[];
126
+ items?: JsonSchema;
127
+ enum?: unknown[];
128
+ description?: string;
129
+ default?: unknown;
130
+ minimum?: number;
131
+ maximum?: number;
132
+ minLength?: number;
133
+ maxLength?: number;
134
+ pattern?: string;
135
+ format?: string;
136
+ anyOf?: JsonSchema[];
137
+ oneOf?: JsonSchema[];
138
+ nullable?: boolean;
139
+ additionalProperties?: boolean | JsonSchema;
140
+ [key: string]: unknown;
141
+ }
142
+ declare function zodToJsonSchema(schema: z.ZodType): JsonSchema;
143
+
144
+ export { MCPServer, type MCPServerConfig, createMCPServer, zodToJsonSchema };
@@ -0,0 +1,413 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/mcp/index.ts
21
+ var mcp_exports = {};
22
+ __export(mcp_exports, {
23
+ MCPServer: () => MCPServer,
24
+ createMCPServer: () => createMCPServer,
25
+ zodToJsonSchema: () => zodToJsonSchema
26
+ });
27
+ module.exports = __toCommonJS(mcp_exports);
28
+
29
+ // src/mcp/schema.ts
30
+ function zodToJsonSchema(schema) {
31
+ return convert(schema);
32
+ }
33
+ function convert(schema) {
34
+ const def = schema._def;
35
+ const typeName = def?.typeName;
36
+ switch (typeName) {
37
+ case "ZodString":
38
+ return convertString(def);
39
+ case "ZodNumber":
40
+ return convertNumber(def);
41
+ case "ZodBoolean":
42
+ return { type: "boolean" };
43
+ case "ZodNull":
44
+ return { type: "null" };
45
+ case "ZodLiteral":
46
+ return { enum: [def.value] };
47
+ case "ZodEnum":
48
+ return { type: "string", enum: def.values };
49
+ case "ZodNativeEnum":
50
+ return { enum: Object.values(def.values) };
51
+ case "ZodObject":
52
+ return convertObject(def);
53
+ case "ZodArray":
54
+ return convertArray(def);
55
+ case "ZodOptional":
56
+ return convert(def.innerType);
57
+ case "ZodNullable": {
58
+ const inner = convert(def.innerType);
59
+ return { anyOf: [inner, { type: "null" }] };
60
+ }
61
+ case "ZodDefault":
62
+ return { ...convert(def.innerType), default: def.defaultValue() };
63
+ case "ZodUnion":
64
+ return { anyOf: def.options.map((o) => convert(o)) };
65
+ case "ZodDiscriminatedUnion":
66
+ return { oneOf: [...def.options.values()].map((o) => convert(o)) };
67
+ case "ZodRecord":
68
+ return {
69
+ type: "object",
70
+ additionalProperties: convert(def.valueType)
71
+ };
72
+ case "ZodTuple": {
73
+ const items = def.items.map((item) => convert(item));
74
+ return { type: "array", items: items.length === 1 ? items[0] : void 0, prefixItems: items };
75
+ }
76
+ case "ZodEffects":
77
+ return convert(def.schema);
78
+ case "ZodPipeline":
79
+ return convert(def.in);
80
+ case "ZodLazy":
81
+ return convert(def.getter());
82
+ case "ZodAny":
83
+ return {};
84
+ case "ZodUnknown":
85
+ return {};
86
+ default:
87
+ return {};
88
+ }
89
+ }
90
+ function convertString(def) {
91
+ const schema = { type: "string" };
92
+ if (def.checks) {
93
+ for (const check of def.checks) {
94
+ switch (check.kind) {
95
+ case "min":
96
+ schema.minLength = check.value;
97
+ break;
98
+ case "max":
99
+ schema.maxLength = check.value;
100
+ break;
101
+ case "email":
102
+ schema.format = "email";
103
+ break;
104
+ case "url":
105
+ schema.format = "uri";
106
+ break;
107
+ case "uuid":
108
+ schema.format = "uuid";
109
+ break;
110
+ case "regex":
111
+ schema.pattern = check.regex.source;
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ if (def.description) schema.description = def.description;
117
+ return schema;
118
+ }
119
+ function convertNumber(def) {
120
+ const schema = { type: "number" };
121
+ if (def.checks) {
122
+ for (const check of def.checks) {
123
+ switch (check.kind) {
124
+ case "min":
125
+ schema.minimum = check.value;
126
+ if (check.inclusive === false) schema.exclusiveMinimum = check.value;
127
+ break;
128
+ case "max":
129
+ schema.maximum = check.value;
130
+ if (check.inclusive === false) schema.exclusiveMaximum = check.value;
131
+ break;
132
+ case "int":
133
+ schema.type = "integer";
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ if (def.description) schema.description = def.description;
139
+ return schema;
140
+ }
141
+ function convertObject(def) {
142
+ const shape = def.shape();
143
+ const properties = {};
144
+ const required = [];
145
+ for (const [key, value] of Object.entries(shape)) {
146
+ properties[key] = convert(value);
147
+ const fieldDef = value._def;
148
+ const isOptional = fieldDef?.typeName === "ZodOptional" || fieldDef?.typeName === "ZodDefault";
149
+ if (!isOptional) {
150
+ required.push(key);
151
+ }
152
+ }
153
+ const schema = { type: "object", properties };
154
+ if (required.length > 0) schema.required = required;
155
+ if (def.description) schema.description = def.description;
156
+ return schema;
157
+ }
158
+ function convertArray(def) {
159
+ const schema = {
160
+ type: "array",
161
+ items: convert(def.type)
162
+ };
163
+ if (def.minLength) schema.minItems = def.minLength.value;
164
+ if (def.maxLength) schema.maxItems = def.maxLength.value;
165
+ if (def.description) schema.description = def.description;
166
+ return schema;
167
+ }
168
+
169
+ // src/mcp/server.ts
170
+ var PARSE_ERROR = -32700;
171
+ var INVALID_REQUEST = -32600;
172
+ var METHOD_NOT_FOUND = -32601;
173
+ var INVALID_PARAMS = -32602;
174
+ var INTERNAL_ERROR = -32603;
175
+ var MCPServer = class {
176
+ constructor(config) {
177
+ this.initialized = false;
178
+ this.running = false;
179
+ this.config = config;
180
+ }
181
+ /** Start listening on stdin for JSON-RPC messages */
182
+ start() {
183
+ if (this.running) return;
184
+ this.running = true;
185
+ const stdin = process.stdin;
186
+ const stdout = process.stdout;
187
+ stdin.setEncoding("utf-8");
188
+ let buffer = "";
189
+ stdin.on("data", (chunk) => {
190
+ buffer += chunk;
191
+ let newlineIdx;
192
+ while ((newlineIdx = buffer.indexOf("\n")) !== -1) {
193
+ const line = buffer.slice(0, newlineIdx).trim();
194
+ buffer = buffer.slice(newlineIdx + 1);
195
+ if (!line) continue;
196
+ this.handleLine(line).then((response) => {
197
+ if (response) {
198
+ stdout.write(JSON.stringify(response) + "\n");
199
+ }
200
+ }).catch((err) => {
201
+ const errorResponse = {
202
+ jsonrpc: "2.0",
203
+ id: null,
204
+ error: { code: INTERNAL_ERROR, message: err.message }
205
+ };
206
+ stdout.write(JSON.stringify(errorResponse) + "\n");
207
+ this.config.onError?.(err instanceof Error ? err : new Error(String(err)));
208
+ });
209
+ }
210
+ });
211
+ stdin.on("end", () => {
212
+ this.running = false;
213
+ });
214
+ this.config.onStart?.();
215
+ }
216
+ /** Stop the server */
217
+ stop() {
218
+ this.running = false;
219
+ }
220
+ /** Handle a single JSON-RPC message. Returns a response or null for notifications. */
221
+ async handleMessage(message) {
222
+ if (message.id === void 0 || message.id === null) {
223
+ if (message.method === "notifications/initialized") {
224
+ }
225
+ return null;
226
+ }
227
+ switch (message.method) {
228
+ case "initialize":
229
+ return this.handleInitialize(message);
230
+ case "tools/list":
231
+ return this.handleToolsList(message);
232
+ case "tools/call":
233
+ return this.handleToolsCall(message);
234
+ case "ping":
235
+ return { jsonrpc: "2.0", id: message.id, result: {} };
236
+ default:
237
+ return {
238
+ jsonrpc: "2.0",
239
+ id: message.id,
240
+ error: { code: METHOD_NOT_FOUND, message: `Method not found: ${message.method}` }
241
+ };
242
+ }
243
+ }
244
+ /** Get all tools as MCP tool schemas */
245
+ listTools() {
246
+ return Object.values(this.config.tools).map((tool) => ({
247
+ name: tool.name,
248
+ description: tool.description || tool.name,
249
+ inputSchema: zodToJsonSchema(tool.inputSchema)
250
+ }));
251
+ }
252
+ /** Execute a tool by name */
253
+ async callTool(name, args) {
254
+ if (!Object.prototype.hasOwnProperty.call(this.config.tools, name)) {
255
+ throw new McpError(INVALID_PARAMS, `Unknown tool: ${name}`);
256
+ }
257
+ const tool = this.config.tools[name];
258
+ try {
259
+ const result = await tool.run(args, {
260
+ isServer: true,
261
+ ...this.config.context
262
+ });
263
+ const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
264
+ return { content: [{ type: "text", text }] };
265
+ } catch (error) {
266
+ if (error instanceof Error && error.name === "ZodError") {
267
+ throw new McpError(INVALID_PARAMS, `Invalid input: ${error.message}`);
268
+ }
269
+ throw error;
270
+ }
271
+ }
272
+ // ─── Private ─────────────────────────────────────────────────────────────
273
+ async handleLine(line) {
274
+ let message;
275
+ try {
276
+ message = JSON.parse(line);
277
+ } catch {
278
+ return {
279
+ jsonrpc: "2.0",
280
+ id: null,
281
+ error: { code: PARSE_ERROR, message: "Parse error" }
282
+ };
283
+ }
284
+ if (!message.jsonrpc || message.jsonrpc !== "2.0") {
285
+ return {
286
+ jsonrpc: "2.0",
287
+ id: message.id ?? null,
288
+ error: { code: INVALID_REQUEST, message: "Invalid JSON-RPC version" }
289
+ };
290
+ }
291
+ return this.handleMessage(message);
292
+ }
293
+ handleInitialize(message) {
294
+ this.initialized = true;
295
+ return {
296
+ jsonrpc: "2.0",
297
+ id: message.id,
298
+ result: {
299
+ protocolVersion: "2024-11-05",
300
+ capabilities: {
301
+ tools: {}
302
+ },
303
+ serverInfo: {
304
+ name: this.config.name,
305
+ version: this.config.version
306
+ }
307
+ }
308
+ };
309
+ }
310
+ handleToolsList(message) {
311
+ return {
312
+ jsonrpc: "2.0",
313
+ id: message.id,
314
+ result: {
315
+ tools: this.listTools()
316
+ }
317
+ };
318
+ }
319
+ async handleToolsCall(message) {
320
+ const params = message.params;
321
+ const toolName = params?.name;
322
+ const args = params?.arguments ?? {};
323
+ if (!toolName) {
324
+ return {
325
+ jsonrpc: "2.0",
326
+ id: message.id,
327
+ error: { code: INVALID_PARAMS, message: "Missing tool name" }
328
+ };
329
+ }
330
+ try {
331
+ const result = await this.callTool(toolName, args);
332
+ return {
333
+ jsonrpc: "2.0",
334
+ id: message.id,
335
+ result
336
+ };
337
+ } catch (error) {
338
+ if (error instanceof McpError) {
339
+ return {
340
+ jsonrpc: "2.0",
341
+ id: message.id,
342
+ error: { code: error.code, message: error.message }
343
+ };
344
+ }
345
+ return {
346
+ jsonrpc: "2.0",
347
+ id: message.id,
348
+ result: {
349
+ content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }],
350
+ isError: true
351
+ }
352
+ };
353
+ }
354
+ }
355
+ /**
356
+ * Create a Web Request handler for HTTP-based MCP transport.
357
+ * Compatible with Next.js route handlers, Deno, Bun, Cloudflare Workers, etc.
358
+ *
359
+ * @example
360
+ * ```typescript
361
+ * // Next.js route: app/api/mcp/route.ts
362
+ * import { server } from '@/lib/mcp';
363
+ * export const POST = server.httpHandler();
364
+ * ```
365
+ */
366
+ httpHandler() {
367
+ return async (req) => {
368
+ const contentType = req.headers.get("content-type") || "";
369
+ if (!contentType.includes("application/json")) {
370
+ return Response.json(
371
+ { jsonrpc: "2.0", id: null, error: { code: PARSE_ERROR, message: "Content-Type must be application/json" } },
372
+ { status: 400 }
373
+ );
374
+ }
375
+ let message;
376
+ try {
377
+ message = await req.json();
378
+ } catch {
379
+ return Response.json(
380
+ { jsonrpc: "2.0", id: null, error: { code: PARSE_ERROR, message: "Parse error" } },
381
+ { status: 400 }
382
+ );
383
+ }
384
+ if (!message.jsonrpc || message.jsonrpc !== "2.0") {
385
+ return Response.json(
386
+ { jsonrpc: "2.0", id: message.id ?? null, error: { code: INVALID_REQUEST, message: "Invalid JSON-RPC version" } },
387
+ { status: 400 }
388
+ );
389
+ }
390
+ const response = await this.handleMessage(message);
391
+ if (!response) {
392
+ return new Response(null, { status: 204 });
393
+ }
394
+ return Response.json(response);
395
+ };
396
+ }
397
+ };
398
+ var McpError = class extends Error {
399
+ constructor(code, message) {
400
+ super(message);
401
+ this.code = code;
402
+ this.name = "McpError";
403
+ }
404
+ };
405
+ function createMCPServer(config) {
406
+ return new MCPServer(config);
407
+ }
408
+ // Annotate the CommonJS export names for ESM import in node:
409
+ 0 && (module.exports = {
410
+ MCPServer,
411
+ createMCPServer,
412
+ zodToJsonSchema
413
+ });