dune analytics mcp built with spellbooks + dune api
Configuration
View docs{
"mcpServers": {
"evan-kim2028-spice-mcp": {
"command": "spice-mcp",
"args": [],
"env": {
"DUNE_API_KEY": "YOUR_DUNE_API_KEY"
}
}
}
}Spice MCP Server provides a clean, type-safe interface that lets AI agents query Dune Analytics data, discover verified tables, and manage saved queries. It’s designed to be agent-friendly and to minimize memory usage with a lazy, polars-first data pipeline, making it easy to build AI workflows around blockchain datasets.
You connect your MCP client to Spice MCP Server to run queries, discover tables, and manage saved queries. Use the standard MCP client workflow to execute a saved query by ID or URL, discover high-quality tables from Dune Spellbook, and browse table schemas. All actions are exposed as typed endpoints with clear parameter and response shapes, so you can build robust AI prompts and tooling around these capabilities.
Prerequisites you need before installing Spice MCP Server:
- Python 3.13+ to run the server code and install dependencies.
Install the Spice MCP package from PyPI.
pip install spice-mcpSet your Dune API key so Spice MCP Server can access Dune data. You can provide the key via a project environment file or by exporting it in your shell.
echo "DUNE_API_KEY=your-api-key-here" > .env
```
```
export DUNE_API_KEY=your-api-key-hereAdd Spice MCP Server to your MCP client configuration. The server runs as a local process and uses the provided API key to authenticate with Dune. Start the server in your environment and connect your MCP client using the following configuration.
{
"name": "spice-mcp",
"command": "spice-mcp",
"env": {
"DUNE_API_KEY": "your-dune-api-key-here"
}
}Query history logging is enabled by default. Logs are stored in logs/queries.jsonl, or in ~/.spice_mcp/logs/queries.jsonl if you run outside a project directory. You can customize paths by setting SPICE_QUERY_HISTORY and SPICE_ARTIFACT_ROOT environment variables.
Admin actions (create/update/fork/archive/unarchive) are recorded with action_type="admin_action" and include the related query_id for traceability.
Execute queries by ID, URL, or raw SQL with parameters, limits, and formats (preview, raw, metadata, poll).
Retrieve metadata for a saved query by ID or URL.
Unified discovery across Dune API and Spellbook to surface verified, production-ready tables, with optional keyword, schema, limit, and source filters.
Get column metadata for a specified table, including data types and descriptions.
Verify API key and server configuration to ensure connectivity.
Create a new saved query with a name, SQL, description, tags, and parameters.
Update an existing saved query by ID with new name, SQL, description, tags, and parameters.
Fork an existing saved query by source ID to create a new saved query.
Archive a saved query by ID.
Unarchive a saved query by ID.