/** * MCP (Model Context Protocol) Adapter * * Connects the SwarmOrchestrator to MCP servers, enabling agent communication * over the Model Context Protocol. This enables cross-network agent discovery * and execution via MCP's tool-calling interface. * * MCP servers expose "tools" — this adapter maps each tool to an agent * that the orchestrator can delegate tasks to. * * Usage: * const adapter = new MCPAdapter(); * await registry.addAdapter(adapter, { * connection: { url: 'http://localhost:3000/mcp' } * }); * * Or with pre-registered tool functions: * const adapter = new MCPAdapter(); * adapter.registerTool("search", searchFunction); * await registry.addAdapter(adapter); * * Then in the orchestrator: * delegateTask({ targetAgent: "mcp:search", ... }) * * @module MCPAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterConfig, AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** * MCP Tool definition (matches MCP spec) */ export interface MCPTool { name: string; description?: string; inputSchema?: Record; } /** * MCP tool execution function */ export type MCPToolHandler = (args: Record) => Promise<{ content: Array<{ type: string; text?: string; data?: unknown; }>; isError?: boolean; }>; /** * MCP Server connection interface */ export interface MCPServerConnection { /** List available tools from the MCP server */ listTools(): Promise; /** Call a tool on the MCP server */ callTool(name: string, args: Record): Promise<{ content: Array<{ type: string; text?: string; data?: unknown; }>; isError?: boolean; }>; /** Close the connection */ close(): Promise; } export declare class MCPAdapter extends BaseAdapter { readonly name = "mcp"; readonly version = "1.0.0"; private tools; private toolMetadata; private serverConnection; get capabilities(): AdapterCapabilities; initialize(config: AdapterConfig): Promise; /** * Register a local tool handler (no MCP server needed) */ registerTool(name: string, handler: MCPToolHandler, metadata?: { description?: string; inputSchema?: Record; }): void; private discoverServerTools; executeAgent(agentId: string, payload: AgentPayload, context: AgentContext): Promise; private executeLocalTool; private executeRemoteTool; private buildToolArgs; private extractContent; shutdown(): Promise; } //# sourceMappingURL=mcp-adapter.d.ts.map