/** * mcp/types.ts — MCP Protocol Types (JSON-RPC 2.0) * * Implements the Model Context Protocol specification (MCP 2025-06-18) * without requiring the @modelcontextprotocol/sdk dependency. * * Protocol reference: https://modelcontextprotocol.io/specification/2025-06-18/ * Hannover reference: src/services/mcp/types.ts */ export interface JsonRpcRequest { jsonrpc: "2.0"; id: number | string; method: string; params?: Record; } export interface JsonRpcResponse { jsonrpc: "2.0"; id: number | string | null; result?: unknown; error?: JsonRpcError; } export interface JsonRpcError { code: number; message: string; data?: unknown; } export interface JsonRpcNotification { jsonrpc: "2.0"; method: string; params?: Record; } export interface McpStdioConfig { type?: "stdio"; command: string; args?: string[]; env?: Record; } export interface McpReturnedHttpReadPolicy { pathPrefixes: string[]; credentialHeaderNames: string[]; maxResponseBytes?: number; } export interface McpHttpConfig { type: "http" | "sse"; url: string; headers?: Record; /** Explicit host policy for reading URLs returned by this exact connector. */ returnedHttpRead?: McpReturnedHttpReadPolicy; } export type McpServerConfig = McpStdioConfig | McpHttpConfig; export interface McpConfig { mcpServers: Record; } export interface McpToolDefinition { name: string; /** Human-readable display name (spec 2025-06-18) */ title?: string; description?: string; inputSchema: { type: "object"; properties?: Record; required?: string[]; [key: string]: unknown; }; /** Optional output schema for structuredContent validation */ outputSchema?: { type: "object"; properties?: Record; required?: string[]; [key: string]: unknown; }; annotations?: { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; openWorldHint?: boolean; }; _meta?: Record; } export interface McpResource { uri: string; name?: string; description?: string; mimeType?: string; } export interface McpPrompt { name: string; description?: string; arguments?: Array<{ name: string; description?: string; required?: boolean; }>; } export interface McpAnnotations { audience?: ("user" | "assistant")[]; priority?: number; lastModified?: string; } export interface McpTextContent { type: "text"; text: string; annotations?: McpAnnotations; } export interface McpImageContent { type: "image"; data: string; mimeType: string; annotations?: McpAnnotations; } export interface McpAudioContent { type: "audio"; data: string; mimeType: string; annotations?: McpAnnotations; } export interface McpResourceLinkContent { type: "resource_link"; uri: string; name?: string; description?: string; mimeType?: string; annotations?: McpAnnotations; } export interface McpEmbeddedResource { type: "resource"; resource: { uri: string; mimeType?: string; text?: string; blob?: string; annotations?: McpAnnotations; }; } export type McpContent = McpTextContent | McpImageContent | McpAudioContent | McpResourceLinkContent | McpEmbeddedResource; export interface McpToolCallResult { content: McpContent[]; /** Spec 2025-06-18: structured JSON output (for tools with outputSchema) */ structuredContent?: unknown; isError?: boolean; _meta?: Record; } export interface McpServerCapabilities { tools?: { listChanged?: boolean; }; resources?: { subscribe?: boolean; listChanged?: boolean; }; prompts?: { listChanged?: boolean; }; } export interface McpServerInfo { name: string; version: string; } export interface McpInitializeResult { protocolVersion: string; capabilities: McpServerCapabilities; serverInfo: McpServerInfo; instructions?: string; } export type McpConnectionStatus = "connected" | "failed" | "pending" | "disconnected"; export interface McpConnection { name: string; status: McpConnectionStatus; config: McpServerConfig; capabilities?: McpServerCapabilities; serverInfo?: McpServerInfo; instructions?: string; tools: McpToolDefinition[]; resources: McpResource[]; error?: string; }