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 { Response } from './response.js';
import { SessionLog } from './sessionLog.js';
import { filteredTools } from './tools.js';
import { packageJSON } from './package.js';
import { toToolDefinition } from './tools/tool.js';
import type { Tool } from './tools/tool.js';
import type { BrowserContextFactory } from './browserContextFactory.js';
@@ -65,15 +66,15 @@ export class BrowserServerBackend implements ServerBackend {
});
}
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) {
async callTool(name: string, rawArguments: any) {
const tool = this._tools.find(tool => tool.schema.name === name)!;
const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {});
const context = this._context!;
const parsedArguments = schema.inputSchema.parse(rawArguments || {});
const response = new Response(context, schema.name, parsedArguments);
const tool = this._tools.find(tool => tool.schema.name === schema.name)!;
const response = new Response(context, name, parsedArguments);
context.setRunningTool(true);
try {
await tool.handle(context, parsedArguments, response);