API & CLI Reference
Both Python (mcp_schema_bridge) and TypeScript (mcp-schema-bridge) expose the same core model and produce byte-identical output.
Core functions
Section titled “Core functions”normalize_tools / normalizeTools
Section titled “normalize_tools / normalizeTools”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,) -> ToolsetResultTypeScript
normalizeTools( tools: readonly unknown[], target: Target, opts?: NormalizeOptions,): ToolsetResultnormalize_schema / normalizeSchema
Section titled “normalize_schema / normalizeSchema”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,) -> NormalizeResultTypeScript
normalizeSchema( schema: unknown, target: Target, opts?: NormalizeOptions,): NormalizeResultdenormalize_args / denormalizeArgs
Section titled “denormalize_args / denormalizeArgs”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] = (),) -> DenormalizeResultTypeScript
denormalizeArgs( tool: HasReverse, args: unknown, opts?: { strict?: boolean; repairs?: Iterable<Repair> },): DenormalizeResultstrict: Whentrue, unrecognized argument shapes raiseInvalidInputErrorinstead of passing through with alossywarning.repairs: Opt-in unambiguous repairs:"int_from_integral_float"— converts5.0to5forintegerfields (Python only; in JS5.0 === 5)."enum_case_insensitive"— matches a string to a unique case-insensitiveenumvalue.
to_sdk_payload / toSdkPayload
Section titled “to_sdk_payload / toSdkPayload”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.
Targets & Options
Section titled “Targets & Options”TARGETS
Section titled “TARGETS”"gemini-json" · "openai" · "openai-strict" · "anthropic" · "anthropic-strict"
NormalizeOptions
Section titled “NormalizeOptions”| 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. |
Result & Report Types
Section titled “Result & Report Types”ToolsetResult
Section titled “ToolsetResult”| 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. |
NormalizedTool
Section titled “NormalizedTool”name: Tool name.description: Tool description (ornull).target: Actual target used (may be the non-strict sibling ifstrict_fallbacktriggered).strict: Boolean indicating whether strict mode is active for this tool.schema: Normalized JSON Schema object ready for the provider.schemaOrdered(TS only):Mappreserving exact key order for integer-like property names.reverse: Reverse map used bydenormalize_args/denormalizeArgs.fingerprint: SHA-256 fingerprint covering the original schema, library version,rules_version, and target.
ReportEntry & Severities
Section titled “ReportEntry & Severities”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, anddenormalize_argsrestores 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 ifstrict_fallbackis enabled).
Errors
Section titled “Errors”All errors inherit from SchemaBridgeError:
InvalidInputError: Malformed input tool/schema, or invalid arguments withdenormalize_args(..., strict=True).UnsupportedSchemaError: Raised whenon_unsupported="raise"encounters afatalentry.LimitExceededError: Input exceedsmax_nodesormax_depth.ReverseMismatchError:denormalize_argswas called with areversemap whosefingerprintorrules_versiondoes not match the tool or loaded rules.
CLI (mcp-schema-bridge)
Section titled “CLI (mcp-schema-bridge)”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>.
mcp-schema-bridge check
Section titled “mcp-schema-bridge check”Reports what would change for one or more targets.
mcp-schema-bridge check tools.json --fail-on lossymcp-schema-bridge check --target gemini-json --target openai-strict --stdio -- python my_server.pyFlags: --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).
mcp-schema-bridge normalize
Section titled “mcp-schema-bridge normalize”Prints normalized tools, reverse maps, and reports as JSON (or text).
mcp-schema-bridge normalize tools.json --target anthropic-strict > normalized.jsonFlags: --target, --format {json,text}, --strict-fallback, --no-hints, --stdio, --timeout SECONDS.
mcp-schema-bridge proxy
Section titled “mcp-schema-bridge proxy”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.
mcp-schema-bridge proxy --target gemini-json --report bridge-report.json -- npx -y some-mcp-serverFlags: --target (required), --strict-fallback, --no-hints, --report FILE.
Exit codes
Section titled “Exit codes”0 ok · 1 --fail-on threshold reached (check) · 2 usage error · 3 input, server, or timeout error.