chore: tool definition without zod (#873)

This commit is contained in:
Yury Semikhatsky
2025-08-12 13:19:25 -07:00
committed by GitHub
parent 53c6b6dcb1
commit 7c4d67b3ae
8 changed files with 77 additions and 77 deletions

View File

@@ -22,6 +22,7 @@ import { packageJSON } from '../package.js';
import { Context } from './context.js';
import { perform } from './perform.js';
import { snapshot } from './snapshot.js';
import { toToolDefinition } from '../tools/tool.js';
import type { FullConfig } from '../config.js';
import type { ServerBackend } from '../mcp/server.js';
@@ -48,13 +49,13 @@ class LoopToolsServerBackend implements ServerBackend {
this._context = await Context.create(this._config);
}
tools(): mcpServer.ToolSchema<any>[] {
return this._tools.map(tool => tool.schema);
tools(): mcpServer.ToolDefinition[] {
return this._tools.map(tool => toToolDefinition(tool.schema));
}
async callTool(schema: mcpServer.ToolSchema<any>, rawArguments: any): Promise<mcpServer.ToolResponse> {
const tool = this._tools.find(tool => tool.schema.name === schema.name)!;
const parsedArguments = schema.inputSchema.parse(rawArguments || {});
async callTool(name: string, rawArguments: any): Promise<mcpServer.ToolResponse> {
const tool = this._tools.find(tool => tool.schema.name === name)!;
const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {});
return await tool.handle(this._context!, parsedArguments);
}