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_SCHEMAis read per database, soALLOWED_SCHEMASmust list every database you want to search.fetch_moreworks 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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_server_milan_datawarehouse-0.1.1.tar.gz | 15.8 kB | Without provenance | Details for mcp_server_milan_datawarehouse-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_server_milan_datawarehouse-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for mcp_server_milan_datawarehouse-0.1.1-py3-none-any.whl |
Total release size: 30.2 kB
Release files / mcp_server_milan_datawarehouse-0.1.1.tar.gz
| Download URL | mcp_server_milan_datawarehouse-0.1.1.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6dd5738df1240303c0412c7bbca00c31cc3fa90056d88f44791f6a1149da1fb
|
|
BLAKE2b-256 checksum How to use checksums |
d78501d198fcc5533a1a254ab34b17dfa56125ae97a57fa283052a7fbca23e3f
|
| 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.1-py3-none-any.whl
| Download URL | mcp_server_milan_datawarehouse-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae4fdfb654e60a3264c58ae060b901281217c756c6e2e15e74e4100557a3bf6a
|
|
BLAKE2b-256 checksum How to use checksums |
b8058fecd0c1b92606e293184cd9f444048281052ff6d1abbad48d6f0b6461b6
|
| 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.1
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.