Skip to main content
Glama
mcp-server-milan-datawarehouse

mcp-server-milan-datawarehouse

mcp-server-milan-datawarehouse

A read-only MCP server for Snowflake. It lets an LLM explore your warehouse schema and run SELECT queries — and nothing else.

Built for two things: safety by default and low token cost.


Why another Snowflake MCP server

Most database MCP servers dump the whole schema into the tool descriptions. That schema is then re-sent to the model on every request, whether or not a tool is called. This one does the opposite:

Decision

Effect

4 tools, not 30

A few hundred tokens of tool definitions per request, not thousands

Schema discovered on demand (search_schema, describe_table)

No schema in the prompt at all

TSV output instead of JSON

Keys are not repeated per row; typically 60–75% fewer output tokens

100-row default, continue via RESULT_SCAN

The query is not re-run to page; less compute and fewer tokens

Static tool text

The prefix stays cacheable across turns

Run python scripts/measure_tokens.py to see the current cost of tools/list on your build. The budget is 1,200 tokens and tests/test_tools.py fails if it is exceeded.


Related MCP server: Snowflake MCP Server (Read-Only)

Install

uvx mcp-server-milan-datawarehouse

or

pipx install mcp-server-milan-datawarehouse

Requires Python 3.11+.


Configure

Everything comes from environment variables. Copy .env.example and fill it in.

Variable

Required

Purpose

SNOWFLAKE_ACCOUNT

yes

<org>-<account>

SNOWFLAKE_USER

yes*

login name of the read-only service user

SNOWFLAKE_PASSWORD

*

password, if not using key-pair

SNOWFLAKE_PRIVATE_KEY_PATH

*

path to rsa_key.p8 (preferred)

SNOWFLAKE_PRIVATE_KEY_PASSPHRASE

no

passphrase for the key

SNOWFLAKE_CONNECTION_NAME

*

reuse an entry from ~/.snowflake/connections.toml

SNOWFLAKE_ROLE

recommended

the read-only role

SNOWFLAKE_WAREHOUSE

recommended

warehouse to run on

SNOWFLAKE_DATABASE

recommended

default database

SNOWFLAKE_SCHEMA

no

default schema

ALLOWED_SCHEMAS

recommended

DB.SCHEMA,DB.SCHEMA allowlist

MAX_ROWS_HARD_CAP

no

ceiling for max_rows (default 500)

STATEMENT_TIMEOUT

no

seconds, set on every session (default 60)

MCP_TRANSPORT

no

stdio (default) or streamable-http

* exactly one auth method is required: key-pair, password, or connection name.

Key-pair is recommended: it survives MFA enforcement and cannot be replayed.

Client config (Claude Desktop / Cursor)

{
  "mcpServers": {
    "milan-dw": {
      "command": "uvx",
      "args": ["mcp-server-milan-datawarehouse"],
      "env": {
        "SNOWFLAKE_ACCOUNT": "myorg-myaccount",
        "SNOWFLAKE_USER": "DW_MCP_READONLY",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "/Users/me/.snowflake/rsa_key.p8",
        "SNOWFLAKE_ROLE": "DW_MCP_READONLY",
        "SNOWFLAKE_WAREHOUSE": "COMPUTE_WH",
        "SNOWFLAKE_DATABASE": "ANALYTICS",
        "ALLOWED_SCHEMAS": "ANALYTICS.PUBLIC,ANALYTICS.MARTS"
      }
    }
  }
}

Tools

Tool

What it does

search_schema(query, limit=15)

Finds tables/columns by name or comment. One line per table.

describe_table(table, sample_rows=0)

Columns as TSV: name, type, nullable, comment. Optional ≤5 sample rows.

run_query(sql, max_rows=100)

Runs one read-only statement. Returns TSV.

fetch_more(cursor_id, offset=0, max_rows=100)

Pages a truncated result via RESULT_SCAN.

Output contract

One header line, then one row per line, tab-separated. NULL is an empty cell. Dates are ISO-8601, decimals keep at most 6 places, cells over 200 characters are truncated with …, columns that are entirely null are dropped. The executed SQL is never echoed back. When a result is cut, the last line starts with # and carries the cursor_id needed to continue.

order_id	city	amount
1001	Tehran	12500
1002	Karaj	8300.5
# truncated at 2 rows; fetch_more(cursor_id="01b2c3d4-...")

Security model

Two layers, and only the second one is a real boundary.

Layer 1 — the SQL guard (guard.py). One statement only. Comments are stripped, string literals and quoted identifiers are masked before keyword scanning, and the statement must start with SELECT, WITH, EXPLAIN, SHOW, DESCRIBE or DESC. Anything containing INSERT, UPDATE, DELETE, MERGE, CREATE, DROP, ALTER, TRUNCATE, GRANT, REVOKE, COPY, PUT, GET, CALL, USE, COMMIT and friends is rejected. Every session also sets STATEMENT_TIMEOUT_IN_SECONDS and a QUERY_TAG so runaway queries and their origin are visible in QUERY_HISTORY.

Layer 2 — the role. This is what actually protects your warehouse. Use a role that cannot write:

CREATE ROLE DW_MCP_READONLY;
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE DW_MCP_READONLY;
GRANT USAGE ON DATABASE ANALYTICS TO ROLE DW_MCP_READONLY;
GRANT USAGE ON SCHEMA ANALYTICS.PUBLIC TO ROLE DW_MCP_READONLY;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS.PUBLIC TO ROLE DW_MCP_READONLY;
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS.PUBLIC TO ROLE DW_MCP_READONLY;
GRANT ROLE DW_MCP_READONLY TO USER DW_MCP_READONLY;

The guard is a guard rail for mistakes, not a sandbox. If you run this server with an account that can write, nothing here will stop it. Do not do that.

For the strongest posture, point the server at secure views instead of base tables, and never at a schema containing PII.


Limits

  • Only objects created with unquoted (upper-case) identifiers are found; quoted lower-case identifiers are not supported.

  • INFORMATION_SCHEMA is read per database, so ALLOWED_SCHEMAS must list every database you want to search.

  • fetch_more works within Snowflake's result-retention window (24h by default).

  • No write path, by design. There is no plan to add one.

Development

git clone https://github.com/Saideh-Heshmati/mcp-server-milan-datawarehouse
cd mcp-server-milan-datawarehouse
pip install -e ".[dev]"
pytest
python scripts/measure_tokens.py

Tests need no Snowflake account — the connector is stubbed.

License

MIT

Available Tools

4 tools
describe_tableC

Columns of one table as TSV: name, type, nullable, comment.

Inputs: table (required), sample_rows. Returns: result

fetch_moreC

Continue a truncated result using its cursor_id.

Inputs: cursor_id (required), offset, max_rows. Returns: result

run_queryA

Run one read-only SELECT/WITH query. Returns TSV: header then rows.

Inputs: sql (required), max_rows. Returns: result

search_schemaB

Search table and column names in allowed schemas. One line per match.

Inputs: query (required), limit. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool occupies a distinct step in the read-only query lifecycle: discovery (search_schema), structure inspection (describe_table), execution (run_query), and pagination (fetch_more). The boundary between run_query and fetch_more is made explicit by the cursor_id reference, so misselection is unlikely.

    Naming Consistency5/5

    All four tools follow a consistent snake_case verb_noun pattern (search_schema, describe_table, run_query, fetch_more). Verb choices are distinct and accurately describe the action.

    Tool Count5/5

    Four tools is a tight, well-scoped surface for a read-only data warehouse inspector; each tool corresponds to a necessary stage of schema discovery and querying. No tool feels redundant or missing at this count.

    Completeness4/5

    The read-only lifecycle is fully covered: find tables/columns, inspect structure, execute SELECT/WITH, and paginate truncated results. Minor gaps remain—no way to enumerate schemas/tables directly or inspect keys, constraints, and indexes beyond column metadata.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables AI assistants to securely connect to Snowflake data warehouses and execute SQL queries through natural language interactions. Supports multiple authentication methods and provides formatted query results with built-in security controls.
      1
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only interaction with Snowflake databases through SQL queries, schema exploration, and data insight tracking. Provides tools to query data, list databases/schemas/tables, describe table structures, and maintain a memo of discovered insights.
      GPL 3.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to execute SQL queries and explore Snowflake databases using natural language, with schema discovery, table inspection, and readonly mode.
      11
      145 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only querying of Snowflake databases through Claude, supporting multiple authentication methods and SQL operations like SELECT, SHOW, DESCRIBE.
      14
      MIT