Skip to main content
Glama
Thiago-Fernandes-Dias

SQL Server MCP Server

SQL Server MCP Server (Python)

A Model Context Protocol (MCP) server in Python for integration with Microsoft SQL Server databases.

The server provides complete schema inspection tools and CRUD (Create, Read, Update, Delete) operations, as well as MCP resources for quick data and schema queries.

Available Tools

Schema & Inspection

  • list_schemas(): Lists all user schemas present in the database.

  • list_tables(schema_name=None): Lists database tables and views with the option to filter by schema.

  • get_table_schema(table_name, schema_name="dbo"): Returns structural details of the table (columns, data types, primary keys, foreign keys, and identities).

  • get_database_schema(schema_name=None, table_name=None): Returns the complete database schema or a filtered one.

CRUD Operations

  • read_records(table_name, schema_name="dbo", columns=None, where_clause=None, params=None, order_by=None, limit=100, offset=0): Queries records from a table with custom columns, parameterized WHERE filters, ordering, and pagination.

  • read_query(sql_query, params=None): Executes a custom SELECT query in T-SQL with support for positional parameters (?).

  • insert_record(table_name, data, schema_name="dbo"): Inserts a single record (key/value dictionary) into a table.

  • bulk_insert_records(table_name, records, schema_name="dbo"): Inserts multiple records in batch within a transaction.

  • update_records(table_name, data, where_clause, where_params=None, schema_name="dbo"): Updates records matching a parameterized WHERE clause.

  • delete_records(table_name, where_clause, params=None, schema_name="dbo"): Safely removes records matching a WHERE clause.

  • execute_sql(sql_statement, params=None): Executes arbitrary DDL/DML commands (CREATE, ALTER, DROP, INSERT, UPDATE, DELETE).

Related MCP server: SQL Server MCP

MCP Resources

  • sqlserver://schema: Returns the complete database schema in JSON format.

  • sqlserver://tables: Returns the list of available tables and views.

Installation and Configuration

1. Requirements

  • Python >= 3.10

  • SQL Server Driver (Supports pyodbc with SQL Server ODBC Driver and pymssql for pure Python connections).

2. Environment Configuration (.env)

Create a .env file in the project root or define the environment variables:

SQLSERVER_HOST=localhost
SQLSERVER_PORT=1433
SQLSERVER_DATABASE=MeuBanco
SQLSERVER_USER=sa
SQLSERVER_PASSWORD=SuaSenha123!
SQLSERVER_DRIVER_TYPE=auto
SQLSERVER_TRUST_SERVER_CERTIFICATE=true

3. Installation

python -m venv .venv
# Windows
.\.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate

pip install -e .

Configuration in MCP Clients

Example of mcp.json / Client Configuration

{
  "mcpServers": {
    "sql-server": {
      "command": "python",
      "args": [
        "-m",
        "sql_server_mcp.server"
      ],
      "env": {
        "SQLSERVER_HOST": "localhost",
        "SQLSERVER_PORT": "1433",
        "SQLSERVER_DATABASE": "MeuBanco",
        "SQLSERVER_USER": "sa",
        "SQLSERVER_PASSWORD": "SuaSenha123!",
        "SQLSERVER_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

🐳 Docker & Makefile

You can use the Makefile to facilitate building and running via Docker:

# Compilar a imagem Docker
make build

# Executar o servidor MCP em container utilizando as variáveis do .env
make run

# Rodar os testes unitários dentro do container Docker
make docker-test

# Exibir ajuda dos comandos Makefile
make help

🧪 Tests

To run the application's unit tests:

pytest
Install Server
F
license - not found
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables interaction with Microsoft SQL Server instances using Windows or SQL Server authentication via native ODBC drivers. It allows users to execute SQL queries, list tables, and inspect schemas across multiple configured database environments through natural language.
    746
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that connects AI assistants to Microsoft SQL Server databases, enabling schema exploration and read-only queries safely.
    49
    23
    4
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A comprehensive MCP server for SQL Server database operations, enabling CRUD operations, schema exploration, and stored procedure execution through natural language.
    8
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Thiago-Fernandes-Dias/sql_server_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server