/** * Shared types and helpers for MCP tool registration. * * Guardrail layers applied by registerToolSafe (outer → inner): * 1. Audit log wrapper — captures timing and outcome for every call. * 2. Project allowlist — rejects calls targeting disallowed project UUIDs at runtime. * 3. Input validation — rejects invalid resource IDs (control chars, ?, #, %, path traversal). * 4. Dry-run wrapper — simulates writes without executing them (registration-time). * 5. Safety-mode wrapper — disables tools that exceed the configured safety level. * 6. Raw handler — the actual tool implementation. */ import type { LightdashClient } from '@lightdash-tools/client'; import type { ToolAnnotations } from '@lightdash-tools/common'; import type { z } from 'zod'; /** Prefix for all MCP tool names (disambiguation when multiple servers are connected). */ export declare const TOOL_PREFIX = "ldt__"; export type TextContent = { content: Array<{ type: 'text'; text: string; }>; isError?: boolean; }; /** Tool handler type used to avoid deep instantiation with SDK/Zod. Accepts (args, extra) for SDK compatibility. */ export type ToolHandler = (args: unknown, extra?: unknown) => Promise; /** Options for registerTool; inputSchema typed as ZodRawShapeCompat for SDK compatibility. Pass annotations explicitly (e.g. READ_ONLY_DEFAULT or WRITE_IDEMPOTENT) for visibility. */ export type ToolOptions = { description: string; inputSchema: Record; title?: string; annotations?: ToolAnnotations; }; export { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE } from '@lightdash-tools/common'; /** * Registers a tool with prefix and annotations, applying all guardrail layers. * shortName is prefixed to become TOOL_PREFIX + shortName. * Pass annotations explicitly (e.g. READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, or WRITE_DESTRUCTIVE). * * CLI flag --allowed-projects always takes priority over LIGHTDASH_TOOLS_ALLOWED_PROJECTS. */ export declare function registerToolSafe(server: unknown, shortName: string, options: ToolOptions, handler: ToolHandler): void; export declare function wrapTool(client: LightdashClient, fn: (client: LightdashClient) => (args: T) => Promise): ToolHandler;