Datagrunt 5.8.0: Unified CLI and Zero-SDK Vertex AI Routing

December 2, 2026by Martin Graham

Datagrunt 5.8.0 is now available! This minor release expands the top-level datagrunt command into a unified, lazy-loaded CLI spanning tabular data, DuckDB SQL, deterministic PDF workflows, schema-driven rationalization, the self-hosted MCP server, and the standalone agent — alongside zero-SDK Google Cloud Vertex AI credential resolution and hardened remote read-tool auto-approvals (PR #531).


Highlights in Datagrunt 5.8.0

  1. Unified datagrunt CLI with Eight Subcommands (datagrunt.cli) — Introduces inspect, sample, query, convert, pdf, and rationalize alongside mcp and agent, while keeping datagrunt --help and datagrunt --version completely free of eager optional or heavy imports (polars, duckdb, pyarrow, mcp, pydantic, httpx, httpx2, anyio, pypdfium2).
  2. Deterministic Local Tabular & DuckDB SQL Subcommands — Reuses datagrunt.mcp.tools and PathSandbox under local CLI defaults (1 GiB max_file_bytes, Parquet/XLSX bomb guards, read-only DuckDB SQL, atomic os.O_NOFOLLOW file writes, and symlink destination refusal).
  3. CLI PDF Extraction & Schema-Driven Rationalization — Adds datagrunt pdf (markdown, elements, export, corpus, inspect-corpus) and datagrunt rationalize with dynamic Pydantic schema loading (module.path:ClassName or path/to/schema.py:ClassName) and multi-family consensus support.
  4. Shared Zero-SDK Google Cloud Vertex AI Auth (_vertex_auth) — Routes gemini:<model> and anthropic:<model> through Vertex AI (--vertex-project, --vertex-location) or Vertex Express (--vertex-express for Gemini) across both datagrunt rationalize and datagrunt agent, resolving tokens via google.auth ADC or a trusted gcloud binary on absolute PATH directories.
  5. Hardened --allow-remote-reads for datagrunt agent — Allows datagrunt agent (and datagrunt-agent) to auto-approve Datagrunt’s 6 built-in read-only tools on remote MCP servers only when server annotations confirm readOnlyHint=True (and not destructiveHint=True) and definition_sha256 stays pinned for the session.

1. Unified Lazy-Loaded datagrunt CLI

Running datagrunt --help or datagrunt --version dispatches solely through datagrunt.cli:main without importing polars, duckdb, pyarrow, mcp, pydantic, httpx, httpx2, anyio, or pypdfium2. If you invoke a subcommand whose optional extra is missing (such as datagrunt rationalize without [pdf,rationalize]), the CLI exits cleanly with exit code 2 and prints the exact uv pip install command.

# Inspect CSV/TSV (delimiter, schema), Excel (sheets), Parquet, or PDF metadata
datagrunt inspect sales.csv
datagrunt inspect workbook.xlsx --sheet 1 --json

# Preview bounded tabular rows (table, json, jsonl, csv)
datagrunt sample sales.csv -n 10 --normalize-columns --format table

# Run read-only DuckDB SQL over any CSV, Excel, Parquet, or PDF file (table alias: data)
datagrunt query sales.csv "SELECT region, SUM(amount) AS total FROM data GROUP BY 1" --format json

# Convert CSV, TSV, Excel, or Parquet files to CSV, Excel, JSON, JSONL, or Parquet
datagrunt convert sales.csv out.parquet --normalize-columns
datagrunt convert workbook.xlsx sheets.csv --all-sheets

Key safety and ergonomics behaviors built into datagrunt._cli_data:

  • Read-only DuckDB SQL & stdin queries: datagrunt query accepts - to read SQL from stdin, enforces --limit between 1 and 10,000 (exiting 2 outside bounds), warns on stderr when output is truncated, and delegates to the hardened single-statement DuckDB executor.
  • Safe atomic writes & symlink refusal: Writing via query -o, pdf markdown -o, convert, or pdf export resolves only the parent directory, refuses symlinked output destinations (even with --overwrite), writes atomically through an O_NOFOLLOW temp file with fsync + os.replace, and preserves existing POSIX file permissions on --overwrite.
  • No silent .tsv delimiter mismatches: datagrunt convert intentionally excludes .tsv from output extension inference so comma-delimited CSV is never silently written to a .tsv path without an explicit --format.

You can also invoke the dispatcher programmatically in Python via datagrunt.cli.main:

import io
from datagrunt.cli import main

stdout = io.StringIO()
stderr = io.StringIO()
exit_code = main(["--version"], stdout=stdout, stderr=stderr)
print(exit_code, stdout.getvalue().strip())

2. datagrunt pdf & datagrunt rationalize

All deterministic v5 PDF capabilities and schema-driven rationalization are now first-class CLI commands:

# PDF extraction, Markdown rendering, bundles, and corpora (requires [pdf])
datagrunt pdf markdown report.pdf -o report.md
datagrunt pdf elements report.pdf --kind table --format jsonl
datagrunt pdf export report.pdf ./report_bundle --format bundle
datagrunt pdf corpus ./pdfs -o ./corpus --render-pages vision_only
datagrunt pdf inspect-corpus ./corpus --json

For schema-driven extraction with datagrunt rationalize (requires [pdf,rationalize]), point --schema at either an importable module.path:ClassName or a standalone path/to/schema.py:ClassName file defining a Pydantic BaseModel subclass:

# schemas.py
from typing import Annotated
from pydantic import BaseModel
from datagrunt import Key


class PartMention(BaseModel):
    part_number: Annotated[str, Key("part")]
    description: str
    quantity: int
# Schema-driven PDF rationalization with repeatable --model flags for multi-family consensus
datagrunt rationalize ./corpus \
  --schema schemas.py:PartMention \
  --prompt "Extract BOM parts" \
  --model gemini:gemini-2.5-pro \
  --vertex-project my-gcp-proj \
  --vertex-location global \
  -o parts.jsonl

_load_schema_class() registers file-based schema modules in sys.modules before execution and runs model_rebuild() so schemas using from __future__ import annotations and forward references resolve cleanly. Passing --out (-o) writes full provenance JSONL via result.to_jsonl(), while omitting -o or passing --json prints the structured summary, extracted records, and result.telemetry.to_dict() to stdout.


3. Zero-SDK Google Cloud Vertex AI Auth & Express Mode

Datagrunt 5.8.0 introduces a shared credential and target resolver (datagrunt._llm._vertex_auth) used by both datagrunt rationalize and datagrunt agent (datagrunt-agent) — with zero vendor SDK dependencies:

# Route Gemini or Claude through Google Cloud Vertex AI directly from the CLI
datagrunt agent \
  --model gemini:gemini-2.5-pro \
  --vertex-project my-gcp-proj \
  --vertex-location global \
  --root ./data \
  "Summarize sales.csv"

datagrunt agent \
  --model anthropic:claude-sonnet-4-6 \
  --vertex-project my-gcp-proj \
  --vertex-location us-east5 \
  --root ./data \
  "Summarize sales.csv"

When --vertex-project (or DATAGRUNT_VERTEX_PROJECT / DATAGRUNT_AGENT_VERTEX_PROJECT) is set, credentials resolve automatically in two steps:

  1. google.auth ADC (if installed): Obtains Application Default Credentials for the cloud-platform scope and refreshes expired tokens under a threading.Lock.
  2. gcloud CLI fallback: If google-auth is unavailable or unconfigured, locates gcloud strictly in absolute directories on PATH (never the current working directory and never with shell=True), invokes gcloud auth application-default print-access-token (falling back to gcloud auth print-access-token), and caches tokens in memory for 5 minutes.

For Gemini models using Vertex AI Express mode, pass --vertex-express alongside GOOGLE_CLOUD_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY. Invalid combinations — such as pairing --vertex-project with --vertex-express, combining Vertex flags with --base-url, or passing --vertex-express with anthropic:<model> or openai:<model> — fail closed with explicit validation errors. On datagrunt agent, an explicit --vertex-express flag overrides DATAGRUNT_AGENT_VERTEX_PROJECT cleanly.


4. Hardened --allow-remote-reads for datagrunt agent

When connecting datagrunt agent to a self-hosted remote Streamable HTTP MCP server, remote tools previously defaulted to requiring interactive or --approve-writes confirmation because only the in-process server’s tool definitions are allowlisted by default.

Datagrunt 5.8.0 adds --allow-remote-reads (and --no-allow-remote-reads / DATAGRUNT_AGENT_ALLOW_REMOTE_READS) backed by ApprovalRequest.raw_annotations in datagrunt.agent.security and datagrunt.agent.loop:

export DATAGRUNT_AGENT_MODEL="anthropic:claude-sonnet-4-5"
export DATAGRUNT_AGENT_MCP_URL="https://mcp.example.com/mcp"
export MCP_AUTH_HEADER="Bearer $DATAGRUNT_MCP_AUTH_TOKEN"

datagrunt agent \
  --mcp-header-env "Authorization=MCP_AUTH_HEADER" \
  --allow-remote-reads \
  --json \
  --trace-out trace.json \
  "Inspect Q4 files"

Remote auto-approval enforces three invariants simultaneously:

  1. The tool name must be one of Datagrunt’s 6 built-in read-only tools (BUILTIN_DATAGRUNT_READ_TOOLS: list_files, inspect_file, read_sample, query_file, pdf_extract_elements, pdf_to_markdown).
  2. Remote server annotations must explicitly confirm readOnlyHint=True and must not set destructiveHint=True.
  3. The tool’s definition_sha256 is pinned per (server_id, tool_name) on first approval — if the remote server mutates a tool definition mid-session, auto-approval is refused.

You can also configure and run DatagruntAgent directly in Python:

from pathlib import Path
from pydantic import BaseModel
from datagrunt.agent import AgentConfig, DatagruntAgent, InProcessMCPTarget
from datagrunt.mcp import MCPServerConfig


class SalesSummary(BaseModel):
    total_amount: float
    top_region: str


config = AgentConfig(
    model="openai:gpt-4o",
    mcp_target=InProcessMCPTarget(MCPServerConfig(roots=(Path("./data"),))),
    max_steps=15,
    timeout_s=120.0,
)
with DatagruntAgent(config, output_schema=SalesSummary) as agent:
    result = agent.run("Compute total sales and top region from sales.csv")
    print(result.output)

Getting Started with Datagrunt 5.8.0

Install or upgrade with uv:

# Core library + unified tabular CLI (inspect, sample, query, convert)
uv pip install --upgrade datagrunt

# Add deterministic PDF CLI & Python APIs
uv pip install --upgrade "datagrunt[pdf]"

# Add schema-driven PDF rationalization
uv pip install --upgrade "datagrunt[pdf,rationalize]"

# Add the self-hosted MCP server or standalone agent
uv pip install --upgrade "datagrunt[mcp,pdf]"
uv pip install --upgrade "datagrunt[agent,pdf]"

Or with pip:

pip install --upgrade datagrunt

Explore the new Unified CLI & Standalone Agent Guide and the MCP Server Guide for complete flag tables, environment variables, and security defaults.