/** * ExpositionCompiler — Topology Compiler Engine * * Pure-function transformation module responsible for projecting * the tool registry's abstract definitions onto the MCP protocol * wire format based on the configured Exposition Strategy. * * - **flat**: Deterministically expands each action into an independent * atomic MCP tool with isolated schema, description, and annotations. * * - **grouped**: Passthrough — yields the grouped tool definition unmodified. * * Also emits an O(1) dispatch map for constant-time request proxying * during execution. * * Pure-function module: no state, no side effects. * * @module */ import { type Tool as McpTool } from '@modelcontextprotocol/sdk/types.js'; import { type ToolBuilder } from '../core/types.js'; import { type ToolExposition } from './types.js'; /** * Routing entry for the O(1) dispatch map. * * Maps a flat tool name (e.g. `projects_list`) back to its * originating builder, the action key, and the discriminator field. */ export interface FlatRoute { /** The originating grouped builder */ readonly builder: ToolBuilder; /** Action key to inject as discriminator value (e.g. `"list"`) */ readonly actionKey: string; /** Discriminator field name (e.g. `"action"`) */ readonly discriminator: string; } /** * Result of the exposition compilation phase. * * Contains the protocol-facing tool definitions and the routing map * for incoming flat tool calls. */ export interface ExpositionResult { /** MCP Tool definitions to expose in `tools/list` */ readonly tools: McpTool[]; /** O(1) dispatch map: flat tool name → route info */ readonly routingMap: Map>; /** Whether flat mode is active (controls callHandler behavior) */ readonly isFlat: boolean; } /** * Compile tool builders into the protocol-facing exposition format. * * @param builders - Iterable of registered tool builders * @param exposition - Exposition strategy ('flat' or 'grouped') * @param separator - Action separator for flat naming (default: '_') * @returns Compiled tools and routing map */ /** * Optional warning callback for diagnostics. * Replaces console.warn to avoid polluting stdout/stderr in production. * @see Bug #131 */ export type ExpositionWarnFn = (message: string) => void; export declare function compileExposition(builders: Iterable>, exposition?: ToolExposition, separator?: string, onWarn?: ExpositionWarnFn): ExpositionResult; //# sourceMappingURL=ExpositionCompiler.d.ts.map