Skip to main content

duckquery-mcp

An MCP server that exposes a locally-running DuckQuery backend to MCP clients (Claude Code, Cursor, Codex). Start DuckQuery first (desktop app, Docker, or uvicorn main:app --port 48001); this server auto-discovers it.

Run

uvx duckquery-mcp            # zero-install
# or: pipx run duckquery-mcp

Env:

  • DUCKQUERY_API_BASE — explicit backend URL (e.g. http://127.0.0.1:48001). Optional; auto-discovered otherwise (runtime.json, then probes 48001/8000/8001).
  • DUCKQUERY_MCP_MODE — read-only | normal (default) | full.

Add to a CLI

Claude Code:

claude mcp add duckquery -- uvx duckquery-mcp

Cursor / Codex (mcp.json):

{
  "mcpServers": {
    "duckquery": {
      "command": "uvx",
      "args": ["duckquery-mcp"],
      "env": { "DUCKQUERY_MCP_MODE": "normal" }
    }
  }
}

Claude Desktop — add the same mcpServers block to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "duckquery": {
      "command": "uvx",
      "args": ["duckquery-mcp"]
    }
  }
}

Tools

Version 0.4.1 retains the existing tool signatures and safety modes, adds optional column_types/pushdown/warnings to query results, and adds three read-only exploration tools for DuckQuery >=2.1.2:

  • get_column_insights: suggestions from actual field types, without row sampling.
  • discover_json_paths: apply filters before sampling at most 100 rows; paths are not a complete schema.
  • generate_insight_query: generate metrics or JSON-extraction SQL without executing it. Planned pushdown is not evidence of actual execution.

Call get_capabilities before using DuckDB 2.0-specific SQL. run_sql/federated_query retain server classification and the conservative old-backend fallback. Legacy pivot execute=True generates SQL only; it does not create a table. Its existing confirmation gate and write-tier registration are unchanged. Materialization still uses save_as_table with explicit confirmation.

The 0.4.1 wheel and source distribution accompany DuckQuery v2.1.3. To use that exact wheel independently of PyPI publication:

uvx --from https://github.com/Chenkeliang/duckdb-query/releases/download/v2.1.3/duckquery_mcp-0.4.1-py3-none-any.whl duckquery-mcp

The unpinned uvx command uses the version available on PyPI (and its cache). After a PyPI update, use uvx --refresh duckquery-mcp@0.4.1 and reconnect/restart the MCP server. Existing MCP 0.4.0 tools remain compatible with DuckQuery v2.1.3; the Windows packaging repair does not require a client update.

High-level tools (query, the AI agent tools below, discover, add sources, configure LLM, transform, export) plus a generic duckquery_request passthrough. Safety mode gates which tools are exposed:

The AI tools all call the backend's unified Agent Engine (POST /api/ai/agent/run, one thin tool per mode), replacing the removed single-purpose LLM services:

  • ask_agent (mode=data_qa) — conversational data agent. Runs bounded, read-only probe queries — inspecting schemas, verifying real column values, and dry-running row-capped SELECTs — over local tables and, when you pass attach_databases, attached MySQL/PostgreSQL/SQLite/DuckDB tables, before answering. Any returned sql is a draft; the agent never executes writes.
  • generate_sql (mode=generate_sql) — NL → an EXPLAIN-validated SQL draft (not executed).
  • repair_sql (mode=repair_sql) — error doctor: failing SQL + error → a fix.
  • explain_sql (mode=explain_sql) — plain-language explanation of a statement.
  • suggest_chart (mode=suggest_chart) — a chart spec for a result set.

All five are read-tier tools — exposed in every safety mode — and never execute writes.

  • read-only — hides all mutating tools; non-GET duckquery_request calls are hard-blocked (confirm cannot override).
  • normal (default) — mutating tools are exposed, but changing tables, saving connections, importing data, running mutating SQL, and non-GET duckquery_request calls each require confirm=true.
  • full — bypasses the MCP confirmation gates above; backend safeguards still apply.

The AI-settings tools (configure_llm, test_llm_provider) are write-tier: hidden in read-only, and in normal mode they take the same confirm=true parameter as every other write tool.

Publishing (maintainers)

The manual Publish MCP workflow builds/tests the version already merged into main, then publishes through PyPI OIDC without storing an API token in the repository. Configure a Trusted Publisher for the duckquery-mcp PyPI project:

  • GitHub owner: Chenkeliang
  • Repository: duckdb-query
  • Workflow: publish-mcp.yml
  • Environment: pypi

After that one-time PyPI configuration, dispatch the workflow from main with version 0.4.1. The publish job only receives an OIDC token, separate from the build job. Never put publication tokens in issues, release notes or source files.

Metadata

Release files for duckquery-mcp 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duckquery-mcp 0.4.1
File Size Uploaded Provenance Actions
duckquery_mcp-0.4.1.tar.gz 94.0 kB Without provenance Details for duckquery_mcp-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for duckquery-mcp 0.4.1
File Interpreter ABI Platform Actions
duckquery_mcp-0.4.1-py3-none-any.whl Python 3 none any Details for duckquery_mcp-0.4.1-py3-none-any.whl

Total release size: 117.5 kB

Release files / duckquery_mcp-0.4.1.tar.gz

Download URL duckquery_mcp-0.4.1.tar.gz
Size 94.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a7e91669ea70d9c35a3fff8e70e32e02a187f0c0eb4ecbc477a85565ef2f5c
BLAKE2b-256 checksum
How to use checksums
b602bec434b75cd277781c2d723a3c36d4797c1ca0bd9a614c575bd61bac50b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / duckquery_mcp-0.4.1-py3-none-any.whl

Download URL duckquery_mcp-0.4.1-py3-none-any.whl
Size 23.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20f63ddf449ad94bf5e09bacf24d4283179d8c10679d239148150f67f067b04a
BLAKE2b-256 checksum
How to use checksums
3e9f73ae9a013ad1c27877efffa373e1bef067986af107c21d2dc5b52cf5770d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Security for duckquery-mcp 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page