UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

54 lines 1.85 kB
/** * Schema helper utilities for tool registration * * This module provides utilities for converting between different schema formats * used in tool registration. */ import { z } from "zod"; /** * Convert a Zod object schema to the internal Record<string, z.ZodSchema> format * * @param zodSchema - Zod object schema to convert * @returns Object mapping parameter names to Zod validation schemas * * @example * ```typescript * const schema = z.object({ * name: z.string(), * age: z.number().optional() * }); * const params = convertZodSchemaToParams(schema); * // Returns: { name: z.string(), age: z.number().optional() } * ``` */ export declare function convertZodSchemaToParams(zodSchema: z.ZodObject<any>): Record<string, z.ZodSchema>; /** * Input definition for tool parameters */ export interface InputDefinition { name: string; type: string; required?: boolean; description?: string; } /** * Create input schema for tools * * Converts tool input definitions into Zod validation schemas for runtime validation. * Supports common data types (string, number, boolean, object, array) and optional * parameters. Used internally when registering tools with the MCP server. * * @param inputs - Array of input parameter definitions with name, type, and optional flag * @returns Object mapping parameter names to Zod validation schemas * * @example * ```typescript * const schema = createParamsSchema([ * { name: 'query', type: 'string', required: true, description: 'Search query' }, * { name: 'limit', type: 'number', required: false } * ]) * // Returns: { query: z.string().describe('Search query'), limit: z.number().optional() } * ``` */ export declare function createParamsSchema(inputs: InputDefinition[]): Record<string, z.ZodSchema>; //# sourceMappingURL=schema-helpers.d.ts.map