import { type ClientContext, type ExposureStrategy, type McpModuleOptions, type ToolListEntry, type ToolMetadata } from '@nest-mcp/common'; import { type OnApplicationBootstrap } from '@nestjs/common'; import { McpRegistryService } from '../discovery/registry.service'; import { type GetToolSchemaArgs, type GetToolSchemaResult } from './meta-tools/get-tool-schema'; import { type ListAvailableToolsArgs, type ListAvailableToolsResult } from './meta-tools/list-available-tools'; /** * Applies a catalog-presentation strategy to `tools/list` responses. * * Responsibilities: * - Resolve the concrete strategy for each client (static option or resolver). * - Transform executor-built tool entries per the resolved strategy: * `eager` (no-op), `search` (annotate with `_meta.defer_loading`), * `lazy` (filter to eager + meta-tools), `typed-api` (reserved). * - Register the `list_available_tools` / `get_tool_schema` meta-tools * at bootstrap when `lazy` is reachable. * - Validate config at application bootstrap (name collisions, all-deferred, * incompatible combinations). * * The service is a singleton and pure-per-request: client state lives in the * {@link ClientContext} parameter, never on the service. */ export declare class ExposureService implements OnApplicationBootstrap { private readonly options; private readonly registry; private readonly logger; private readonly configured; private readonly metaToolNames; private readonly metaToolConfig; private readonly maxBatchSize; constructor(options: McpModuleOptions, registry: McpRegistryService); /** * Runs after all `onModuleInit` hooks (including the scanner) have populated * the registry. We validate collisions against the scanned tools *before* * registering our meta-tools so an existing tool with the same name is a * hard error, not a silent overwrite. */ onApplicationBootstrap(): void; /** * Resolve the concrete strategy for the given client context. If the * module was configured with a static strategy, returns it unchanged; * if configured with a resolver function, invokes it with `ctx`. */ resolveForClient(ctx: ClientContext): ExposureStrategy; /** * Transform a list of tool entries (as produced by the executor) according * to the resolved strategy. Meta-tools are always present in the registry * but only surfaced in the response when `kind: 'lazy'` is active. * * @param entries - Pre-mapped tool entries (one per registered tool). * @param metas - Parallel map of tool name to metadata, for selector evaluation. * @param ctx - Client context used to resolve the strategy. */ applyStrategy(entries: ToolListEntry[], metas: Map, ctx: ClientContext): ToolListEntry[]; handleListAvailableTools(args: ListAvailableToolsArgs): Promise; handleGetToolSchema(args: GetToolSchemaArgs): Promise; private applySearch; private applyLazy; private withoutMetaTools; private lazyHint; private canResolveToLazy; private canResolveToSearch; /** * Decide whether the configured strategy could resolve to a given kind. * * - Static strategies: exact answer from the `kind` discriminant. * - Resolver functions with declared kinds (via `defineResolver`): exact * answer from the declaration. * - Plain resolver functions: conservative `true`, with a one-time warning * suggesting the user wrap with `defineResolver` to tighten behavior. */ private canResolveTo; private warnedUndeclaredResolver; private warnUndeclaredResolverOnce; private registerMetaTools; private validateNameCollisions; private validateSearchReachable; } //# sourceMappingURL=exposure.service.d.ts.map