@neon/tools 1.0.0 → 1.1.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/README.md +19 -0
- package/dist/generated/zod.gen.d.ts.map +1 -1
- package/dist/generated/zod.gen.js +1119 -1119
- package/dist/lib/ergonomic/bind.d.ts.map +1 -1
- package/dist/lib/ergonomic/bind.js +1 -1
- package/dist/lib/ergonomic/catalog.js +2 -2
- package/dist/lib/ergonomic/composed.js +2 -2
- package/dist/lib/mcp-json-schema.d.ts +15 -0
- package/dist/lib/mcp-json-schema.d.ts.map +1 -0
- package/dist/lib/mcp-json-schema.js +31 -0
- package/dist/lib/mcp-register.d.ts +14 -0
- package/dist/lib/mcp-register.d.ts.map +1 -0
- package/dist/lib/mcp-register.js +61 -0
- package/dist/mcp-v1.d.ts +4 -2
- package/dist/mcp-v1.d.ts.map +1 -1
- package/dist/mcp-v1.js +6 -1
- package/dist/mcp.d.ts +5 -11
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +4 -56
- package/dist/operations.gen.js +332 -332
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../../src/lib/ergonomic/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,SAAS,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EACN,KAAK,eAAe,EACpB,kBAAkB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,oBAAoB,EAEzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACX,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,iBAAi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AI,EAAE,iBAAiB,GAAG;IACzB,EAAE,EAAE,EAAE,CAAC;IACP,SAAS,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;IACtB,GAAG,EAAE,CACJ,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EACtB,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,EAC5B,MAAM,CAAC,EAAE,WAAW,KAChB,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB,GACC,QAAQ,CACV,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EACrD,WAAW,CAAC,EAAE,CAAC,EACf,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CACzB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { operationFactories } from "../../operations.gen.js";
|
|
|
4
4
|
import { NeonError, createNeonClient } from "@neon/sdk";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
//#region src/lib/ergonomic/bind.ts
|
|
7
|
-
const ALL_PAGES = "
|
|
7
|
+
const ALL_PAGES = " Returns every page. Pass limit to cap how many.";
|
|
8
8
|
const inertClient = createNeonClient({ apiKey: "unused" }).client;
|
|
9
9
|
const snakeSegment = (segment) => segment.replace(/[A-Z]/g, (character) => `_${character.toLowerCase()}`);
|
|
10
10
|
const publishedId = (id) => {
|
|
@@ -7,7 +7,7 @@ const logReadAnnotations = {
|
|
|
7
7
|
readOnlyHint: true,
|
|
8
8
|
destructiveHint: false,
|
|
9
9
|
idempotentHint: true,
|
|
10
|
-
openWorldHint:
|
|
10
|
+
openWorldHint: false
|
|
11
11
|
};
|
|
12
12
|
const toolFactories = {
|
|
13
13
|
"projects.list": (options) => fromGenerated(options, {
|
|
@@ -681,7 +681,7 @@ const toolFactories = {
|
|
|
681
681
|
inputSchema: z.strictObject({}),
|
|
682
682
|
annotations: {
|
|
683
683
|
readOnlyHint: true,
|
|
684
|
-
openWorldHint:
|
|
684
|
+
openWorldHint: false
|
|
685
685
|
},
|
|
686
686
|
requiresApproval: false,
|
|
687
687
|
metadata: {
|
|
@@ -5,11 +5,11 @@ import * as z from "zod";
|
|
|
5
5
|
const writeAnnotations = {
|
|
6
6
|
readOnlyHint: false,
|
|
7
7
|
destructiveHint: true,
|
|
8
|
-
openWorldHint:
|
|
8
|
+
openWorldHint: false
|
|
9
9
|
};
|
|
10
10
|
const readAnnotations = {
|
|
11
11
|
readOnlyHint: true,
|
|
12
|
-
openWorldHint:
|
|
12
|
+
openWorldHint: false
|
|
13
13
|
};
|
|
14
14
|
const pooledField = z.boolean().describe("Return a pooled connection string. Default true. Set false for a direct connection.").optional();
|
|
15
15
|
const branchCreateFields = zBranchCreateRequest.shape.branch.unwrap().shape;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const compactJsonSchema: (node: unknown) => unknown;
|
|
3
|
+
export interface McpStandardSchema {
|
|
4
|
+
"~standard": {
|
|
5
|
+
version: number;
|
|
6
|
+
vendor: string;
|
|
7
|
+
jsonSchema: {
|
|
8
|
+
input: () => Record<string, unknown>;
|
|
9
|
+
output: () => Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
validate: (value: unknown) => unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const toMcpInputSchema: (schema: z.ZodType) => McpStandardSchema;
|
|
15
|
+
//# sourceMappingURL=mcp-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-json-schema.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,OAOjD,CAAC;AAMF,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE;YACX,KAAK,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACrC,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACtC,CAAC;QACF,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KACtC,CAAC;CACF;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,iBAiCpD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
//#region src/lib/mcp-json-schema.ts
|
|
3
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
const compactJsonSchema = (node) => {
|
|
5
|
+
if (!isPlainObject(node)) return node;
|
|
6
|
+
const rest = { ...node };
|
|
7
|
+
delete rest.$schema;
|
|
8
|
+
return rest;
|
|
9
|
+
};
|
|
10
|
+
const isStandardValidate = (value) => typeof value === "function";
|
|
11
|
+
const toMcpInputSchema = (schema) => {
|
|
12
|
+
const json = compactJsonSchema(z.toJSONSchema(schema, { io: "input" }));
|
|
13
|
+
if (!isPlainObject(json)) throw new TypeError("MCP tool input schemas must be JSON Schema objects");
|
|
14
|
+
const standard = "~standard" in schema && isPlainObject(schema["~standard"]) ? schema["~standard"] : void 0;
|
|
15
|
+
const validate = standard === void 0 ? void 0 : standard.validate;
|
|
16
|
+
return { "~standard": {
|
|
17
|
+
version: 1,
|
|
18
|
+
vendor: "neon",
|
|
19
|
+
jsonSchema: {
|
|
20
|
+
input: () => json,
|
|
21
|
+
output: () => json
|
|
22
|
+
},
|
|
23
|
+
validate: (value) => {
|
|
24
|
+
if (isStandardValidate(validate)) return validate(value);
|
|
25
|
+
const parsed = schema.safeParse(value);
|
|
26
|
+
return parsed.success ? { value: parsed.data } : { issues: parsed.error.issues };
|
|
27
|
+
}
|
|
28
|
+
} };
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { compactJsonSchema, toMcpInputSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NeonTool } from "./operation.js";
|
|
2
|
+
export interface McpToolResult {
|
|
3
|
+
content: Array<{
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
}>;
|
|
7
|
+
structuredContent: Record<string, unknown>;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface McpToolServer {
|
|
11
|
+
registerTool: object;
|
|
12
|
+
}
|
|
13
|
+
export declare const registerNeonToolsWithSchema: (server: McpToolServer, tools: Readonly<Record<string, NeonTool>>, inputSchema: (tool: NeonTool) => unknown) => void;
|
|
14
|
+
//# sourceMappingURL=mcp-register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-register.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,MAAM,CAAC;CACrB;AA0FD,eAAO,MAAM,2BAA2B,GACvC,QAAQ,aAAa,EACrB,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EACzC,aAAa,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,KACtC,IAkBF,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/lib/mcp-register.ts
|
|
2
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
3
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
4
|
+
const authInfoFrom = (context) => {
|
|
5
|
+
if (!isRecord(context)) return;
|
|
6
|
+
if (isRecord(context.http) && "authInfo" in context.http) return context.http.authInfo;
|
|
7
|
+
if ("authInfo" in context) return context.authInfo;
|
|
8
|
+
};
|
|
9
|
+
const bearerCredentialFromMcpContext = (context) => {
|
|
10
|
+
const authInfo = authInfoFrom(context);
|
|
11
|
+
if (authInfo === void 0) return;
|
|
12
|
+
if (!isRecord(authInfo) || typeof authInfo.token !== "string" || authInfo.token.length === 0) throw new TypeError("A Neon API key or OAuth access token is required");
|
|
13
|
+
return authInfo.token;
|
|
14
|
+
};
|
|
15
|
+
const signalFrom = (context) => {
|
|
16
|
+
if (!isRecord(context)) return;
|
|
17
|
+
if (context.signal instanceof AbortSignal) return context.signal;
|
|
18
|
+
if (isRecord(context.mcpReq) && context.mcpReq.signal instanceof AbortSignal) return context.mcpReq.signal;
|
|
19
|
+
};
|
|
20
|
+
const createToolHandler = (tool) => async (input, context) => {
|
|
21
|
+
try {
|
|
22
|
+
const apiKey = bearerCredentialFromMcpContext(context);
|
|
23
|
+
const structuredContent = { data: (await tool.execute(input, {
|
|
24
|
+
signal: signalFrom(context),
|
|
25
|
+
...apiKey === void 0 ? {} : { apiKey }
|
|
26
|
+
})).data };
|
|
27
|
+
return {
|
|
28
|
+
content: [{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: JSON.stringify(structuredContent)
|
|
31
|
+
}],
|
|
32
|
+
structuredContent
|
|
33
|
+
};
|
|
34
|
+
} catch (error) {
|
|
35
|
+
const structuredContent = { error: { message: errorMessage(error) } };
|
|
36
|
+
return {
|
|
37
|
+
content: [{
|
|
38
|
+
type: "text",
|
|
39
|
+
text: JSON.stringify(structuredContent)
|
|
40
|
+
}],
|
|
41
|
+
structuredContent,
|
|
42
|
+
isError: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const registerNeonToolsWithSchema = (server, tools, inputSchema) => {
|
|
47
|
+
if (typeof server.registerTool !== "function") throw new TypeError("Expected an MCP server with registerTool().");
|
|
48
|
+
for (const tool of Object.values(tools)) Reflect.apply(server.registerTool, server, [
|
|
49
|
+
tool.id,
|
|
50
|
+
{
|
|
51
|
+
title: tool.title,
|
|
52
|
+
description: tool.description,
|
|
53
|
+
inputSchema: inputSchema(tool),
|
|
54
|
+
annotations: tool.annotations,
|
|
55
|
+
_meta: { "neon/requiresApproval": tool.requiresApproval }
|
|
56
|
+
},
|
|
57
|
+
createToolHandler(tool)
|
|
58
|
+
]);
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { registerNeonToolsWithSchema };
|
package/dist/mcp-v1.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type McpToolResult, type McpToolServer } from "./lib/mcp-register.js";
|
|
2
|
+
import type { NeonTool } from "./lib/operation.js";
|
|
3
|
+
export type { McpToolResult, McpToolServer };
|
|
4
|
+
export declare const registerNeonTools: (server: McpToolServer, tools: Readonly<Record<string, NeonTool>>) => void;
|
|
3
5
|
//# sourceMappingURL=mcp-v1.d.ts.map
|
package/dist/mcp-v1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-v1.d.ts","sourceRoot":"","sources":["../src/mcp-v1.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"mcp-v1.d.ts","sourceRoot":"","sources":["../src/mcp-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAE7C,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,KACvC,IAEF,CAAC"}
|
package/dist/mcp-v1.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { registerNeonToolsWithSchema } from "./lib/mcp-register.js";
|
|
2
|
+
//#region src/mcp-v1.ts
|
|
3
|
+
const registerNeonTools = (server, tools) => {
|
|
4
|
+
registerNeonToolsWithSchema(server, tools, (tool) => tool.inputSchema);
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
2
7
|
export { registerNeonTools };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import { compactJsonSchema, toMcpInputSchema } from "./lib/mcp-json-schema.js";
|
|
2
|
+
import { type McpToolResult, type McpToolServer } from "./lib/mcp-register.js";
|
|
1
3
|
import type { NeonTool } from "./lib/operation.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
text: string;
|
|
6
|
-
}>;
|
|
7
|
-
structuredContent: Record<string, unknown>;
|
|
8
|
-
isError?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface McpToolServer {
|
|
11
|
-
registerTool: object;
|
|
12
|
-
}
|
|
4
|
+
export type { McpStandardSchema } from "./lib/mcp-json-schema.js";
|
|
5
|
+
export type { McpToolResult, McpToolServer };
|
|
6
|
+
export { compactJsonSchema, toMcpInputSchema };
|
|
13
7
|
export declare const registerNeonTools: (server: McpToolServer, tools: Readonly<Record<string, NeonTool>>) => void;
|
|
14
8
|
//# sourceMappingURL=mcp.d.ts.map
|
package/dist/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAE/C,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,KACvC,IAIF,CAAC"}
|
package/dist/mcp.js
CHANGED
|
@@ -1,60 +1,8 @@
|
|
|
1
|
+
import { registerNeonToolsWithSchema } from "./lib/mcp-register.js";
|
|
2
|
+
import { compactJsonSchema, toMcpInputSchema } from "./lib/mcp-json-schema.js";
|
|
1
3
|
//#region src/mcp.ts
|
|
2
|
-
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
3
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
4
|
-
const authInfoFrom = (context) => {
|
|
5
|
-
if (!isRecord(context)) return;
|
|
6
|
-
if (isRecord(context.http) && "authInfo" in context.http) return context.http.authInfo;
|
|
7
|
-
if ("authInfo" in context) return context.authInfo;
|
|
8
|
-
};
|
|
9
|
-
const bearerCredentialFromMcpContext = (context) => {
|
|
10
|
-
const authInfo = authInfoFrom(context);
|
|
11
|
-
if (authInfo === void 0) return;
|
|
12
|
-
if (!isRecord(authInfo) || typeof authInfo.token !== "string" || authInfo.token.length === 0) throw new TypeError("A Neon API key or OAuth access token is required");
|
|
13
|
-
return authInfo.token;
|
|
14
|
-
};
|
|
15
|
-
const signalFrom = (context) => {
|
|
16
|
-
if (!isRecord(context)) return;
|
|
17
|
-
if (context.signal instanceof AbortSignal) return context.signal;
|
|
18
|
-
if (isRecord(context.mcpReq) && context.mcpReq.signal instanceof AbortSignal) return context.mcpReq.signal;
|
|
19
|
-
};
|
|
20
4
|
const registerNeonTools = (server, tools) => {
|
|
21
|
-
|
|
22
|
-
for (const tool of Object.values(tools)) Reflect.apply(server.registerTool, server, [
|
|
23
|
-
tool.id,
|
|
24
|
-
{
|
|
25
|
-
title: tool.title,
|
|
26
|
-
description: tool.description,
|
|
27
|
-
inputSchema: tool.inputSchema,
|
|
28
|
-
annotations: tool.annotations,
|
|
29
|
-
_meta: { "neon/requiresApproval": tool.requiresApproval }
|
|
30
|
-
},
|
|
31
|
-
async (input, context) => {
|
|
32
|
-
try {
|
|
33
|
-
const apiKey = bearerCredentialFromMcpContext(context);
|
|
34
|
-
const structuredContent = { data: (await tool.execute(input, {
|
|
35
|
-
signal: signalFrom(context),
|
|
36
|
-
...apiKey === void 0 ? {} : { apiKey }
|
|
37
|
-
})).data };
|
|
38
|
-
return {
|
|
39
|
-
content: [{
|
|
40
|
-
type: "text",
|
|
41
|
-
text: JSON.stringify(structuredContent)
|
|
42
|
-
}],
|
|
43
|
-
structuredContent
|
|
44
|
-
};
|
|
45
|
-
} catch (error) {
|
|
46
|
-
const structuredContent = { error: { message: errorMessage(error) } };
|
|
47
|
-
return {
|
|
48
|
-
content: [{
|
|
49
|
-
type: "text",
|
|
50
|
-
text: JSON.stringify(structuredContent)
|
|
51
|
-
}],
|
|
52
|
-
structuredContent,
|
|
53
|
-
isError: true
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
]);
|
|
5
|
+
registerNeonToolsWithSchema(server, tools, (tool) => toMcpInputSchema(tool.inputSchema));
|
|
58
6
|
};
|
|
59
7
|
//#endregion
|
|
60
|
-
export { registerNeonTools };
|
|
8
|
+
export { compactJsonSchema, registerNeonTools, toMcpInputSchema };
|