run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
29 lines • 1.86 kB
TypeScript
/**
* Tool arguments are strict: an argument a tool does not declare is refused,
* never silently dropped.
*
* Every tool is registered with its strict schema (`strictInput`), so the
* published JSON Schema says `additionalProperties: false` and the MCP SDK
* itself refuses an unknown key. The SDK reports its refusal as plain text,
* though, and every run402-mcp error carries `structuredContent`. So the
* guard below validates a `tools/call` against the same strict schema before
* the SDK sees it, and answers a failure itself with the structured error:
* `UNKNOWN_ARGUMENT` (with the closest declared names) or `INVALID_ARGUMENTS`.
* A valid call passes through untouched.
*/
import { z } from "zod";
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import type { ToolError } from "./structured.js";
/** A tool's input shape as a strict object: unknown keys fail. */
export declare function strictInput<T extends z.ZodRawShape>(shape: T): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
type StrictSchema = z.ZodObject<z.ZodRawShape, "strict">;
/** The structured refusal for arguments that fail a tool's strict schema, or null when they pass. */
export declare function argumentError(tool: string, schema: StrictSchema, args: unknown): ToolError | null;
/**
* Refuse invalid tool arguments with a structured result before the server
* dispatches the call. Install after `server.connect(transport)`, which sets
* the transport's `onmessage`.
*/
export declare function guardToolArguments(transport: Transport, schemas: Record<string, StrictSchema>): void;
export {};
//# sourceMappingURL=input-guard.d.ts.map