/** * Functions for extracting tools from an OpenAPI specification */ import { OpenAPIV3 } from 'openapi-types'; import type { JSONSchema7 } from 'json-schema'; import { McpToolDefinition } from '../types/index.js'; /** Default maximum tool name length (Claude Desktop limit). */ export declare const DEFAULT_MAX_TOOL_NAME_LENGTH = 64; /** * Split a tool name into words on `_`/`-` boundaries and camelCase humps, * preserving each word's original casing so it can be rejoined. * * `FDA_get_info_on_conditions` -> ['FDA','get','info','on','conditions'] * `createUserSubscriptionMethod` -> ['create','User','Subscription','Method'] */ export declare function splitNameIntoWords(name: string): string[]; /** * Abbreviate a tool name word-by-word (inspired by ToolUniverse): keep the * first word (category/verb prefix) intact, then for each subsequent word keep * short words (<= 3 chars) as-is and shorten longer words to their first 4 * characters. Words are rejoined with `_`. * * `FDA_get_info_on_conditions_for_doctor_consultation_by_drug_name` * -> `FDA_get_info_on_cond_for_doct_cons_by_drug_name` * * Readability-preserving but NOT length-guaranteed (a name with very many words * can still exceed the limit), so callers must apply a hard backstop. */ export declare function abbreviateToolName(name: string): string; /** * Produce an MCP-compliant tool name within `maxLength` (issue #4). * * Strategy: * 1. If the name already fits, return it unchanged. * 2. Try word-level abbreviation (readable, no hash). If that fits, use it. * 3. Otherwise fall back to deterministic Start…End hash truncation. * * @param name Sanitized candidate tool name * @param maxLength Maximum allowed length * @returns A name guaranteed to be <= maxLength */ export declare function shortenToolName(name: string, maxLength: number): string; /** * Truncate a tool name to `maxLength` when it exceeds the limit. * * Strategy (issue #4): names are truncated "Start…End" style — the head and * the tail are both preserved and the middle is elided with `__` — followed by * a short deterministic hash of the *full* name. This keeps tool names readable * for the model in both common collision shapes (prefix collisions like * `createUserSubscriptionPaymentMethodWith...` where the tail disambiguates, * and suffix collisions like `getUserById`/`getOrderById` where the head does), * while the hash guarantees uniqueness even when both ends match. The hash is * computed over the original name, so output is stable across runs and spec * reordering. * * For very small limits there isn't room for two ends plus a marker plus a * hash, so it falls back to `head_hash`. * * Returns the name unchanged when already within the limit. */ export declare function truncateToolName(name: string, maxLength: number): string; /** * Extracts tool definitions from an OpenAPI document * * @param api OpenAPI document * @returns Array of MCP tool definitions */ /** Smallest tool-name length that still guarantees collision-resolution progress. */ export declare const MIN_TOOL_NAME_LENGTH = 8; export declare function extractToolsFromApi(api: OpenAPIV3.Document, defaultInclude?: boolean, maxToolNameLength?: number): McpToolDefinition[]; /** * Generates input schema and extracts parameter details from an operation * * @param operation OpenAPI operation object * @param pathParameters Optional path-level parameters that apply to all operations in the path * @returns Input schema, parameters, and request body content type */ export declare function generateInputSchemaAndDetails(operation: OpenAPIV3.OperationObject, pathParameters?: (OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject)[]): { inputSchema: JSONSchema7 | boolean; parameters: OpenAPIV3.ParameterObject[]; requestBodyContentType?: string; }; /** * Maps an OpenAPI schema to a JSON Schema with cycle protection. * * @param schema OpenAPI schema object or reference * @param seen WeakSet tracking already visited schema objects * @returns JSON Schema representation */ export declare function mapOpenApiSchemaToJsonSchema(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, seen?: WeakSet): JSONSchema7 | boolean;