/** * Shared response formatter for MCP tool outputs. * * Tools can declare `outputFormat?: "markdown" | "json" | "both"` (defaults to * `"json"`, preserving v1.8 behavior). When the caller asks for a different * shape, the registration wrapper in `src/index.ts` calls * {@link formatMcpResponse} to produce the actual response content. * * Two audiences are served at once: * - **AI agents** (the typical caller) want raw JSON they can parse and chain * into the next call without re-reasoning. * - **Humans reading the same response** (the typical second audience: the * dev pasting the result into a PR comment, a Slack thread, or a Jira * ticket) want a markdown view that highlights the key fields. * * `outputFormat: "both"` returns BOTH content items in a single response, so a * client can display the markdown to the user AND parse the JSON for the * agent loop without an extra round-trip. */ import { z } from "zod"; export declare const outputFormatField: z.ZodOptional>; export type OutputFormat = z.infer; export interface McpContentItem { type: "text"; text: string; } /** * Shape of the MCP tool response. Matches the SDK's expected type * (which has an open index signature for arbitrary extension fields like * `_meta`); we model it explicitly here so the formatter's return type * can flow through `server.registerTool` without a cast. */ export interface McpResponse { content: McpContentItem[]; [key: string]: unknown; } /** * Pure: shape the MCP response based on the caller's `outputFormat`. * * For `json` and `both`, the JSON is `JSON.stringify(result, null, 2)`. For * `markdown` and `both`, the markdown is rendered via {@link renderAsMarkdown}. */ export declare function formatMcpResponse(result: unknown, toolName: string, format: OutputFormat | undefined): McpResponse; /** * Pure: render a verify-fix focused markdown table for tools that support * it. Returns `null` if the tool's result does not match the expected * verify-fix shape, signaling the caller to fall back to standard markdown. * * Supported tools: * * - `analyzeAbandonedMemory`: reads `actionableShrinkage[]` (the v1.10 * verify-fix-default direction: classes that the fix freed) and * `actionableGrowth[]` (regressions the fix didn't address). Emits one * table for shrinkage and, when non-empty, a second smaller table for * growth. Threshold: |delta| >= 10 by default to filter cosmetic noise. * * - `diffMemgraphs`: reads `classCountChanges[]` (positive + negative). * Future expansion; for now returns null and falls back to standard * markdown. * * The 4-column layout is deliberately compact (Class | Before | After | * Delta) so it renders cleanly in GitHub's markdown preview, dev.to, and * agent chat contexts. A trailing `> Diagnosis: ...` blockquote carries * the structured `diagnosis` field when present. */ export declare function renderVerifyFixTable(result: unknown, toolName: string): string | null; /** * Pure: render an arbitrary JSON-shaped value as markdown. * * The rendering is intentionally generic: it does not have per-tool * templates. A `# Tool name` header, a `## Key` for each top-level field, and * smart formatting for arrays of objects (tables when the rows share a * schema) and scalars. Per-tool overrides can land in v1.9.1+ if any * specific tool's output deserves a more curated view. * * Exposed for tests. */ export declare function renderAsMarkdown(value: unknown, toolName: string): string;