Skip to main content
Glama

dune_query_fork

Create a copy of an existing Dune Analytics query to modify and analyze blockchain data with Polars-optimized workflows.

Instructions

Fork an existing saved Dune query. Requires SPICE_DUNE_ALLOW_SAVES=true.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_query_idYes
nameNo

Implementation Reference

  • Registration of the dune_query_fork tool using FastMCP @app.tool decorator, which also defines metadata like title, description, and tags.
    @app.tool(
        name="dune_query_fork",
        title="Fork Saved Query",
        description="Fork an existing saved Dune query. Requires SPICE_DUNE_ALLOW_SAVES=true.",
        tags={"dune", "admin"},
    )
  • The handler function for dune_query_fork tool. Initializes services, checks permissions, forks the query via QueryAdminService, logs to history, and handles errors.
    def dune_query_fork(source_query_id: int, name: str | None = None) -> dict[str, Any]:
        _ensure_initialized()
        if CONFIG is None or not CONFIG.allow_saves:
            return error_response(
                ValueError("Saving queries is disabled. Set SPICE_DUNE_ALLOW_SAVES=true to enable."),
                context={"tool": "dune_query_fork", "allow_saves": False}
            )
        assert QUERY_ADMIN_SERVICE is not None
        try:
            result = dict(QUERY_ADMIN_SERVICE.fork(source_query_id, name=name))
            # Log admin action
            if QUERY_HISTORY is not None:
                query_id = result.get("query_id") or source_query_id
                QUERY_HISTORY.record(
                    execution_id=f"fork_{source_query_id}",
                    query_type="query_id",
                    query_preview=f"Forked query {source_query_id}",
                    status="success",
                    duration_ms=0,
                    action_type="admin_action",
                    query_id=query_id,
                    action="fork",
                    source_query_id=source_query_id,
                )
            return result
        except Exception as e:
            # Log error
            if QUERY_HISTORY is not None:
                QUERY_HISTORY.record(
                    execution_id=f"fork_{source_query_id}",
                    query_type="query_id",
                    query_preview=f"Failed to fork query {source_query_id}",
                    status="error",
                    duration_ms=0,
                    action_type="admin_action",
                    query_id=source_query_id,
                    action="fork",
                    error=str(e),
                )
            return error_response(e, context={"tool": "dune_query_fork", "source_query_id": source_query_id})

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Evan-Kim2028/spice-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server