/** * The exact prefix `@langchain/mcp-adapters` puts in front of an errored MCP tool result's text * content, for a tool named `toolName` (its **bare** name, as the server advertises it) on the * server configured under `serverName`. * * Single-sourced so the derivation below and the spec that pins the adapter's wording compare the * same string: a retyped literal on both sides of that assertion would pin nothing. */ export declare function mcpToolErrorMessagePrefix(serverName: string, toolName: string): string; /** One captured tool result, in the shape {@link mcpToolErrorPayload} needs to judge it. */ export interface McpToolErrorPayloadInput { /** The registered tool name, exactly as the model called it (`ToolMessage.name`). */ name: string; /** Whether the result carried LangChain's error signal (`ToolMessage.status === 'error'`). */ isError: boolean; /** The result payload as captured, untouched (`ToolMessage.content`). */ content: unknown; } /** * The server's own error body, recovered from a softened MCP tool error, or `undefined`. * * **Present implies parseable**, and that contract is the point: the grading check falls back to * the observed payload — and to its existing failure reason — whenever this returns `undefined`, so * a recorded field must never be something the check would then choke on. Every one of these * yields `undefined`: * * - the result is not an error, or its content is not a plain string (a blocks array is a SUCCESS * shape; the adapter's throw always produces a string); * - the name is not MCP-namespaced, or does not resolve to exactly one configured server; * - the message does not start with the computed prefix (a different adapter message — an invalid * result, an unexpected content type — or an upstream reword); * - the remainder is not JSON, which is simply a server that formats its errors as prose; * - the remainder is longer than `maxBytes` UTF-8 bytes. * * That last one is a deliberate choice rather than a fallout. The observed payload is capped at * capture so a giant result cannot bloat run stats, and the same per-field bound has to apply here * or the cap is trivially escaped. It bounds each field, not the record: a result that carries both * fields can hold two capped strings, which is the price of keeping the observed payload intact * beside a gradable one. But a JSON document cut off at the bound does not parse, so recording * a truncated one would spend the bytes, break the present-implies-parseable contract, and leave * the check failing anyway — while looking, to whoever reads the record, as though the recovery * had worked. Dropping it says the true thing instead. The bound counts UTF-8 bytes, the same unit * the observed-payload cap counts (BATCH-49) — a character count here would recover a body the * other site had already cut, or drop one it had kept, for any payload outside ASCII. * * @param result The captured result: registered name, error status, and the untouched content. * @param configuredMcpServers `Object.keys(config.mcpServers)` — the user's own keys, and the only * thing consulted when resolving which server this tool belongs to. * @param maxBytes The same cap the observed payload is held to, in UTF-8 bytes. A body whose * encoded size is over it is dropped whole rather than cut — see the contract above. */ export declare function mcpToolErrorPayload(result: McpToolErrorPayloadInput, configuredMcpServers: Iterable, maxBytes: number): string | undefined;