MCP-Web Tools API
BaseTool<TInput, TOutput>
Class — packages/tools/src/base.ts
Abstract base class for creating reusable MCP tools.
Extend this class to create tools that can be shared across projects. Subclasses must implement all abstract properties: name, description, inputSchema, outputSchema, and handler.
Accessors:
ts
get name(): stringUnique name for the tool.
ts
get description(): stringDescription of what the tool does (shown to AI).
ts
get inputSchema(): TInput | undefinedZod schema for validating input parameters.
ts
get outputSchema(): TOutputZod schema for validating output values.
ts
get handler(): (params: z.infer<TInput>) => z.infer<TOutput> | Promise<z.infer<TOutput>>Function that executes the tool logic.
ts
get definition(): ToolDefinitionReturns the tool definition for registration with MCPWeb.