export interface JsonRpcRequest { jsonrpc: "2.0"; id?: number | string | null; method: string; params?: unknown; } export interface JsonRpcResponse { jsonrpc: "2.0"; id: number | string | null; result?: unknown; error?: JsonRpcError; } export interface JsonRpcError { code: number; message: string; data?: unknown; } export const PARSE_ERROR = -32700; export const INVALID_REQUEST = -32600; export const METHOD_NOT_FOUND = -32601; export const INVALID_PARAMS = -32602; export const INTERNAL_ERROR = -32603; export interface ToolDefinition { name: string; description: string; inputSchema: Record; handler: (args: Record) => Promise; } export interface ToolResult { content: { type: "text"; text: string }[]; isError?: boolean; } export function ok(id: number | string | null, result: unknown): JsonRpcResponse { return { jsonrpc: "2.0", id, result }; } export function fail(id: number | string | null, code: number, message: string, data?: unknown): JsonRpcResponse { return { jsonrpc: "2.0", id, error: { code, message, data } }; }