chore: introduce response type (#738)

This commit is contained in:
Pavel Feldman 2025-07-22 16:36:21 -07:00 committed by GitHub
parent c2b98dc70b
commit 601a74305c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 443 additions and 526 deletions

View file

@ -19,6 +19,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, Tool as McpTool } from '
import { zodToJsonSchema } from 'zod-to-json-schema';
import { Context } from './context.js';
import { Response } from './response.js';
import { allTools } from './tools.js';
import { packageJSON } from './package.js';
@ -61,7 +62,9 @@ export function createConnection(config: FullConfig, browserContextFactory: Brow
return errorResult(`Tool "${request.params.name}" not found`);
try {
return await context.run(tool, request.params.arguments);
const response = new Response(context);
await tool.handle(context, tool.schema.inputSchema.parse(request.params.arguments || {}), response);
return await response.serialize();
} catch (error) {
return errorResult(String(error));
}