mcp-openapi-schema-explorer
Version:
MCP OpenAPI schema explorer
82 lines (81 loc) • 3.39 kB
TypeScript
/**
* Utility functions for building standardized MCP URIs for this server.
*/
/**
* Encodes a string component for safe inclusion in a URI path segment.
* Uses standard encodeURIComponent.
* Encodes a path string for safe inclusion in a URI.
* This specifically targets path strings which might contain characters
* like '{', '}', etc., that need encoding when forming the URI path part.
* Uses standard encodeURIComponent.
* Encodes a path string for safe inclusion in a URI path segment.
* This is necessary because the path segment comes from the user potentially
* containing characters that need encoding (like '{', '}').
* Uses standard encodeURIComponent.
* @param path The path string to encode.
* @returns The encoded path string, with leading slashes removed before encoding.
*/
export declare function encodeUriPathComponent(path: string): string;
/**
* Builds the URI for accessing a specific component's details.
* Example: openapi://components/schemas/MySchema
* @param type The component type (e.g., 'schemas', 'responses').
* @param name The component name.
* @returns The full component detail URI.
*/
export declare function buildComponentDetailUri(type: string, name: string): string;
/**
* Builds the URI for listing components of a specific type.
* Example: openapi://components/schemas
* @param type The component type (e.g., 'schemas', 'responses').
* @returns The full component map URI.
*/
export declare function buildComponentMapUri(type: string): string;
/**
* Builds the URI for accessing a specific operation's details.
* Example: openapi://paths/users/{userId}/GET
* @param path The API path (e.g., '/users/{userId}').
* @param method The HTTP method (e.g., 'GET', 'POST').
* @returns The full operation detail URI.
*/
export declare function buildOperationUri(path: string, method: string): string;
/**
* Builds the URI for listing methods available at a specific path.
* Example: openapi://paths/users/{userId}
* @param path The API path (e.g., '/users/{userId}').
* @returns The full path item URI.
*/
export declare function buildPathItemUri(path: string): string;
/**
* Builds the URI for accessing a top-level field (like 'info' or 'servers')
* or triggering a list view ('paths', 'components').
* Example: openapi://info, openapi://paths
* @param field The top-level field name.
* @returns The full top-level field URI.
*/
export declare function buildTopLevelFieldUri(field: string): string;
/**
* Builds the URI suffix for a specific component's details.
* Example: components/schemas/MySchema
*/
export declare function buildComponentDetailUriSuffix(type: string, name: string): string;
/**
* Builds the URI suffix for listing components of a specific type.
* Example: components/schemas
*/
export declare function buildComponentMapUriSuffix(type: string): string;
/**
* Builds the URI suffix for a specific operation's details.
* Example: paths/users/{userId}/get
*/
export declare function buildOperationUriSuffix(path: string, method: string): string;
/**
* Builds the URI suffix for listing methods available at a specific path.
* Example: paths/users/{userId}
*/
export declare function buildPathItemUriSuffix(path: string): string;
/**
* Builds the URI suffix for a top-level field.
* Example: info, paths
*/
export declare function buildTopLevelFieldUriSuffix(field: string): string;