SQL Server

Provides read-only SQL Server access for AI assistants with schema, performance data, and audit logging.
  • python

1

GitHub Stars

python

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "shaharwiener-mcp-sql-server": {
      "command": "python",
      "args": [
        "/Users/shahar.wiener/repos/mcp-sql-server/server.py"
      ],
      "env": {
        "MCP_HOST": "127.0.0.1",
        "MCP_PORT": "9303",
        "LOG_LEVEL": "INFO",
        "PANGO_ENV": "Prd",
        "MCP_TRANSPORT": "stdio",
        "DB_CONN_LOCALDB": "Driver={ODBC Driver 18 for SQL Server};Server=127.0.0.1,1433;Database=LocalDB;UID=sa;PWD=YourStrong@Passw0rd;TrustServerCertificate=yes;Encrypt=yes;LoginTimeout=30"
      }
    }
  }
}

You can run a safe, read-only MCP server that connects to SQL Server databases, exposing schema, performance metrics, and metadata to AI assistants. This server emphasizes protection against unsafe commands, auditing, and easy deployment in cloud or local environments, while supporting multiple databases at once.

How to use

Use an MCP client to connect to the server and perform read-only queries against your SQL Server databases. You can inspect schemas, fetch table metadata, retrieve execution plans, and obtain performance and security information without executing writes. If you need to work with multiple databases, configure separate DB connection strings and reference them by their environment variable names. When you query, keep requests limited to SELECT statements; the system validates queries to prevent dangerous commands and enforces safe parsing and timing controls.

How to install

Prerequisites you need before installing the server are a Python runtime and Docker if you plan to run containerized. You will also want a modern shell to execute commands.

# Optional: set up a Python virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the server directly (local development)
python server.py

Additional setup notes

Configuration is environment-based. Default values live in a settings module, and you override them with environment variables or .env files for local development. At least one DB_CONN_<NAME> variable must be provided to connect to a database. You can deploy in Docker or AWS Fargate by setting transport to SSE and binding to 0.0.0.0 when needed.

Available tools

execute_sql_query

Execute SELECT queries with safety validation to ensure read-only access.

get_execution_plan

Retrieve query execution plans to analyze performance.

parse_sql_script

Parse and validate SQL syntax without executing to check correctness.

get_schema

Fetch database schema information, including table structures and metadata.

get_table_metadata

Obtain detailed metadata for a specific table.

get_object_definition

Get object definitions such as views and procedures.

get_table_size_statistics

Return table size and space usage statistics.

get_row_count_for_table

Return row counts for tables.

get_index_usage_statistics

Analyze how indexes are used to optimize queries.

get_missing_index_suggestions

Suggest missing indexes based on workload patterns.

get_current_blocking_snapshot

Identify current blocking sessions.

get_recent_deadlocks

Provide recent deadlock information.

get_sql_agent_jobs

List SQL Agent jobs.

get_sql_agent_job_history

Show history of SQL Agent jobs.

get_recent_failed_jobs

Find recently failed jobs.

get_principals_and_roles

List database principals and their roles.

get_permissions_for_principal

Show permissions granted to a principal.

get_recent_security_changes

Track recent security-related changes.

get_recent_schema_changes

Track DDL/schema changes.

sample_query_results

Execute a query and return sample results.

search_objects

Search for database objects by name pattern.

get_execution_plan

Retrieve detailed execution plans for queries.

get_wait_statistics

Analyze database wait statistics.

get_cache_hit_ratio

Monitor buffer cache efficiency.

get_index_fragmentation

Check fragmentation levels of indexes.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
SQL Server MCP Server - shaharwiener/mcp-sql-server | VeilStrat