import { McpServer } from '@modelcontextprotocol/server'; import type { CallToolResult, Implementation, ReadResourceResult, ToolAnnotations, ServerOptions, Transport } from '@modelcontextprotocol/server'; import { z, type ZodRawShape } from 'zod'; import type { Telemetry } from '@salesforce/b2c-tooling-sdk/telemetry'; import type { ContentRead, McpToolConfig, ToolContext } from './utils/types.js'; /** MCP skills extension identifier (SEP-2640). */ export declare const SKILLS_EXTENSION = "io.modelcontextprotocol/skills"; /** * Extended server options. */ export interface B2CDxMcpServerOptions extends ServerOptions { /** Release debugger sessions and log watches owned by this server instance. */ cleanup?: () => Promise; /** Configured `--project-directory`; bounds the per-call `projectDirectory` argument with client roots. */ projectDirectory?: string; /** * Telemetry instance for tracking server and tool events. * If not provided, telemetry is disabled. */ telemetry?: Telemetry; } /** Make the MCP SDK list a schema without `$schema` and default safe-integer bounds; validation is unchanged. */ export declare function compactJsonSchema(schema: T): T; export declare class B2CDxMcpServer extends McpServer { private readonly browserLogins; private readonly cleanup?; private clientLogged; private closePromise?; /** The 2025-era client's `roots/list` result, refreshed when the client reports a change. */ private legacyRoots?; private readonly projectDirectories; private readonly resourceReaders; private telemetry?; /** * Creates a new B2CDxMcpServer instance * * @param serverInfo - The server implementation details * @param options - Optional server configuration */ constructor(serverInfo: Implementation, options?: B2CDxMcpServerOptions); /** Register after resource metadata. Resolve raw URIs before URL dot-segment normalization. */ addResourceReader(prefix: string, read: (uri: string) => Promise): void; /** * Serve the MCP skills extension (SEP-2640): `skills/list` and `skills/get`. * Register before connecting. `get` throws a ProtocolError for unknown skills. */ addSkillsExtension(skills: { list: () => unknown[]; get: (uri: string) => unknown; }): void; /** * Register a tool with the server. * * This method provides a convenient way to register tools. * * @param name - Tool name * @param description - Tool description * @param inputSchema - Zod schema for input validation * @param handler - Function to handle tool invocations */ addTool(name: string, description: string, inputSchema: ZodRawShape, handler: (args: Record, context?: ToolContext) => Promise, metadata?: Pick & { annotations?: ToolAnnotations; _meta?: Record; }): void; close(): Promise; /** * Connect to a transport. */ connect(transport: Transport): Promise; /** * Record skill or doc content returned outside a tool call. `via` names the * avenue (`resources/read`, `skills/get`) so dashboards can compare them. */ recordContentRead(via: string, read: ContentRead): void; /** * Request `roots/list` from a 2025-era client, once per change. Some clients * send bare paths where the spec requires `file://` URIs, so the result is * parsed leniently rather than with the SDK's strict schema. */ private fetchLegacyRoots; /** * Record the client's identity once it is known, from `initialize` (legacy * protocol) or any request envelope (modern protocol). Every later event * carries the client name, and the first identification per process sends * CLIENT_CONNECTED, so sessions that never call a tool still report which * client and agent started them. */ private recordClient; private recordRequestClient; }