/** * @fileoverview Model Context Protocol (MCP) types * * MCP is the current standard for AI agent communication. * These types define the JSON-RPC based protocol. */ /** * MCP JSON-RPC request format. */ export type McpId = string | number; /** * MCP JSON-RPC request format. */ export interface McpRequest { /** JSON-RPC version, always '2.0' */ jsonrpc: '2.0'; /** Request ID for correlation */ id: McpId; /** Method being called */ method: string; /** Optional parameters */ params?: Record; } /** * MCP JSON-RPC response format. */ export interface McpResponse { /** JSON-RPC version, always '2.0' */ jsonrpc: '2.0'; /** Request ID this is responding to */ id: McpId; /** Result if successful */ result?: unknown; /** Error if failed */ error?: McpError; } /** * MCP error format (JSON-RPC compliant). */ export interface McpError { /** Error code (see McpErrorCodes) */ code: number; /** Human-readable error message */ message: string; /** Additional error data */ data?: unknown; } /** * Standard MCP error codes (JSON-RPC + MCP specific). */ export declare const McpErrorCodes: { readonly PARSE_ERROR: -32700; readonly INVALID_REQUEST: -32600; readonly METHOD_NOT_FOUND: -32601; readonly INVALID_PARAMS: -32602; readonly INTERNAL_ERROR: -32603; readonly SERVER_NOT_INITIALIZED: -32002; readonly REQUEST_CANCELLED: -32800; readonly CONTENT_MODIFIED: -32801; }; export type McpErrorCode = (typeof McpErrorCodes)[keyof typeof McpErrorCodes]; /** * MCP notification format (no response expected). */ export interface McpNotification { jsonrpc: '2.0'; method: string; params?: Record; } /** * MCP tool definition format. */ export interface McpTool { /** Tool name */ name: string; /** Tool description */ description?: string; /** JSON Schema for input */ inputSchema: { type: 'object'; properties?: Record; required?: string[]; }; /** AFD extensions carried through MCP tools/list. */ _meta?: McpToolCommandMeta & { /** Grouped tools only: one entry per command the tool dispatches to. */ actions?: McpToolAction[]; }; } /** Per-command AFD metadata advertised in a tool's `_meta`. */ export interface McpToolCommandMeta { category?: string; requires?: string[]; mutation?: boolean; destructive?: boolean; undoable?: boolean; examples?: Array<{ title: string; input: unknown; }>; outputSchema?: Record; contexts?: string[]; } /** * One action of a grouped tool (`toolStrategy: 'grouped'`), as listed in its * `_meta.actions`: the underlying command and its input schema. */ export interface McpToolAction extends McpToolCommandMeta { /** Value of the grouped tool's `action` argument */ action: string; /** Full command name (usable with afd-call and afd-detail) */ command: string; description: string; /** Input schema of the command, sent as the grouped tool's `params` */ inputSchema: McpTool['inputSchema']; } /** * MCP tools/list response. */ export interface McpToolsListResult { tools: McpTool[]; } /** * MCP tools/call request params. */ export interface McpToolCallParams { name: string; arguments?: Record; } /** * MCP tools/call response. */ export interface McpToolCallResult { content: McpContent[]; isError?: boolean; } /** * MCP content types. */ export type McpContent = McpTextContent | McpImageContent | McpResourceContent; export interface McpTextContent { type: 'text'; text: string; } export interface McpImageContent { type: 'image'; data: string; mimeType: string; } export interface McpResourceContent { type: 'resource'; resource: { uri: string; mimeType?: string; text?: string; blob?: string; }; } /** * MCP server capabilities. */ export interface McpServerCapabilities { tools?: { listChanged?: boolean; }; resources?: { subscribe?: boolean; listChanged?: boolean; }; prompts?: { listChanged?: boolean; }; logging?: Record; experimental?: Record; } /** * MCP client capabilities. */ export interface McpClientCapabilities { roots?: { listChanged?: boolean; }; sampling?: Record; experimental?: Record; } /** * MCP initialize request params. */ export interface McpInitializeParams { protocolVersion: string; capabilities: McpClientCapabilities; clientInfo: { name: string; version: string; }; } /** * MCP initialize response. */ export interface McpInitializeResult { protocolVersion: string; capabilities: McpServerCapabilities; serverInfo: { name: string; version: string; }; } /** * Create an MCP request. */ export declare function createMcpRequest(method: string, params?: Record): McpRequest; /** * Create an MCP success response. */ export declare function createMcpResponse(id: McpId, result: unknown): McpResponse; /** * Create an MCP error response. */ export declare function createMcpErrorResponse(id: McpId, code: number, message: string, data?: unknown): McpResponse; /** * Create a text content item. */ export declare function textContent(text: string): McpTextContent; /** * Type guard for MCP requests. */ export declare function isMcpRequest(value: unknown): value is McpRequest; /** * Type guard for MCP responses. */ export declare function isMcpResponse(value: unknown): value is McpResponse; /** * Type guard for MCP notifications. */ export declare function isMcpNotification(value: unknown): value is McpNotification; //# sourceMappingURL=mcp.d.ts.map