sql-server-mcp
A local MCP server for read-only SQL Server / MS Fabric queries. Runs as a single-user process over stdio, authenticated as you (delegated Entra ID identity, not a service principal) — one server process per tenant.
Prerequisites
- Python 3.14+ and uv
- Either the Azure CLI logged in to the target tenant (
az login --tenant <tenant-id>), or just a browser available — the server falls back to an interactive browser login if there's no CLI session - An Entra ID account in the target tenant with read access to the target database (e.g.
db_datareader)
Configuration
Each tenant gets its own set of environment variables:
| Variable | Required | Description |
|---|---|---|
MCP_SQL_SERVER_NAME |
yes | SQL Server / Fabric SQL endpoint hostname, e.g. xyz-xyz.datawarehouse.fabric.microsoft.com |
MCP_SQL_DATABASE_NAME |
yes | Default database to connect to |
MCP_AZURE_TENANT_ID |
yes, unless using SQL login | The Entra ID tenant ID — pins auth to this directory even if your machine has other az login sessions active |
MCP_SQL_USERNAME |
no | SQL login username. If set, the server uses username + password authentication instead of Entra ID (and MCP_AZURE_TENANT_ID is not needed) |
MCP_SQL_PASSWORD |
with username | SQL login password. Must be set together with MCP_SQL_USERNAME |
MCP_SQL_TRUST_SERVER_CERTIFICATE |
no | Set to true to skip server certificate validation (needed for servers with self-signed or otherwise untrusted certificates, e.g. older on-prem SQL Server). Default: false |
MCP_SQL_LEGACY_TLS |
no | Set to true for old SQL Server hosts (e.g. SQL Server 2012) that reset the connection during the TLS handshake (TCP Provider: Error code 0x2746). Lowers OpenSSL's security level to 0 for this process (and its child processes), so it requires SQL login and is best avoided elsewhere. Default: false |
MCP_MAX_ROWS |
no | Max rows returned per tool call (default: 25) |
Running it
The server is a uvx-runnable console script (sql-server-mcp), no
manual install step needed - uvx builds an isolated environment for it
on first run and reuses it afterwards:
uvx sql-server-mcp
To run from a local checkout instead (e.g. during development), point
--from at the path:
uvx --from /path/to/sql-server-mcp sql-server-mcp
On startup it acquires a token (via az login if available, otherwise an
interactive browser prompt) and runs over stdio. Database connectivity uses
mssql-python, which bundles
its own driver — no separate ODBC driver install is required.
Example MCP client config
One block per tenant:
{
"mcpServers": {
"tenant-a-sql": {
"command": "uvx",
"args": ["sql-server-mcp"],
"env": {
"MCP_SQL_SERVER_NAME": "tenant-a.datawarehouse.fabric.microsoft.com",
"MCP_SQL_DATABASE_NAME": "wh_silver",
"MCP_AZURE_TENANT_ID": "<tenant-a-tenant-id>"
}
},
"tenant-b-sql": {
"command": "uvx",
"args": ["sql-server-mcp"],
"env": {
"MCP_SQL_SERVER_NAME": "tenant-b.datawarehouse.fabric.microsoft.com",
"MCP_SQL_DATABASE_NAME": "wh_gold",
"MCP_AZURE_TENANT_ID": "<tenant-b-tenant-id>"
}
}
}
}
Tools
query(sql)— run a single read-onlySELECT. Table references must be fully qualified asdatabase.schema.table; there's no mutable "active database". Returns at mostMCP_MAX_ROWSrows, as a Markdown table.list_databases()— list user databases with status/metadata.search_schema(target, name, databases?, schema?, use_wildcard?)— search table or column metadata viaINFORMATION_SCHEMAacross one or more databases (all of them ifdatabasesis omitted).export_query(sql, path, format?)— run a single read-onlySELECTand write the full, uncapped result to a local Parquet or CSV file instead of returning it. For large results or when the output feeds into other local tools (pandas, DuckDB, etc.).
Development
uv run pytest # unit tests, no network/DB/Azure required
uv run python scripts/manual_smoke_test.py # real end-to-end check against a live database
Metadata
Release files for sql-server-mcp 0.5.3
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 | |
|---|---|---|---|---|
| sql_server_mcp-0.5.3.tar.gz | 121.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sql_server_mcp-0.5.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 137.0 kB
Release files / sql_server_mcp-0.5.3.tar.gz
| Download URL | sql_server_mcp-0.5.3.tar.gz |
|---|---|
| Size | 121.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
303b2fa5e5bd687e532290b41b7922ef6e3a8225fb00861011afabd956aa223a
|
|
BLAKE2b-256 checksum How to use checksums |
6e13b664ab4bdb921a9fd4c107958fbe658aca2c98e03c1663299a5fefc036f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sql_server_mcp-0.5.3-py3-none-any.whl
| Download URL | sql_server_mcp-0.5.3-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8ea3b0d4e2adbf2e739e48efaa1aadde896b26bf886def2be5aef0fb78ce526
|
|
BLAKE2b-256 checksum How to use checksums |
a754498123c05d38c3494f3956f40abfddfd83711850c07e4c6cdfaf44ed5c3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sql-server-mcp 0.5.3
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.