Skip to main content

MCP server for Preset (Superset) — manage dashboards, charts, and datasets from Claude Code and other LLM agents

Project description

preset-mcp

MCP server for Preset (managed Apache Superset). Manage dashboards, charts, and datasets from Claude Code and other LLM agents.

Claude Code ──STDIO──> preset-mcp ──> Preset API

Setup for Claude Code

1. Get your Preset API credentials

  1. Log in to app.preset.io
  2. Go to Settings > API Keys
  3. Create a new token/secret pair
  4. Copy both the token and secret

2. Install and register (one command)

The simplest setup — uv run handles installation automatically:

claude mcp add --scope user preset-mcp -- \
  uv run --from preset-mcp \
    --with preset-cli --with fastmcp --with sqlglot --with pydantic \
    env PRESET_API_TOKEN=<your-token> PRESET_API_SECRET=<your-secret> \
    preset-mcp

To auto-connect to a specific workspace on startup, add the PRESET_WORKSPACE variable:

claude mcp add --scope user preset-mcp -- \
  uv run --from preset-mcp \
    --with preset-cli --with fastmcp --with sqlglot --with pydantic \
    env PRESET_API_TOKEN=<your-token> \
        PRESET_API_SECRET=<your-secret> \
        PRESET_WORKSPACE="Your Workspace Title" \
    preset-mcp

3. Verify

claude mcp list
# Should show: preset-mcp  ... 16 tools

Then in a Claude Code session, try:

> list my preset workspaces

Alternative: Install from source

git clone https://github.com/Evan-Kim2028/preset-mcp.git
cd preset-mcp
uv sync

claude mcp add --scope user preset-mcp -- \
  uv run --directory /path/to/preset-mcp \
    env PRESET_API_TOKEN=<your-token> PRESET_API_SECRET=<your-secret> \
    preset-mcp

Tools (16)

Workspace Navigation

Tool Purpose
list_workspaces List all workspaces you have access to
use_workspace Switch to a workspace by title

Read

Tool Purpose
list_dashboards List dashboards (with progressive disclosure)
get_dashboard Get full detail for a single dashboard
list_charts List charts
list_datasets List datasets
list_databases List database connections
workspace_catalog Relationship-aware topology map

Create

Tool Purpose
create_dashboard Create a new empty dashboard
create_dataset Register a SQL query as a virtual dataset
create_chart Build a chart from a dataset

Update

Tool Purpose
update_dataset Change a dataset's SQL, name, or description
update_chart Change a chart's title, viz type, or parameters
update_dashboard Rename or publish/unpublish a dashboard

SQL & Audit

Tool Purpose
run_sql Execute a read-only query through Preset's connection
snapshot_workspace Full inventory dump for auditing

Typical Workflow

The intended workflow pairs preset-mcp with a data warehouse MCP (like igloo-mcp for Snowflake):

1. Explore data in Snowflake          (igloo-mcp)
2. Write and validate your SQL         (igloo-mcp)
3. workspace_catalog                   (preset-mcp) — understand what exists
4. list_databases                      (preset-mcp) — find the database_id
5. create_dataset                      (preset-mcp) — register the SQL
6. create_chart + create_dashboard     (preset-mcp) — build the viz
7. update_dataset / update_chart       (preset-mcp) — iterate

Features

Progressive Disclosure

All list tools accept a response_mode parameter to control token usage:

  • compact — IDs and names only (~80% fewer tokens)
  • standard (default) — Key metadata fields
  • full — Raw API response
list_dashboards(response_mode="compact")
→ {"count": 42, "data": [{"id": 1, "dashboard_title": "Revenue"}, ...]}

SQL Safety

run_sql uses sqlglot for AST-based validation:

  • Blocks write operations (INSERT, UPDATE, DELETE, DROP, ALTER, MERGE, TRUNCATE, GRANT, REVOKE)
  • Detects multi-statement injection (SELECT 1; DROP TABLE x)
  • Handles comment-wrapped bypasses (-- comment\nDELETE FROM x)
  • Catches CTE-wrapped writes (WITH x AS (...) DELETE FROM y)

Structured Errors

Errors include error_type and hints[] so the LLM can self-recover:

{
  "error": "No workspace selected.",
  "error_type": "no_workspace",
  "hints": [
    "Call list_workspaces to see available workspaces.",
    "Then call use_workspace('Title') to select one."
  ]
}

Structured Logging

JSON logs on stderr (stdout is reserved for the STDIO transport):

{"ts":"2025-02-11 12:00:00","level":"INFO","msg":"tool=list_dashboards status=ok duration_ms=234"}

Configuration

All settings are overridable via environment variables:

Variable Default Purpose
PRESET_API_TOKEN (required) Preset API token
PRESET_API_SECRET (required) Preset API secret
PRESET_WORKSPACE (optional) Auto-connect to this workspace
PRESET_MCP_SQL_ROW_LIMIT 1000 Max rows from SQL queries
PRESET_MCP_SQL_SAMPLE_ROWS 5 Rows shown in standard mode
PRESET_MCP_TRUNCATION_THRESHOLD 50 Full-mode truncation cutoff
PRESET_MCP_TRUNCATION_TAIL 5 Tail rows kept when truncating
PRESET_MCP_LOG_LEVEL INFO Logging verbosity

Python Library

preset-mcp also works as a standalone Python library (no MCP required):

from preset_py import connect

ws = connect("My Workspace")
dashboards = ws.dashboards()
df = ws.run_sql("SELECT * FROM revenue LIMIT 10", database_id=1)

ws.create_dataset("daily_revenue", "SELECT ...", database_id=1)
ws.create_chart(dataset_id=5, title="Revenue", viz_type="echarts_timeseries_bar")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

preset_mcp-0.1.0.tar.gz (139.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

preset_mcp-0.1.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file preset_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: preset_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 139.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for preset_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 00f54d6c3bf85139626553abd5c6873aecce6100f6a33c49e886eff1ed5e46d7
MD5 3e88422377e4f521526e8e2b3d7545ed
BLAKE2b-256 eb7fde9b295c14f32c68fe221610d5c6b7aed9584c278807ff4f6668206e5ebb

See more details on using hashes here.

File details

Details for the file preset_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: preset_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for preset_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff9161a8b6290abc148664b3ee898f04adbfbf809c030a7aa76a4b3bb201a477
MD5 b75521e1a5006fb1b03288658ac7da9c
BLAKE2b-256 1dba35861d3bcc4681bf4855ba14b6f42b723b41af807195dc985f02fdcb4219

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page