Skip to main content
Glama

dune_query_create

Create and save new Dune Analytics queries with SQL code, names, descriptions, tags, and parameters for blockchain data analysis.

Instructions

Create a new saved Dune query (name + SQL).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
query_sqlYes
descriptionNo
tagsNo
parametersNo

Implementation Reference

  • Registers the 'dune_query_create' tool with FastMCP app using @app.tool decorator, specifying name, title, description, and tags.
    @app.tool( name="dune_query_create", title="Create Saved Query", description="Create a new saved Dune query (name + SQL). Requires SPICE_DUNE_ALLOW_SAVES=true.", tags={"dune", "admin"}, )
  • The handler function for dune_query_create tool. Ensures initialization, checks save permissions, creates the query via QUERY_ADMIN_SERVICE, logs success or failure to QUERY_HISTORY, and returns result or error.
    def dune_query_create(name: str, query_sql: str, description: str | None = None, tags: list[str] | None = None, parameters: list[dict[str, Any]] | 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_create", "allow_saves": False} ) assert QUERY_ADMIN_SERVICE is not None try: result = dict(QUERY_ADMIN_SERVICE.create(name=name, query_sql=query_sql, description=description, tags=tags, parameters=parameters)) # Log admin action if QUERY_HISTORY is not None: query_id = result.get("query_id") if query_id: QUERY_HISTORY.record( execution_id=f"create_{query_id}", query_type="query_id", query_preview=f"Created query: {name}", status="success", duration_ms=0, action_type="admin_action", query_id=query_id, action="create", name=name, ) return result except Exception as e: # Log error if QUERY_HISTORY is not None: QUERY_HISTORY.record( execution_id=f"create_failed", query_type="raw_sql", query_preview=f"Failed to create query: {name}", status="error", duration_ms=0, action_type="admin_action", action="create", name=name, error=str(e), ) return error_response(e, context={"tool": "dune_query_create", "name": name})

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