@lantos1618/better-ui 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +410 -207
- package/dist/agui/index.d.mts +116 -0
- package/dist/agui/index.d.ts +116 -0
- package/dist/agui/index.js +328 -0
- package/dist/agui/index.mjs +156 -0
- package/dist/auth/index.mjs +1 -1
- package/dist/chunk-CIESM3BP.mjs +33 -0
- package/dist/chunk-XDWHMRBN.mjs +159 -0
- package/dist/components/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mcp/index.d.mts +157 -0
- package/dist/mcp/index.d.ts +157 -0
- package/dist/mcp/index.js +491 -0
- package/dist/mcp/index.mjs +332 -0
- package/dist/persistence/index.mjs +1 -1
- package/dist/react/index.mjs +1 -1
- package/package.json +17 -3
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
package/dist/auth/index.mjs
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
__require,
|
|
30
|
+
__esm,
|
|
31
|
+
__export,
|
|
32
|
+
__toCommonJS
|
|
33
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm,
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CIESM3BP.mjs";
|
|
5
|
+
|
|
6
|
+
// src/mcp/schema.ts
|
|
7
|
+
var schema_exports = {};
|
|
8
|
+
__export(schema_exports, {
|
|
9
|
+
zodToJsonSchema: () => zodToJsonSchema
|
|
10
|
+
});
|
|
11
|
+
function zodToJsonSchema(schema) {
|
|
12
|
+
return convert(schema);
|
|
13
|
+
}
|
|
14
|
+
function convert(schema) {
|
|
15
|
+
const def = schema._def;
|
|
16
|
+
const typeName = def?.typeName;
|
|
17
|
+
switch (typeName) {
|
|
18
|
+
case "ZodString":
|
|
19
|
+
return convertString(def);
|
|
20
|
+
case "ZodNumber":
|
|
21
|
+
return convertNumber(def);
|
|
22
|
+
case "ZodBoolean":
|
|
23
|
+
return { type: "boolean" };
|
|
24
|
+
case "ZodNull":
|
|
25
|
+
return { type: "null" };
|
|
26
|
+
case "ZodLiteral":
|
|
27
|
+
return { enum: [def.value] };
|
|
28
|
+
case "ZodEnum":
|
|
29
|
+
return { type: "string", enum: def.values };
|
|
30
|
+
case "ZodNativeEnum":
|
|
31
|
+
return { enum: Object.values(def.values) };
|
|
32
|
+
case "ZodObject":
|
|
33
|
+
return convertObject(def);
|
|
34
|
+
case "ZodArray":
|
|
35
|
+
return convertArray(def);
|
|
36
|
+
case "ZodOptional":
|
|
37
|
+
return convert(def.innerType);
|
|
38
|
+
case "ZodNullable": {
|
|
39
|
+
const inner = convert(def.innerType);
|
|
40
|
+
return { anyOf: [inner, { type: "null" }] };
|
|
41
|
+
}
|
|
42
|
+
case "ZodDefault":
|
|
43
|
+
return { ...convert(def.innerType), default: def.defaultValue() };
|
|
44
|
+
case "ZodUnion":
|
|
45
|
+
return { anyOf: def.options.map((o) => convert(o)) };
|
|
46
|
+
case "ZodDiscriminatedUnion":
|
|
47
|
+
return { oneOf: [...def.options.values()].map((o) => convert(o)) };
|
|
48
|
+
case "ZodRecord":
|
|
49
|
+
return {
|
|
50
|
+
type: "object",
|
|
51
|
+
additionalProperties: convert(def.valueType)
|
|
52
|
+
};
|
|
53
|
+
case "ZodTuple": {
|
|
54
|
+
const items = def.items.map((item) => convert(item));
|
|
55
|
+
return { type: "array", items: items.length === 1 ? items[0] : void 0, prefixItems: items };
|
|
56
|
+
}
|
|
57
|
+
case "ZodEffects":
|
|
58
|
+
return convert(def.schema);
|
|
59
|
+
case "ZodPipeline":
|
|
60
|
+
return convert(def.in);
|
|
61
|
+
case "ZodLazy":
|
|
62
|
+
return convert(def.getter());
|
|
63
|
+
case "ZodAny":
|
|
64
|
+
return {};
|
|
65
|
+
case "ZodUnknown":
|
|
66
|
+
return {};
|
|
67
|
+
default:
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function convertString(def) {
|
|
72
|
+
const schema = { type: "string" };
|
|
73
|
+
if (def.checks) {
|
|
74
|
+
for (const check of def.checks) {
|
|
75
|
+
switch (check.kind) {
|
|
76
|
+
case "min":
|
|
77
|
+
schema.minLength = check.value;
|
|
78
|
+
break;
|
|
79
|
+
case "max":
|
|
80
|
+
schema.maxLength = check.value;
|
|
81
|
+
break;
|
|
82
|
+
case "email":
|
|
83
|
+
schema.format = "email";
|
|
84
|
+
break;
|
|
85
|
+
case "url":
|
|
86
|
+
schema.format = "uri";
|
|
87
|
+
break;
|
|
88
|
+
case "uuid":
|
|
89
|
+
schema.format = "uuid";
|
|
90
|
+
break;
|
|
91
|
+
case "regex":
|
|
92
|
+
schema.pattern = check.regex.source;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (def.description) schema.description = def.description;
|
|
98
|
+
return schema;
|
|
99
|
+
}
|
|
100
|
+
function convertNumber(def) {
|
|
101
|
+
const schema = { type: "number" };
|
|
102
|
+
if (def.checks) {
|
|
103
|
+
for (const check of def.checks) {
|
|
104
|
+
switch (check.kind) {
|
|
105
|
+
case "min":
|
|
106
|
+
schema.minimum = check.value;
|
|
107
|
+
if (check.inclusive === false) schema.exclusiveMinimum = check.value;
|
|
108
|
+
break;
|
|
109
|
+
case "max":
|
|
110
|
+
schema.maximum = check.value;
|
|
111
|
+
if (check.inclusive === false) schema.exclusiveMaximum = check.value;
|
|
112
|
+
break;
|
|
113
|
+
case "int":
|
|
114
|
+
schema.type = "integer";
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (def.description) schema.description = def.description;
|
|
120
|
+
return schema;
|
|
121
|
+
}
|
|
122
|
+
function convertObject(def) {
|
|
123
|
+
const shape = def.shape();
|
|
124
|
+
const properties = {};
|
|
125
|
+
const required = [];
|
|
126
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
127
|
+
properties[key] = convert(value);
|
|
128
|
+
const fieldDef = value._def;
|
|
129
|
+
const isOptional = fieldDef?.typeName === "ZodOptional" || fieldDef?.typeName === "ZodDefault";
|
|
130
|
+
if (!isOptional) {
|
|
131
|
+
required.push(key);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const schema = { type: "object", properties };
|
|
135
|
+
if (required.length > 0) schema.required = required;
|
|
136
|
+
if (def.description) schema.description = def.description;
|
|
137
|
+
return schema;
|
|
138
|
+
}
|
|
139
|
+
function convertArray(def) {
|
|
140
|
+
const schema = {
|
|
141
|
+
type: "array",
|
|
142
|
+
items: convert(def.type)
|
|
143
|
+
};
|
|
144
|
+
if (def.minLength) schema.minItems = def.minLength.value;
|
|
145
|
+
if (def.maxLength) schema.maxItems = def.maxLength.value;
|
|
146
|
+
if (def.description) schema.description = def.description;
|
|
147
|
+
return schema;
|
|
148
|
+
}
|
|
149
|
+
var init_schema = __esm({
|
|
150
|
+
"src/mcp/schema.ts"() {
|
|
151
|
+
"use strict";
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
zodToJsonSchema,
|
|
157
|
+
schema_exports,
|
|
158
|
+
init_schema
|
|
159
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
* Create a Streamable HTTP handler (MCP spec 2025-03-26).
|
|
101
|
+
* Supports both single JSON-RPC requests and SSE streaming for long-running operations.
|
|
102
|
+
* Compatible with Next.js route handlers, Deno, Bun, Cloudflare Workers.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Next.js route: app/api/mcp/route.ts
|
|
107
|
+
* import { server } from '@/lib/mcp';
|
|
108
|
+
* export const POST = server.streamableHttpHandler();
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
streamableHttpHandler(): (req: Request) => Promise<Response>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create an MCP server from a Better UI tool registry.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const server = createMCPServer({
|
|
119
|
+
* name: 'my-app',
|
|
120
|
+
* version: '1.0.0',
|
|
121
|
+
* tools: { weather: weatherTool, search: searchTool },
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // For stdio transport (Claude Desktop, etc.)
|
|
125
|
+
* server.start();
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function createMCPServer(config: MCPServerConfig): MCPServer;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Lightweight Zod-to-JSON-Schema converter.
|
|
132
|
+
* Handles common Zod types without requiring zod-to-json-schema dependency.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
interface JsonSchema {
|
|
136
|
+
type?: string;
|
|
137
|
+
properties?: Record<string, JsonSchema>;
|
|
138
|
+
required?: string[];
|
|
139
|
+
items?: JsonSchema;
|
|
140
|
+
enum?: unknown[];
|
|
141
|
+
description?: string;
|
|
142
|
+
default?: unknown;
|
|
143
|
+
minimum?: number;
|
|
144
|
+
maximum?: number;
|
|
145
|
+
minLength?: number;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
pattern?: string;
|
|
148
|
+
format?: string;
|
|
149
|
+
anyOf?: JsonSchema[];
|
|
150
|
+
oneOf?: JsonSchema[];
|
|
151
|
+
nullable?: boolean;
|
|
152
|
+
additionalProperties?: boolean | JsonSchema;
|
|
153
|
+
[key: string]: unknown;
|
|
154
|
+
}
|
|
155
|
+
declare function zodToJsonSchema(schema: z.ZodType): JsonSchema;
|
|
156
|
+
|
|
157
|
+
export { MCPServer, type MCPServerConfig, createMCPServer, zodToJsonSchema };
|
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
* Create a Streamable HTTP handler (MCP spec 2025-03-26).
|
|
101
|
+
* Supports both single JSON-RPC requests and SSE streaming for long-running operations.
|
|
102
|
+
* Compatible with Next.js route handlers, Deno, Bun, Cloudflare Workers.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Next.js route: app/api/mcp/route.ts
|
|
107
|
+
* import { server } from '@/lib/mcp';
|
|
108
|
+
* export const POST = server.streamableHttpHandler();
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
streamableHttpHandler(): (req: Request) => Promise<Response>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create an MCP server from a Better UI tool registry.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const server = createMCPServer({
|
|
119
|
+
* name: 'my-app',
|
|
120
|
+
* version: '1.0.0',
|
|
121
|
+
* tools: { weather: weatherTool, search: searchTool },
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // For stdio transport (Claude Desktop, etc.)
|
|
125
|
+
* server.start();
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function createMCPServer(config: MCPServerConfig): MCPServer;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Lightweight Zod-to-JSON-Schema converter.
|
|
132
|
+
* Handles common Zod types without requiring zod-to-json-schema dependency.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
interface JsonSchema {
|
|
136
|
+
type?: string;
|
|
137
|
+
properties?: Record<string, JsonSchema>;
|
|
138
|
+
required?: string[];
|
|
139
|
+
items?: JsonSchema;
|
|
140
|
+
enum?: unknown[];
|
|
141
|
+
description?: string;
|
|
142
|
+
default?: unknown;
|
|
143
|
+
minimum?: number;
|
|
144
|
+
maximum?: number;
|
|
145
|
+
minLength?: number;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
pattern?: string;
|
|
148
|
+
format?: string;
|
|
149
|
+
anyOf?: JsonSchema[];
|
|
150
|
+
oneOf?: JsonSchema[];
|
|
151
|
+
nullable?: boolean;
|
|
152
|
+
additionalProperties?: boolean | JsonSchema;
|
|
153
|
+
[key: string]: unknown;
|
|
154
|
+
}
|
|
155
|
+
declare function zodToJsonSchema(schema: z.ZodType): JsonSchema;
|
|
156
|
+
|
|
157
|
+
export { MCPServer, type MCPServerConfig, createMCPServer, zodToJsonSchema };
|