Skip to main content
Glama
data-transformer

data-transformer

by tetracoralla

BatchTicket

BatchTicket (CLI: adt) is a deterministic structured-data transducer for Agent workflows. Like the small ticket that travels with a production or shipping batch, each run carries a versioned plan and an explicit account of what execution changed. That account does not claim the mapping was semantically correct.

It is not another jq or SQL dialect. DuckDB, JSON Schema, PyYAML, and standard parsers own established execution work. This project owns the Agent contract around them.

Version 0.2.0 is an unreleased source release candidate. The project is licensed under the Apache License 2.0. The stable technical identifiers remain agent-data-transformer, data-transformer, adt, and the four data_* MCP tools.

What is implemented

  • Inspect JSON, JSONL, CSV, TSV, YAML, and Parquet without returning full payloads.

  • Discover bounded nested record sets in JSON/YAML envelopes and profile their logical fields.

  • Compare a source record shape with a target JSON Schema, surface only structural mapping candidates, and emit an executable draft plan only after explicit compatible mappings.

  • Safe Transformation Plan v1 with no raw code, SQL, shell, jq, regex, or template execution.

  • Filter, project, drop, rename, sort, limit, deduplicate, cast, derive, explode, join, group, pivot, unpivot, flatten, unflatten, and tree mutation.

  • JSON Schema plus non-null, unique, row-count, field, and type assertions.

  • Schema-aware keyed or unkeyed diff.

  • Dry-run with real destination preflight, staged atomic publication, and overwrite protection.

  • Whole-call worker isolation with cumulative source/byte/row/item/depth/time/RSS/temp limits.

  • A byte ceiling over the complete serialized response, including samples, shapes, execution effects, diffs, validation failures, and errors.

  • One strict typed Plan v1 model generates runtime validation, the published JSON Schema, and the live MCP schema.

  • One shared core with CLI and four task-level MCP tools.

Related MCP server: MCP Data Integration Server

Install and run

Development checkout:

git clone https://github.com/tetracoralla/BatchTicket.git
cd BatchTicket
uv sync --frozen --extra dev
uv run adt inspect examples/users.json --select 'data.users[*]'
uv run adt inspect examples/users.json --select 'data.users[*]' \
  --target-schema target.schema.json --mappings mappings.json
uv run adt transform examples/adults.plan.yaml
uv run adt transform examples/adults.plan.yaml --dry-run
uv run adt validate examples/users.json --select 'data.users[*]' \
  --assertions examples/users.assertions.json
ADT_WORKSPACE_ROOT=/absolute/granted/workspace uv run adt mcp

Build a platform-specific plugin that does not need the repository, uv, a Python installation, or a network connection at runtime:

uv run python scripts/build_plugin.py
uv run python scripts/probe_plugin.py \
  dist/plugin/data-transformer-0.2.0-darwin-arm64
codex plugin marketplace add dist/plugin
codex plugin add data-transformer@data-transformer-local

The build produces a plugin directory, a .tar.gz archive, and a SHA-256 checksum in dist/plugin/. Install or copy the complete generated directory; the repository-root .mcp.json is development configuration, while the generated plugin's .mcp.json invokes its bundled executable directly. The generated local marketplace points Codex at that self-contained directory. Rebuilding with --replace refuses symlinked output roots or generated targets before deleting or overwriting anything.

Each generated bundle contains legal/THIRD_PARTY_NOTICES.md, the copied license texts under legal/licenses/, and legal/sbom.cdx.json. The inventory is built from the locked runtime dependency closure plus the incorporated CPython runtime and PyInstaller bootloader; it is checked again from the archive by the plugin test path. The archive is stable for the same source, lock, and build environment, so its companion SHA-256 file identifies the exact generated bundle.

This local macOS arm64 artifact is not a publication action. A GitHub Release upload, code-signing or notarization decision still requires separate authorization; see the release checklist.

The example transformation returns two records inline and reports through execution_effects that one input row was removed. File output is opt-in through output.path; existing files are never replaced unless output.overwrite is explicitly true.

CLI paths are explicit user paths and may be absolute. MCP file paths are a narrower capability: the server first uses workspaces granted through the MCP roots protocol. A single root is selected automatically; when several roots are granted, pass their exact root name in the tool's optional workspace field. Hosts without roots support may pass an explicit ADT_WORKSPACE_ROOT as a compatibility grant. Tool paths remain relative to the selected root, and absolute, parent, URI, and symlink escapes are rejected. Inline-only MCP calls do not require a workspace grant.

Codex CLI 0.148 does not currently pass MCP roots to local plugin servers. For a cold CLI host test, launch Codex with ADT_WORKSPACE_ROOT set to the exact test workspace. Read-only tools can run under approval=never; data_transform has conditional file-output capability and therefore requires an approval-capable host policy even when a particular call returns data inline. A blocked call is an authorization result, not permission to fall back to shell or model-side data rewriting.

Deterministic schema adaptation

data_inspect accepts an optional target_schema and mappings object. It can select a unique nested record set by structural evidence, suggest exact or normalized-name matches, and report incompatible, missing, duplicated, omitted, or dropped fields. It does not use fuzzy synonyms, casts, or defaults. The v1 adapter maps top-level record fields and supports an object schema or an array whose items is one object schema. Composed/reference schemas and ambiguous record sets remain explicitly unresolved.

When every required field has an explicit compatible mapping, adaptation.status is ready and adaptation.draft_plan is a normal Transformation Plan v1. Run that plan through data_transform; the adapter does not create a separate execution path or fifth public tool.

Library API

Portable Capability provider

capabilities/provider.json binds the read-only data_inspect and data_validate core paths to org.openadam.structured-data.analyze@0.1.0. The JSONL adapter validates the portable request, preserves the same restricted workspace and isolated worker, and projects provider results into the canonical shape and validation contracts. A failed content constraint remains a successful result with valid=false; malformed constraints and execution failures use stable Capability errors.

The v0.2 Provider Manifest declares canonical JSONL adapter targets for inspect and validate separately from the public FastMCP tool targets. Its executable transport schema probe introspects the current data_inspect and data_validate tool schemas, keeping canonical adapter and live transport conformance as separate evidence lanes.

Installed source wheels expose adt-capability and adt-transport-schema-probe. Their canonical schemas are package resources, so neither command depends on a repository checkout or a sibling Procedure. The self-contained plugin exposes the same two interfaces through the runtime/adt-capability and runtime/adt-transport-schema-probe launchers, which reuse one frozen runtime, and ships a release-bound Provider Manifest plus canonical schemas. Installed Hosts can therefore use the Capability without a source checkout, Python environment, package manager, or network access.

from data_transformer import DataTransformer

result = DataTransformer().transform(
    {
        "version": "1",
        "sources": {"rows": {"inline": [{"x": 2}, {"x": 4}]}},
        "steps": [
            {
                "op": "derive",
                "field": "doubled",
                "expr": {"multiply": [{"field": "x"}, {"value": 2}]},
            }
        ],
    }
)

Public calls return status: ok, status: dry_run, or status: error with a stable error.code. Successful transformations expose runtime-observed changes under execution_effects; they do not leak stack traces or DuckDB internals.

See the product model, Transformation Plan v1, and the review contract. Contributions are described in CONTRIBUTING.md, security reports in SECURITY.md, and notable changes in CHANGELOG.md.

Available Tools

4 tools
data_diffA
Read-onlyIdempotent

Compare two structured datasets by schema and rows, optionally using stable key fields. Returns compact added, removed, and changed counts and samples.

Inputs: left (required), right (required), limits, workspace, +2 more.

data_inspectA
Read-onlyIdempotent

Inspect JSON, JSONL, CSV, TSV, YAML, or Parquet shape, types, counts, and a small sample without returning the full payload. Use for 'what fields are in this data?' or unknown tool output. Optionally compare record fields with target_schema and return deterministic mapping candidates; a draft plan is returned only after explicit mappings are supplied. One successful call is sufficient for its recorded observations; never repeat the same arguments to confirm it.

Inputs: source (required), limits, mappings, workspace, +2 more.

data_transformA
DestructiveIdempotent

Transform or rewrite records: reshape, filter, join, aggregate, cast, flatten, or convert structured data with Transformation Plan v1. Do not use this tool for a validation-only request such as checking non-null or unique fields; use data_validate. Known transformation shape: {"version":"1","sources":{"input":{"path":"users.json","select":"data.users[*]"}},"steps":[{"id":"filtered","op":"filter","source":"input","where":{"field":"age","gte":18}},{"op":"select","source":"filtered","fields":[{"field":"userId","as":"id"}]}],"return":{"mode":"auto"}}. Omit workspace with ADT_WORKSPACE_ROOT; otherwise it is an exact granted root name, never a path. Returns a compact sample and explicit execution effects; large results require output.path.

Inputs: plan (required), dry_run, workspace.

data_validateA
Read-onlyIdempotent

Validate or check requirements on existing structured data (校验/检查非空、唯一、类型、字段或行数); choose data_validate, not data_transform, for validation-only requests. It accepts JSON Schema and deterministic assertions and returns valid true or false without rewriting the source. Known validation shape: {"source":{"path":"users.json","select":"data.users[*]"},"assertions":[{"type":"not_null","field":"userId"},{"type":"unique","field":"userId"}]}.

Inputs: source (required), limits, schema, workspace, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool occupies a cleanly separated role: observe (inspect), modify (transform), check (validate), and compare (diff). The overlap risk between transform and validate is explicitly addressed with cross-references steering agents to the right tool. No ambiguity remains after reading the descriptions.

    Naming Consistency5/5

    All tools follow the exact data_<verb> pattern in snake_case with uniform imperative verbs: transform, inspect, validate, diff. The convention is fully predictable with zero deviation.

    Tool Count5/5

    At 4 tools, the surface is tightly scoped with no bloat, comfortably within the ideal range for a focused data utility. Every tool earns its place within the read/validate/write/compare lifecycle.

    Completeness4/5

    Core workflows are fully covered: reading, transforming/writing output, validating, and diffing data, with output paths already handled by the transform tool. Minor gaps like an explicit export/delete or data source listing tool prevent a perfect score, but agents can accomplish all primary tasks.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Detects schema mismatches between data producers and consumers through static analysis, supporting extraction, comparison, code generation, and automated validation with watch mode for MCP tools, APIs, and service contracts.
      11
      55 npm
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables reading, normalizing, validating, merging, and exporting data from Excel, CSV, JSON, and SQLite sources into a unified schema, with tools exposed via FastMCP.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides deterministic tools for understanding, transforming, and verifying structured data via MCP, enabling rule inference from examples and verification of transformed records.
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Enables orchestrating data quality checks, transformation, and deduplication pipelines via an MCP interface. Offers tools for listing pipeline stages, validating wiring, running the full check-transform-match pipeline, and explaining configurations.
      MIT