29 lines
869 B
TypeScript
29 lines
869 B
TypeScript
import z from "zod";
|
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
import { server } from "../server";
|
|
|
|
server.registerTool({
|
|
title: "list_tools",
|
|
config: {
|
|
description: "Return the authoritative current list of available local tools with their schemas.",
|
|
inputSchema: {},
|
|
},
|
|
handler: async () => ({
|
|
content: [{
|
|
type: "text",
|
|
text: JSON.stringify(
|
|
Object.values(server.tools)
|
|
.map((tool) => ({
|
|
...tool,
|
|
config: {
|
|
...tool.config,
|
|
inputSchema: zodToJsonSchema(z.object(tool.config.inputSchema ?? {}), { target: "jsonSchema7" }),
|
|
}
|
|
})),
|
|
null,
|
|
2,
|
|
)
|
|
}],
|
|
}),
|
|
});
|