Skip to content

AI Agents / MCP

DataPress exposes its dataset query surface as MCP (Model Context Protocol) tools, so any MCP-compatible AI agent or LLM application can discover, describe, and query your datasets over a standard JSON-RPC 2.0 streamable-HTTP connection.

Protocol revision: MCP 2025-11-25.

Prerequisites

  1. Build DataPress with the mcp feature:
cargo build --release -p datapress-duckdb --features mcp
  1. Enable the endpoint in datasets.toml:
[mcp]
enabled = true
# path = "/mcp"   # default
  1. Restart the server. The startup log will include:
  /mcp (MCP endpoint):
    POST   /mcp
    DELETE /mcp

Claude Desktop

Add a server entry in ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "datapress": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-fetch"],
      "env": {
        "MCP_SERVER_URL": "http://localhost:8080/mcp"
      }
    }
  }
}

Authentication: if [auth] is enabled with anonymous_read = false, add "Authorization": "Bearer <token>" to the headers env var supported by your fetch server wrapper, or configure Claude Desktop's bearer token.

Claude Code (CLI)

claude mcp add datapress --transport http http://localhost:8080/mcp

With a bearer token:

claude mcp add datapress --transport http http://localhost:8080/mcp \
  --header "Authorization: Bearer $DATAPRESS_TOKEN"

VS Code (GitHub Copilot)

Add to your VS Code settings.json:

{
  "github.copilot.chat.mcp.servers": {
    "datapress": {
      "type": "http",
      "url": "http://localhost:8080/mcp"
    }
  }
}

Verifying the connection

Use the MCP Inspector to test the endpoint manually:

npx @modelcontextprotocol/inspector http://localhost:8080/mcp

The inspector shows the initialize handshake, tools/list result, and lets you invoke each tool interactively.

Available tools

Tool When
list_datasets Always
describe_dataset Always
describe_all_datasets Always
query_dataset Always
count_rows Always
sql Only when [mcp].expose_sql = true AND [sql].enabled = true

Typical agent workflow

  1. Call list_datasets → discover what data exists.
  2. Call describe_dataset (or describe_all_datasets for joins) → get column names and types.
  3. Call count_rows with predicates → check result size before paginating.
  4. Call query_dataset → run structured queries with filters, sorting, and pagination.
  5. Call sql (if enabled) → express joins or complex expressions the structured tool cannot.

Local models (Ollama)

Run DataPress tools with a local model via ollmcp:

# Install ollmcp once
pip install mcp-client-for-ollama   # or: uvx --from mcp-client-for-ollama ollmcp

# Run with qwen3 (recommended: ≥14B or MoE variant for multi-step queries)
uvx --from mcp-client-for-ollama ollmcp \
  --servers-json '{"mcpServers":{"datapress":{"type":"streamable_http","url":"http://localhost:8080/mcp"}}}' \
  --model qwen3:30b-a3b

Or save the server config in a file and reference it:

{
  "mcpServers": {
    "datapress": {
      "type": "streamable_http",
      "url": "http://localhost:8000/mcp"
    }
  }
}
uvx --from mcp-client-for-ollama ollmcp \
  --servers-json-file datapress-mcp.json \
  --model qwen3:30b-a3b

Troubleshooting with Ollama

  • Model calls no tools. Reasoning models with thinking enabled sometimes emit a thinking block but no tool call. Disable thinking with /tm in the chat, or switch to a non-reasoning model.
  • Tool calls fail or truncate. Raise num_ctx to at least 16 000 tokens in the Ollama model file. Multi-step queries with large schemas fill context quickly.
  • Poor multi-step behaviour. Prefer ≥ 14 B parameter or MoE (mixture-of- experts) models — smaller models struggle with the discover → schema → count → query workflow reliably.