chore: tool definition without zod (#873)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user