/** * MCP Server Implementation * * High-level server class that orchestrates the MCP protocol handler, * transport layer, and tool/resource/prompt registrations. */ import type { MCPServerConfig, ServerCapabilities, Tool, ToolRegistration, ToolHandler, Resource, ResourceRegistration, ResourceHandler, Prompt, PromptRegistration, PromptHandler, Logger, LogLevel } from '../types'; /** * MCP Server Options */ export interface MCPServerOptions { /** Server name (required) */ name: string; /** Server version (required) */ version: string; /** Server description */ description?: string; /** Server capabilities override */ capabilities?: Partial; /** Logging configuration */ logging?: { level?: LogLevel; format?: 'json' | 'text'; }; /** Initial tools to register */ tools?: ToolRegistration[]; /** Initial resources to register */ resources?: ResourceRegistration[]; /** Initial prompts to register */ prompts?: PromptRegistration[]; /** Enable debug mode */ debug?: boolean; /** Custom logger instance */ logger?: Logger; } /** * MCP Server Status */ export type MCPServerStatus = 'stopped' | 'starting' | 'running' | 'stopping' | 'error'; /** * MCP Server Class * * Main entry point for creating and managing an MCP server. * Provides a fluent API for registering tools, resources, and prompts. */ export declare class MCPServer { private readonly config; private readonly logger; private readonly transport; private readonly handler; private status; private startPromise; private stopPromise; constructor(options: MCPServerOptions); /** * Get the current server status */ getStatus(): MCPServerStatus; /** * Start the MCP server */ start(): Promise; /** * Stop the MCP server */ stop(): Promise; /** * Register a tool with the server * * @param registration Tool registration including tool definition and handler * @returns This server instance for chaining */ registerTool(registration: ToolRegistration): this; /** * Register a tool using separate parameters * * @param tool Tool definition * @param handler Tool handler function * @returns This server instance for chaining */ addTool(tool: Tool, handler: ToolHandler): this; /** * Unregister a tool by name * * @param name Tool name to unregister * @returns True if the tool was unregistered */ unregisterTool(name: string): boolean; /** * Register a resource with the server * * @param registration Resource registration * @returns This server instance for chaining */ registerResource(registration: ResourceRegistration): this; /** * Register a resource using separate parameters * * @param resource Resource definition * @param handler Resource handler function * @returns This server instance for chaining */ addResource(resource: Resource, handler: ResourceHandler): this; /** * Unregister a resource by URI * * @param uri Resource URI to unregister * @returns True if the resource was unregistered */ unregisterResource(uri: string): boolean; /** * Register a prompt with the server * * @param registration Prompt registration * @returns This server instance for chaining */ registerPrompt(registration: PromptRegistration): this; /** * Register a prompt using separate parameters * * @param prompt Prompt definition * @param handler Prompt handler function * @returns This server instance for chaining */ addPrompt(prompt: Prompt, handler: PromptHandler): this; /** * Unregister a prompt by name * * @param name Prompt name to unregister * @returns True if the prompt was unregistered */ unregisterPrompt(name: string): boolean; /** * Get the server configuration */ getConfig(): Readonly; /** * Get the logger instance */ getLogger(): Logger; /** * Internal start implementation */ private doStart; /** * Internal stop implementation */ private doStop; } /** * Factory function to create an MCP server * * @param options Server options * @returns New MCP server instance * * @example * ```typescript * const server = createMCPServer({ * name: 'my-server', * version: '1.0.0', * }); * * server.addTool(myTool, myHandler); * await server.start(); * ``` */ export declare function createMCPServer(options: MCPServerOptions): MCPServer; /** * Builder pattern for creating MCP servers */ export declare class MCPServerBuilder { private options; constructor(name: string, version: string); /** * Set server description */ description(desc: string): this; /** * Set log level */ logLevel(level: LogLevel): this; /** * Enable debug mode */ debug(enabled?: boolean): this; /** * Add a tool */ withTool(tool: Tool, handler: ToolHandler): this; /** * Add a resource */ withResource(resource: Resource, handler: ResourceHandler): this; /** * Add a prompt */ withPrompt(prompt: Prompt, handler: PromptHandler): this; /** * Set custom logger */ logger(logger: Logger): this; /** * Set capabilities */ capabilities(caps: Partial): this; /** * Build and return the server */ build(): MCPServer; /** * Build and start the server */ start(): Promise; } /** * Start building an MCP server * * @param name Server name * @param version Server version * @returns Server builder instance * * @example * ```typescript * const server = await buildMCPServer('my-server', '1.0.0') * .description('My awesome MCP server') * .logLevel('debug') * .withTool(myTool, myHandler) * .start(); * ``` */ export declare function buildMCPServer(name: string, version: string): MCPServerBuilder; //# sourceMappingURL=MCPServer.d.ts.map