Skip to main content

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 384 tokens of tool definitions per request, measured — 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. tools/list costs 384 tokens on this build (4 tools, o200k_base). Re-run python scripts/measure_tokens.py to check your own build; the budget is 1,200 and tests/test_tools.py fails above it.


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

Metadata

Release files for mcp-server-milan-datawarehouse 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-milan-datawarehouse 0.1.0
File Size Uploaded Provenance Actions
mcp_server_milan_datawarehouse-0.1.0.tar.gz 10.1 MB Without provenance Details for mcp_server_milan_datawarehouse-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-milan-datawarehouse 0.1.0
File Interpreter ABI Platform Actions
mcp_server_milan_datawarehouse-0.1.0-py3-none-any.whl Python 3 none any Details for mcp_server_milan_datawarehouse-0.1.0-py3-none-any.whl

Total release size: 10.1 MB

Release files / mcp_server_milan_datawarehouse-0.1.0.tar.gz

Download URL mcp_server_milan_datawarehouse-0.1.0.tar.gz
Size 10.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7f5ac42ff60761e16519a97d1fd6620b70242f122396cfffb3c026c30aef10ab
BLAKE2b-256 checksum
How to use checksums
919823c2f37913e103720d2b0a4a1d027e15c4d49313f81337cad8164058413a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mcp_server_milan_datawarehouse-0.1.0-py3-none-any.whl

Download URL mcp_server_milan_datawarehouse-0.1.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df45893237bbb9d09650949ad0d87d21251a20ec4ea0288331b81aeb12c25bcd
BLAKE2b-256 checksum
How to use checksums
c2e8db37b1bc528a372d6dfaff48d7743c4fe2c228d2211460a5d794dae06c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mcp-server-milan-datawarehouse 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page