import type { CallToolResult, InputRequiredResult } from '@modelcontextprotocol/server'; export declare function textResult(text: string): CallToolResult; export declare function errorResult(text: string): CallToolResult; /** * Cap on a single tool result. A pad can legitimately hold 256 KiB; dumping * all of it would fill the context and bury the part that was asked about. */ export declare const MAX_RESULT_BYTES = 200000; /** * Serializes a payload, refusing rather than cutting the JSON mid-string. * * It used to answer with an envelope carrying the oversized document as a * string. That is valid JSON and no longer a valid *answer*: every tool * declares what it returns and the SDK checks the result against it, so an * envelope of a different shape is refused outright. There is no true answer * of this size. */ export declare function budgetedJson(data: unknown, followUp?: string): string; /** Raised by the budget; `run` turns it into an error result. */ export declare class ResultTooLargeError extends Error { } /** * An answer in both channels at once. * * `structuredContent` is the machine-readable half and the reason every tool * here declares an `outputSchema`; the text block stays because the SDK does * NOT synthesize one for an object-shaped value, and a client that reads only * `content` would otherwise get an empty answer. Both carry the same object. */ export declare function jsonResult(data: Record, followUp?: string): CallToolResult; /** * Marks content that came out of a pad. Every pad is world-writable to anyone * who knows the id, so its content is attacker-controlled by definition — * including content this server wrote earlier, which may have been edited * since. */ export declare function untrustedResult(data: Record): CallToolResult; /** * Shortens pad text to the budget, marking what was cut. * * Separate from the JSON budget because a pad over the ceiling is an ordinary * answer rather than an error: `get_document` on a large pad should return as * much of it as fits, and say how much there was. * * The budget is measured on the text *as serialised*, not on its length: the * text block carries the pad as a JSON string, and a quote or a backslash is * two characters there where the pad has one. Measured on the raw length, a * pad of 200 000 backslashes went out as 400 000 — twice the budget, in the * one channel that is supposed to enforce it. The cut lands on a code unit, * so `toWellFormed` runs after it. Both counts are code points, like every * other character count this server reports. */ export declare function budgetedText(text: string): { text: string; truncated?: { shown: number; total: number; }; }; /** * Limits what an upstream error body can inject into the model context: HTML * error pages (reverse proxies, WAFs) are dropped entirely, other bodies are * truncated. */ export declare function sanitizeErrorBody(body: string): string; /** Errors that come from the caller's arguments rather than from Rustpad. */ export declare class ToolInputError extends Error { constructor(message: string); } /** * Runs a tool handler and converts thrown errors into MCP error results * instead of protocol-level failures. */ export declare function run(fn: () => Promise): Promise;