Skip to main content
Glama

Transpile Python Data Models to Polyglot Schemas

transpile_model_bridge
Read-onlyIdempotent

Generate TypeScript interfaces, Rust structs, or Go structs from Python @dataclass and Pydantic models deterministically via AST, enabling cross-language type schemas.

Instructions

Transpiles Python @dataclass and Pydantic data models into TypeScript interfaces, Rust structs, and Go structs deterministically via AST, distinguishing from 'prune_code_snippet' and 'generate_architecture_blueprint' by generating concrete cross-language type schemas rather than pruning code or diagramming topologies.

Parameters:

  • file_path (str, required): Path to the Python file containing @dataclass or Pydantic model definitions.

  • target_lang (str, optional, default='ts'): Target programming language: 'ts' (TypeScript), 'rust' (Rust with serde), 'go' (Golang), or 'all' (all languages).

Behavior:

  • Mutability: Read-only static AST inspection; does not modify source files on disk.

  • Idempotency: Produces identical type definitions for identical source model input.

  • Performance & Latency: Completes model transpilation in <40ms; consumes <30MB RAM.

  • Privacy: 100% offline local AST parsing; zero external network calls.

  • Auth & Limits: Zero external credentials or API keys required; zero rate limits.

  • Error Handling: Gracefully reports missing file or syntax error without crashing.

Usage Guidelines:

  • When to use: Use when transpiling Python @dataclass and Pydantic models into TypeScript interfaces, Rust structs, or Go structs deterministically via AST.

  • When NOT to use: Do not use for generic Python to JavaScript logic compilation (use specialized external compilers instead); do not use for high-level Mermaid architecture diagrams (use 'generate_architecture_blueprint' instead).

Returns: Formatted Markdown report containing transpiled type definitions in the requested target language.

Input Schema

NameRequiredDescriptionDefault
file_pathYesPath to Python file containing data models.
target_langNoTarget language: 'ts', 'rust', 'go', or 'all' (default: 'ts').ts

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv10.6.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and openWorldHint=false, so the Mutability and Idempotency bullets largely restate structured data. The genuinely additive parts are the performance envelope (<40ms, <30MB), the offline/no-network privacy guarantee, zero auth/rate limits, and graceful error handling for missing files or syntax errors — all useful behavior an agent cannot get from the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The front-loaded purpose sentence and sectioned layout are readable, but content is repeated: the "When to use" bullet restates the opening sentence nearly verbatim, and the Behaviors section re-asserts read-only and idempotent traits already covered by annotations. Trimming those duplicates would roughly halve the length without losing signal.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a two-parameter, read-only tool with an output schema, every decision an agent needs is present: what input file must contain, which target languages exist, that output is a Markdown report, and that failures are reported rather than thrown. Nothing material is left to inference.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters are already documented, and the description's parameter block mostly mirrors the schema. It adds one small increment — that 'rust' means Rust with serde — but does not clarify what happens on unsupported values or which model kinds (dataclass vs Pydantic) are transcribed when both are present.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb (transpiles) and precise resource (Python @dataclass/Pydantic models) and enumerates the exact outputs (TypeScript interfaces, Rust structs, Go structs). It explicitly distinguishes itself from two named siblings, 'prune_code_snippet' and 'generate_architecture_blueprint', so an agent can route correctly without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides an explicit "When to use" statement and a "When NOT to use" block that names the alternatives ('generate_architecture_blueprint' for Mermaid diagrams, external compilers for generic Python-to-JS logic). The only soft spot is that "specialized external compilers" is not a concrete named alternative, but the routing condition is still unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.