import type { JSONSchemaType } from '@redocly/ajv'; import type { McpServer } from '@redocly/mcp-typescript-sdk/server/mcp.js'; import type { OpenAPIDefinition } from '@redocly/openapi-docs'; import type { AccessInfo, ApiDescriptionInfo, McpToolWorkerParams, McpToolWorkerResponse, ToolArgsMap } from '../../types.js'; export type DocsMcpToolRegistrationOptions = { server: McpServer; baseUrl: string; outdir: string; apiDescriptionsMap: Record; headers?: Record; accessInfo: AccessInfo; products?: string[]; }; /** Keys that can be passed to the tool context (excludes 'server' which is not serializable) */ export type ContextKey = Exclude; export type ApiDefinitionResult = { success: true; definition: OpenAPIDefinition; } | { success: false; response: McpToolWorkerResponse; }; export declare abstract class DocsMcpTool { abstract readonly name: TName; abstract readonly description: string; readonly schema: JSONSchemaType; /** * Array of context keys that this tool requires. * The base class will extract these from DocsMcpToolRegistrationOptions * and pass them to executeAction. */ abstract readonly requiredContext: readonly ContextKey[]; constructor(schema: JSONSchemaType); /** * Builds the context object by picking only the required keys from options. */ protected getContext(options: DocsMcpToolRegistrationOptions): McpToolWorkerParams['context']; register(options: DocsMcpToolRegistrationOptions): void; /** * Wraps the tool execution with telemetry and error handling. * Subclasses should call this method and implement executeAction for the actual logic. */ execute(args: ToolArgsMap[TName], context: McpToolWorkerParams['context']): Promise; /** * Implement the actual tool logic here. Called by execute() which handles telemetry. */ protected abstract executeAction(args: ToolArgsMap[TName], context: McpToolWorkerParams['context']): Promise; /** * Helper method for tools that need to load an API definition. * Handles finding the API by name and loading the definition from the file system. * Requires 'outdir' and 'accessInfo' in requiredContext. */ protected getApiDefinition(name: string, context: McpToolWorkerParams['context']): Promise; } //# sourceMappingURL=docs-mcp-tool.d.ts.map