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