/**
 * JSON-RPC 2.0 envelope parsing + error helpers for the MCP Streamable HTTP
 * transport (#614). The MCP wire format is one JSON-RPC message per HTTP body
 * (no batches in the 2025-06-18 revision — spec §transports).
 *
 * Spec: https://www.jsonrpc.org/specification
 */
export declare const JSONRPC_VERSION = "2.0";
/** Standard JSON-RPC 2.0 error codes (spec §5.1). */
export declare const ERROR_CODES: {
    readonly PARSE_ERROR: -32700;
    readonly INVALID_REQUEST: -32600;
    readonly METHOD_NOT_FOUND: -32601;
    readonly INVALID_PARAMS: -32602;
    readonly INTERNAL_ERROR: -32603;
};
export type JsonRpcId = string | number | null;
export interface JsonRpcRequest {
    jsonrpc: '2.0';
    id: JsonRpcId;
    method: string;
    params?: unknown;
}
export interface JsonRpcNotification {
    jsonrpc: '2.0';
    method: string;
    params?: unknown;
}
export interface JsonRpcSuccessResponse {
    jsonrpc: '2.0';
    id: JsonRpcId;
    result: unknown;
}
export interface JsonRpcErrorObject {
    code: number;
    message: string;
    data?: unknown;
}
export interface JsonRpcErrorResponse {
    jsonrpc: '2.0';
    id: JsonRpcId;
    error: JsonRpcErrorObject;
}
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccessResponse | JsonRpcErrorResponse;
export interface ParseSuccess {
    ok: true;
    message: JsonRpcMessage;
}
export interface ParseFailure {
    ok: false;
    code: number;
    reason: string;
}
export type ParseResult = ParseSuccess | ParseFailure;
/**
 * Validate a JSON-RPC envelope. Accepts either a raw UTF-8 JSON string
 * (e.g., from a streamed request body) or an already-parsed value (e.g.,
 * Fastify hands us a parsed object via its preParsing pipeline). Returns
 * either a typed message or a structured parse error that the caller maps
 * to a JSON-RPC error response. Never throws.
 */
export declare function parseMessage(body: string | unknown): ParseResult;
/**
 * True if the message is a "fire-and-forget" frame from the client's
 * perspective — a notification (no `id`) or a response to a server-initiated
 * request (has `result` or `error`). Per MCP §transports point 4, both yield
 * HTTP 202 with no body.
 */
export declare function isClientFireAndForget(message: JsonRpcMessage): boolean;
export declare function buildSuccess(id: JsonRpcId, result: unknown): JsonRpcSuccessResponse;
export declare function buildError(id: JsonRpcId, code: number, message: string, data?: unknown): JsonRpcErrorResponse;
