Skip to main content
Glama
YannBrrd

Simple Snowflake MCP

by YannBrrd

execute-snowflake-sql

Run SQL queries on Snowflake and retrieve results directly through the Simple Snowflake MCP Server, designed to operate behind corporate proxies.

Instructions

Execute a SQL query on Snowflake and return the result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute

Implementation Reference

  • Handler logic for the 'execute-snowflake-sql' tool: parses arguments, executes SQL via helper, formats output in json/markdown/csv, returns TextContent.
    elif name == "execute-snowflake-sql":
        sql = args.get("sql")
        format_type = args.get("format", "json")
        if not sql:
            raise ValueError("'sql' parameter is required")
        
        result = _safe_snowflake_execute(sql, "SQL execution")
        if result["success"]:
            if format_type == "markdown" and isinstance(result["data"], list):
                output = _format_markdown_table(result["data"])
            elif format_type == "csv" and isinstance(result["data"], list):
                if result["data"]:
                    import csv, io
                    output_buffer = io.StringIO()
                    writer = csv.DictWriter(output_buffer, fieldnames=result["data"][0].keys())
                    writer.writeheader()
                    writer.writerows(result["data"])
                    output = output_buffer.getvalue()
                else:
                    output = "No data returned"
            else:
                output = json.dumps(result["data"], indent=2, default=str)
            return [types.TextContent(type="text", text=output)]
        else:
            return [types.TextContent(type="text", text=f"Snowflake error: {result['error']}")]
  • Input JSON schema for the tool defining 'sql' (required string) and 'format' (optional enum: json/markdown/csv).
    inputSchema={
        "type": "object",
        "properties": {
            "sql": {
                "type": "string", 
                "description": "SQL query to execute",
                "minLength": 1,
                "examples": ["SELECT CURRENT_TIMESTAMP()", "SHOW DATABASES"]
            },
            "format": {
                "type": "string",
                "enum": ["json", "markdown", "csv"],
                "default": "json",
                "description": "Output format for results"
            }
        },
        "required": ["sql"],
        "additionalProperties": False
    },
  • Tool registration in @server.list_tools() return list, including name, description, and input schema.
    types.Tool(
        name="execute-snowflake-sql",
        description="Execute a SQL query on Snowflake and return the result as JSON",
        inputSchema={
            "type": "object",
            "properties": {
                "sql": {
                    "type": "string", 
                    "description": "SQL query to execute",
                    "minLength": 1,
                    "examples": ["SELECT CURRENT_TIMESTAMP()", "SHOW DATABASES"]
                },
                "format": {
                    "type": "string",
                    "enum": ["json", "markdown", "csv"],
                    "default": "json",
                    "description": "Output format for results"
                }
            },
            "required": ["sql"],
            "additionalProperties": False
        },
    ),
  • Helper function that performs the actual Snowflake connection, query execution, result fetching, and error handling used by the tool.
    def _safe_snowflake_execute(query: str, description: str = "Query") -> Dict[str, Any]:
        """
        Safely execute a Snowflake query with proper error handling and logging.
        """
        try:
            logger.info(f"Executing {description}: {query[:100]}...")
            ctx = snowflake.connector.connect(**SNOWFLAKE_CONFIG)
            cur = ctx.cursor()
            cur.execute(query)
            
            # Handle different query types
            if cur.description:
                rows = cur.fetchall()
                columns = [desc[0] for desc in cur.description]
                result = [dict(zip(columns, row)) for row in rows]
            else:
                result = {"status": "success", "rowcount": cur.rowcount}
                
            cur.close()
            ctx.close()
            logger.info(f"{description} completed successfully")
            return {"success": True, "data": result}
            
        except Exception as e:
            logger.error(f"{description} failed: {str(e)}")
            return {"success": False, "error": str(e), "data": None}
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Execute a SQL query' implies a write operation could occur, the description doesn't specify whether this tool supports read-only queries, requires specific permissions, has transaction implications, or includes any rate limits. It provides minimal behavioral context beyond the basic action.

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

Conciseness5/5

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

The description is extremely concise - a single sentence that directly states the tool's function. There's zero wasted language, and it's front-loaded with the essential information. Every word earns its place in this minimal description.

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

Completeness2/5

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

For a SQL execution tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'return the result' means - whether it's a data table, success/failure status, or something else. Given the complexity of database operations and the lack of structured metadata, the description should provide more complete context about behavior and outputs.

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

Parameters3/5

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

The schema description coverage is 100%, with the single parameter 'sql' clearly documented as 'SQL query to execute'. The description adds no additional parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Execute a SQL query') and target resource ('on Snowflake'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from sibling tools like 'execute-query' or 'query-view', which appear to have similar functions.

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

Usage Guidelines2/5

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

The description provides no guidance about when to use this tool versus alternatives like 'execute-query' or 'query-view'. There's no mention of prerequisites, limitations, or appropriate contexts for selecting this specific SQL execution tool over others in the sibling set.

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/YannBrrd/simple_snowflake_mcp'

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