Skip to main content
Glama

get_sql_examples

Generate example SQL queries for blockchain datasets using DuckDB. Streamline querying and schema inspection for Ethereum data with workflow tips. Enhance efficiency in blockchain data analysis.

Instructions

Get example SQL queries for different blockchain datasets with DuckDB

SQL WORKFLOW TIPS:
1. First download data: result = query_dataset('dataset_name', blocks='...', output_format='parquet')
2. Inspect schema: schema = get_sql_table_schema(result['files'][0])
3. Run SQL: query_sql("SELECT * FROM read_parquet('/path/to/file.parquet')", files=result['files'])

OR use the combined approach:
- query_blockchain_sql(sql_query="SELECT * FROM read_parquet('...')", dataset='blocks', blocks='...')

Returns:
    Dictionary of example queries categorized by dataset type and workflow patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_sql_examples' tool, decorated with @mcp.tool() for registration. It returns a hardcoded dictionary containing categorized example SQL queries for querying blockchain data with DuckDB.
    def get_sql_examples() -> Dict[str, List[str]]:
        """
        Get example SQL queries for different blockchain datasets with DuckDB
        
        SQL WORKFLOW TIPS:
        1. First download data: result = query_dataset('dataset_name', blocks='...', output_format='parquet')
        2. Inspect schema: schema = get_sql_table_schema(result['files'][0])
        3. Run SQL: query_sql("SELECT * FROM read_parquet('/path/to/file.parquet')", files=result['files'])
        
        OR use the combined approach:
        - query_blockchain_sql(sql_query="SELECT * FROM read_parquet('...')", dataset='blocks', blocks='...')
        
        Returns:
            Dictionary of example queries categorized by dataset type and workflow patterns
        """
        return {
            "basic_usage": [
                "-- Option 1: Simple table names (recommended)",
                "SELECT * FROM blocks LIMIT 10",
                "SELECT * FROM transactions LIMIT 10",
                "SELECT * FROM logs LIMIT 10",
                
                "-- Option 2: Using read_parquet() with explicit file paths",
                "SELECT * FROM read_parquet('/path/to/blocks.parquet') LIMIT 10"
            ],
            "transactions": [
                "-- Option 1: Simple table reference",
                "SELECT * FROM transactions LIMIT 10",
                "SELECT block_number, COUNT(*) as tx_count FROM transactions GROUP BY block_number ORDER BY tx_count DESC LIMIT 10",
                
                "-- Option 2: Using read_parquet()",
                "SELECT from_address, COUNT(*) as sent_count FROM read_parquet('/path/to/transactions.parquet') GROUP BY from_address ORDER BY sent_count DESC LIMIT 10",
                "SELECT to_address, SUM(value) as total_eth FROM read_parquet('/path/to/transactions.parquet') GROUP BY to_address ORDER BY total_eth DESC LIMIT 10"
            ],
            "blocks": [
                "SELECT * FROM blocks LIMIT 10",
                "SELECT block_number, gas_used, transaction_count FROM blocks ORDER BY gas_used DESC LIMIT 10",
                "SELECT AVG(gas_used) as avg_gas, AVG(transaction_count) as avg_txs FROM blocks"
            ],
            "balances": [
                "-- IMPORTANT: When querying the balances dataset, use the 'contract' parameter to specify the address",
                "-- First download the data:",
                "# result = query_dataset('balances', blocks='15M:15.01M', contract='0x1234...', output_format='parquet')",
                "-- Then query the data:",
                "SELECT block_number, address, balance_f64 FROM balances ORDER BY block_number",
                "SELECT block_number, balance_f64, balance_f64/1e18 as balance_eth FROM balances ORDER BY block_number"
            ],
            "logs": [
                "SELECT * FROM logs LIMIT 10",
                "SELECT address, COUNT(*) as event_count FROM logs GROUP BY address ORDER BY event_count DESC LIMIT 10",
                "SELECT topic0, COUNT(*) as event_count FROM logs GROUP BY topic0 ORDER BY event_count DESC LIMIT 10"
            ],
            "joins": [
                "-- Join with simple table references",
                "SELECT t.block_number, COUNT(*) as tx_count, b.gas_used FROM transactions t JOIN blocks b ON t.block_number = b.block_number GROUP BY t.block_number, b.gas_used ORDER BY tx_count DESC LIMIT 10",
                
                "-- Join with read_parquet (useful for complex joins)",
                "SELECT l.block_number, l.address, COUNT(*) as log_count FROM read_parquet('/path/to/logs.parquet') l GROUP BY l.block_number, l.address ORDER BY log_count DESC LIMIT 10"
            ],
            "workflow_examples": [
                "-- Step 1: Download data with query_dataset",
                "# result = query_dataset(dataset='blocks', blocks='15000000:15000100', output_format='parquet')",
                "-- Step 2: Get schema info",
                "# schema = get_sql_table_schema(result['files'][0])",
                "-- Step 3: Run SQL query (simple table reference)",
                "# query_sql(query=\"SELECT * FROM blocks LIMIT 10\", files=result.get('files', []))",
                "",
                "-- Or use the combined function",
                "# query_blockchain_sql(sql_query=\"SELECT * FROM blocks LIMIT 10\", dataset='blocks', blocks='15000000:15000100')"
            ],
            "using_dataset_parameters": [
                "-- IMPORTANT: How to check required parameters for datasets",
                "-- Step 1: Look up the dataset to see required parameters",
                "# dataset_info = lookup_dataset('balances')",
                "# This will show: 'required parameters: address'",
                "",
                "-- Step 2: Use the contract parameter for ANY address parameter",
                "# For balances dataset, query_dataset('balances', blocks='1M:1.1M', contract='0x1234...')",
                "# For erc20_transfers, query_dataset('erc20_transfers', blocks='1M:1.1M', contract='0x1234...')",
                "",
                "-- Step 3: Always check the dataset description and schema before querying new datasets",
                "# This helps ensure you're passing the correct parameters"
            ]
        }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly describes the return format ('Dictionary of example queries categorized by dataset type and workflow patterns'), which is helpful. However, it doesn't mention potential limitations like rate limits, authentication needs, or whether the examples are static or dynamically generated. The description doesn't contradict any annotations (none exist).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, workflow tips, combined approach, returns). It's appropriately sized for the complexity, though the workflow tips section is somewhat lengthy for a tool that just returns examples. Every sentence earns its place by providing practical guidance, but it could be slightly more concise by integrating tips more tightly with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (parameterless, no output schema, no annotations), the description is quite complete. It explains the purpose, provides extensive usage guidance, and describes the return format. The only minor gap is lack of explicit behavioral constraints (e.g., whether examples are curated/static), but overall it's well-rounded for this type of helper tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100% (empty schema). The description appropriately doesn't discuss parameters, which is correct for a parameterless tool. It focuses instead on output semantics and usage context, adding value beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get example SQL queries for different blockchain datasets with DuckDB'. It specifies the exact resource (example SQL queries) and distinguishes from siblings like query_sql (executes SQL) or list_datasets (lists datasets). The verb 'Get' is specific and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance through 'SQL WORKFLOW TIPS' and 'OR use the combined approach', detailing when to use this tool (for learning/example queries) versus alternatives like query_sql or query_blockchain_sql (for actual execution). It names specific sibling tools (query_dataset, get_sql_table_schema, query_sql, query_blockchain_sql) and explains their roles in workflows.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/z80dev/cryo-mcp'

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