UNPKG

openapi-mcp-generator

Version:

Generates MCP server code from OpenAPI specifications

65 lines (64 loc) 2.15 kB
/** * General helper utilities for OpenAPI to MCP generator */ import { OpenAPIV3 } from 'openapi-types'; /** * Safely stringify a JSON object with proper error handling * * @param obj Object to stringify * @param defaultValue Default value to return if stringify fails * @returns JSON string or default value */ export declare function safeJsonStringify(obj: any, defaultValue?: string): string; /** * Sanitizes a string for use in template strings * * @param str String to sanitize * @returns Sanitized string safe for use in template literals */ export declare function sanitizeForTemplate(str: string): string; /** * Converts a string to camelCase * * @param str String to convert * @returns camelCase string */ export declare function toCamelCase(str: string): string; /** * Converts a string to PascalCase * * @param str String to convert * @returns PascalCase string */ export declare function toPascalCase(str: string): string; /** * Creates a valid variable name from a string * * @param str Input string * @returns Valid JavaScript variable name */ export declare function toValidVariableName(str: string): string; /** * Checks if a string is a valid JavaScript identifier * * @param str String to check * @returns True if valid identifier, false otherwise */ export declare function isValidIdentifier(str: string): boolean; /** * Formats a string for use in code comments * * @param str String to format * @param maxLineLength Maximum line length * @returns Formatted comment string */ export declare function formatComment(str: string, maxLineLength?: number): string; /** * Normalize a value to boolean if it looks like a boolean; otherwise undefined. */ export declare function normalizeBoolean(value: unknown): boolean | undefined; /** * Determine if an operation should be included in MCP generation based on x-mcp. * Precedence: operation > path > root; uses provided default when all undefined. */ export declare function shouldIncludeOperationForMcp(api: OpenAPIV3.Document, pathItem: OpenAPIV3.PathItemObject, operation: OpenAPIV3.OperationObject, defaultInclude?: boolean): boolean;