import { z } from 'zod'; import { JsonSchema7Type } from 'zod-to-json-schema'; export interface ToolDefinition { name: string; description: string; inputSchema: JsonSchema7Type & { $schema?: string | undefined; definitions?: { [key: string]: JsonSchema7Type; } | undefined; }; } /** * Interface for MCP tools. * @template TInput - The type of input the tool accepts * @template TOutput - The type of output the tool produces */ export interface Tool { /** * Gets the name of the tool. * @returns The tool name. */ getName(): string; /** * Gets the tool definition for MCP. * @returns The tool definition. */ getToolDefinition(): ToolDefinition; /** * Executes the tool. * @param args The tool arguments. * @returns The tool result. */ execute(args: unknown): Promise; } /** * Base class for MCP tools. */ export declare abstract class BaseTool implements Tool { /** * Gets the name of the tool. * @returns The tool name. */ getName(): string; /** * Gets the tool definition for MCP. * @returns The tool definition. */ getToolDefinition(): ToolDefinition; /** * Gets the name of the tool. * @returns The tool name. */ protected abstract getToolName(): string; /** * Gets the description of the tool. * @returns The tool description. */ protected abstract getToolDescription(): string; /** * Gets the input schema for the tool. * @returns The input schema. */ protected abstract getInputSchema(): z.ZodType; /** * Gets the output schema for the tool. * @returns The output schema, or undefined if not needed. */ protected getOutputSchema(): z.ZodType | undefined; /** * Validates the input arguments against the input schema. * @param args The arguments to validate. * @returns The validated arguments. * @throws If the arguments are invalid. */ protected validateInput(args: unknown): TInput; /** * Validates the output result against the output schema. * @param result The result to validate. * @returns The validated result. * @throws If the result is invalid. */ protected validateOutput(result: TOutput): TOutput; /** * Executes the tool. * @param args The tool arguments. * @returns The tool result. */ execute(args: unknown): Promise; /** * Implements the tool execution logic. * @param args The validated tool arguments. * @returns The tool result. */ protected abstract executeImpl(args: TInput): Promise; }