Skip to content

API & CLI Reference

Both Python (mcp_schema_bridge) and TypeScript (mcp-schema-bridge) expose the same core model and produce byte-identical output.


Normalizes an entire MCP tools/list array for a target, enforcing per-request strict budgets.

Python

normalize_tools(
tools: Sequence[Mapping[str, Any] | Any], # dicts or MCP SDK Tool objects
target: Target,
options: NormalizeOptions | None = None,
) -> ToolsetResult

TypeScript

normalizeTools(
tools: readonly unknown[],
target: Target,
opts?: NormalizeOptions,
): ToolsetResult

Normalizes a single standalone JSON Schema (not wrapped in an MCP tool object).

Python

normalize_schema(
schema: Mapping[str, Any] | bool,
target: Target,
options: NormalizeOptions | None = None,
) -> NormalizeResult

TypeScript

normalizeSchema(
schema: unknown,
target: Target,
opts?: NormalizeOptions,
): NormalizeResult

Reverses reversible schema rewrites (such as removing nulls injected by strict mode or unwrapping a wrapped root) before you pass model arguments to tools/call.

Python

denormalize_args(
tool: NormalizedTool | NormalizeResult | Mapping[str, Any],
args: Any,
*,
strict: bool = False,
repairs: Iterable[Repair] = (),
) -> DenormalizeResult

TypeScript

denormalizeArgs(
tool: HasReverse,
args: unknown,
opts?: { strict?: boolean; repairs?: Iterable<Repair> },
): DenormalizeResult
  • strict: When true, unrecognized argument shapes raise InvalidInputError instead of passing through with a lossy warning.
  • repairs: Opt-in unambiguous repairs:
    • "int_from_integral_float" — converts 5.0 to 5 for integer fields (Python only; in JS 5.0 === 5).
    • "enum_case_insensitive" — matches a string to a unique case-insensitive enum value.

Converts a ToolsetResult into the exact tool array shape expected by official provider SDKs.

api argument Compatible target(s) Output shape
"genai" gemini-json @google/genai / google-genai Tool (functionDeclarations[].parametersJsonSchema)
"openai-responses" openai, openai-strict OpenAI Responses API FunctionTool (explicit strict boolean)
"openai-chat" openai, openai-strict OpenAI Chat Completions ChatCompletionTool (explicit strict boolean)
"anthropic-messages" anthropic, anthropic-strict Anthropic Messages API Tool (input_schema + explicit strict boolean)

In Python, this requires pip install "mcp-schema-bridge[sdks]" for genai (google-genai types); in TypeScript, it returns structurally typed plain objects with zero SDK imports.


"gemini-json" · "openai" · "openai-strict" · "anthropic" · "anthropic-strict"

Python field TypeScript field Default Description
hints hints True / true Append dropped constraints to field descriptions (spec/hint-format.md).
on_unsupported onUnsupported "report" "report" records fatal entries and puts tools in result.rejected; "raise" throws UnsupportedSchemaError on the first fatal entry.
max_ref_depth maxRefDepth 3 Maximum recursion unrolling depth on targets that forbid recursion.
max_nodes maxNodes 10000 Input and output JSON value node cap.
max_depth maxDepth 64 Input nesting depth cap.
max_description_chars maxDescriptionChars None / null Truncate original description text to this length (hints are never truncated).
strict_fallback strictFallback False / false Demote unfixable or over-budget tools to the non-strict sibling (openai or anthropic) instead of rejecting them.
reserved_budget reservedBudget None / null Budget(strict_tools, optional_params, union_params) reserved for your own non-MCP tools or structured output schema.

Member Description
tools List of accepted NormalizedTool objects.
rejected List of Rejection objects (name, target, reasons) for tools that could not be normalized.
report Report containing all ReportEntry items.
get(name) Returns the NormalizedTool with name, or None / undefined.
summary() Returns the human-readable summary string (identical to CLI text output, including fix: lines).
to_dict() / toJSON() Serializes the full result (schema, reverse map, report, versions) for caching.
  • name: Tool name.
  • description: Tool description (or null).
  • target: Actual target used (may be the non-strict sibling if strict_fallback triggered).
  • strict: Boolean indicating whether strict mode is active for this tool.
  • schema: Normalized JSON Schema object ready for the provider.
  • schemaOrdered (TS only): Map preserving exact key order for integer-like property names.
  • reverse: Reverse map used by denormalize_args / denormalizeArgs.
  • fingerprint: SHA-256 fingerprint covering the original schema, library version, rules_version, and target.

Every change emits a ReportEntry with rule, tid, tool, source_path, target_path, instance_path, keyword, action, severity, original, hinted, and message (see Rule catalog).

  • info: Equivalent rewrite; no validation semantics lost.
  • reversible: Wire contract changed, and denormalize_args restores the original shape.
  • lossy: Constraint or distinction is not enforced by the target (restated as a description hint where possible).
  • fatal: Tool cannot be expressed for this target (rejected, or demoted if strict_fallback is enabled).

All errors inherit from SchemaBridgeError:

  • InvalidInputError: Malformed input tool/schema, or invalid arguments with denormalize_args(..., strict=True).
  • UnsupportedSchemaError: Raised when on_unsupported="raise" encounters a fatal entry.
  • LimitExceededError: Input exceeds max_nodes or max_depth.
  • ReverseMismatchError: denormalize_args was called with a reverse map whose fingerprint or rules_version does not match the tool or loaded rules.

Installed via pip install "mcp-schema-bridge[cli]". Input can be a JSON file (single schema, tool array, or tools/list object), - for stdin, or a live MCP server via --stdio -- <command>.

Reports what would change for one or more targets.

Terminal window
mcp-schema-bridge check tools.json --fail-on lossy
mcp-schema-bridge check --target gemini-json --target openai-strict --stdio -- python my_server.py

Flags: --target (repeatable; defaults to all 5), --format {text,json}, --fail-on {info,reversible,lossy,fatal} (default fatal), --strict-fallback, --no-hints, --stdio, --timeout SECONDS (default 60.0).

Prints normalized tools, reverse maps, and reports as JSON (or text).

Terminal window
mcp-schema-bridge normalize tools.json --target anthropic-strict > normalized.json

Flags: --target, --format {json,text}, --strict-fallback, --no-hints, --stdio, --timeout SECONDS.

Starts a stdio MCP server in front of another MCP server, rewriting tools/list schemas for one target and calling denormalize_args on every tools/call.

Terminal window
mcp-schema-bridge proxy --target gemini-json --report bridge-report.json -- npx -y some-mcp-server

Flags: --target (required), --strict-fallback, --no-hints, --report FILE.

0 ok · 1 --fail-on threshold reached (check) · 2 usage error · 3 input, server, or timeout error.