A Model Context Protocol (MCP) server that lets AI agents query and explore Azure SQL databases. It exposes five tools for executing SQL, listing tables, inspecting schemas, retrieving paginated data, and fetching database metadata.
Designed for use with Microsoft Copilot Studio, Claude Desktop, VS Code, and any other MCP-compatible client.
| Tool | Description | Read-only |
|---|---|---|
azure_sql_execute_query |
Execute arbitrary SQL (SELECT, INSERT, UPDATE, DELETE) with parameterized queries | No |
azure_sql_list_tables |
List all tables with schemas and row counts, or get info for a specific table | Yes |
azure_sql_get_table_schema |
Get column names, data types, nullable status, defaults, and primary key info | Yes |
azure_sql_get_table_data |
Retrieve rows with pagination (limit/offset) | Yes |
azure_sql_get_database_info |
Get database name, SQL Server version, creation date, and object counts | Yes |
All tools return either Markdown (human-readable) or JSON (machine-readable) output.
- Python 3.10+
- ODBC Driver 18 for SQL Server
- An Azure SQL Database with credentials
macOS:
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql18 mssql-tools18Linux (Ubuntu/Debian):
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list \
| sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18Windows: Download from Microsoft ODBC Driver 18.
uvx mcp-server-azure-sqlpip install mcp-server-azure-sql
mcp-server-azure-sqlgit clone https://github.com/Microsoft-Course-Content/copilot-studio-mcp-agent-sql.git
cd copilot-studio-mcp-agent-sql
pip install -e .
mcp-server-azure-sqlSet these environment variables (or create a .env file):
| Variable | Required | Description |
|---|---|---|
AZURE_SQL_SERVER |
Yes | Server hostname (e.g., myserver.database.windows.net) |
AZURE_SQL_DATABASE |
Yes | Database name |
AZURE_SQL_USERNAME |
Yes | Database username |
AZURE_SQL_PASSWORD |
Yes | Database password |
AZURE_SQL_DRIVER |
No | ODBC driver (default: ODBC Driver 18 for SQL Server) |
MCP_API_KEY |
No | API key for HTTP mode authentication |
PORT |
No | HTTP server port (default: 8000) |
Copy the example file to get started:
cp .env.example .env
# Edit .env with your Azure SQL credentialsAdd to your claude_desktop_config.json:
{
"mcpServers": {
"azure-sql": {
"command": "uvx",
"args": ["mcp-server-azure-sql"],
"env": {
"AZURE_SQL_SERVER": "your-server.database.windows.net",
"AZURE_SQL_DATABASE": "your-database",
"AZURE_SQL_USERNAME": "your-username",
"AZURE_SQL_PASSWORD": "your-password"
}
}
}
}Add to your .vscode/mcp.json:
{
"servers": {
"azure-sql": {
"command": "uvx",
"args": ["mcp-server-azure-sql"],
"env": {
"AZURE_SQL_SERVER": "your-server.database.windows.net",
"AZURE_SQL_DATABASE": "your-database",
"AZURE_SQL_USERNAME": "your-username",
"AZURE_SQL_PASSWORD": "your-password"
}
}
}
}For Copilot Studio integration, use HTTP transport mode for deployment:
mcp-server-azure-sql --transport httpSee COPILOT_STUDIO_SETUP.md for the complete step-by-step deployment and integration guide.
npx @modelcontextprotocol/inspector uvx mcp-server-azure-sql| Mode | Command | Use Case |
|---|---|---|
| stdio (default) | mcp-server-azure-sql |
Local clients: Claude Desktop, VS Code, MCP Inspector |
| HTTP | mcp-server-azure-sql --transport http |
Remote deployment: Copilot Studio, Azure App Service, Docker |
docker build -t mcp-server-azure-sql .
docker run -p 8000:8000 \
-e AZURE_SQL_SERVER="your-server.database.windows.net" \
-e AZURE_SQL_DATABASE="your-database" \
-e AZURE_SQL_USERNAME="your-username" \
-e AZURE_SQL_PASSWORD="your-password" \
mcp-server-azure-sqlgit clone https://github.com/Microsoft-Course-Content/copilot-studio-mcp-agent-sql.git
cd copilot-studio-mcp-agent-sql
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Lint
ruff check src/ tests/
ruff format src/ tests/- All user input uses parameterized queries (
?placeholders) to prevent SQL injection - Multiple SQL statements in a single query are rejected
- Credentials are loaded from environment variables, never hardcoded
- HTTP mode supports API key authentication via
MCP_API_KEY - Connections use TLS encryption by default (
Encrypt=yes) - Use a least-privilege database account in production
MIT - see LICENSE.