chore: infer tool params (#241)
Moves the `schema.parse` call to the calling side of the handler, so we don't have to duplicate it everywhere.
This commit is contained in:
parent
9578a5b2af
commit
c80f7cf222
20 changed files with 212 additions and 273 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
||||
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||
|
||||
import { Context } from './context';
|
||||
|
||||
|
|
@ -41,7 +42,13 @@ export function createServerWithTools(options: Options): Server {
|
|||
});
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
return { tools: tools.map(tool => tool.schema) };
|
||||
return {
|
||||
tools: tools.map(tool => ({
|
||||
name: tool.schema.name,
|
||||
description: tool.schema.description,
|
||||
inputSchema: zodToJsonSchema(tool.schema.inputSchema)
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue