import { McpServer } from '@modelcontextprotocol/server'; import { CommandResult } from '../utils/types.js'; import { ResourceCatalog } from '../res/resourceCatalog.js'; /** * Owns the command registry and registers it onto MCP server instances. * * Construction and registration are deliberately separate: `serveStdio` may * call its server factory more than once per connection (it builds an * optimistic `server/discover` probe instance and discards it if the client * then opens with a 2025-era `initialize`), so each call needs a *fresh* * `McpServer`. Building the registry once and calling `registerOn()` per * instance keeps the expensive work — and the single-flight auth memo below — * shared, while per-instance registration stays cheap and repeatable. */ export declare class ToolsManager { private readonly resourceCatalog; private commandRegistry; private cliExecutor; private authValidationPromise?; private readonly ensureAuthValidated; /** * Create a new ToolsManager and build its command registry. * @param resourceCatalog The shared index of bundled `res/` content, read by the resource tools */ constructor(resourceCatalog?: ResourceCatalog); /** * Register every command in the registry as a tool on the given MCP server. * Safe to call for each instance the server factory produces. * @param server The MCP server instance to register onto */ registerOn(server: McpServer): void; /** * Build the command registry */ private initializeTools; /** * Register resource access tools for ServiceNow metadata */ private registerResourceTools; /** * Registers a command as an MCP tool on the given server * @param server The MCP server instance to register onto * @param command The command to register */ private registerToolFromCommand; /** Commands at or above this timeout are treated as long-running for progress reporting. */ private static readonly LONG_RUNNING_THRESHOLD_MS; /** Interval between progress heartbeats for long-running commands. */ private static readonly PROGRESS_HEARTBEAT_MS; /** * Start best-effort progress notifications for a long-running command. * Emits an initial progress, then periodic heartbeats with an indeterminate * total, until the returned cleanup function is called (which sends a final * progress). No-ops unless the client supplied a `progressToken` and the * command is long-running. Never throws. * * Request-scoped `notifications/progress` flows on the originating request's * stream on 2026-07-28 as on 2025-11-25. * @returns A cleanup function to call when the command completes. */ private startProgress; /** * Format the result of a command execution. * On success, returns clean output only (isError field already conveys success/failure). * On failure, returns concise error with output context. */ formatResult(result: { success: boolean; output: string; exitCode?: number; error?: string; }): string; /** * List the CLI's stored auth profiles (`now-sdk auth --list`) with the shared * executor, for lazy auth validation. Read-only: the server never adds, * deletes or selects a profile (see `AuthCommand`). Not exposed to MCP * clients; the matching alias is stored in the session for all SDK commands. */ listAuthProfiles(): Promise; } //# sourceMappingURL=toolsManager.d.ts.map