SQL Server

io.github.hlgurgelPublished by GitHub account hlgurgelv0.1.8Updated Oct 24, 2026

Servidor MCP para SQL Server com controle de permissões e modo somente-leitura

VerifiedSTDIODesktop onlyDatabasesDeveloper Tools

Overview

AI-generated overview

Local MCP server for SQL Server that lets an assistant explore schemas and run read-only queries, with write tools gated by permissions and confirmation.

What you can do
  • Run read-only SELECT queries and list accessible databases
  • Inspect tables and views: structure, columns, types, primary keys, indexes, constraints and table statistics
  • Browse stored procedures and functions, including their source code
  • Review estimated execution plans and the last run status of SQL Agent jobs
  • When the connection user has write roles: execute procedures, run UPDATE with a WHERE clause, create indexes, alter procedures and run DDL with rollback scripts
When to use it
Useful when an assistant needs to explore or query a SQL Server database, understand its schema, procedures and functions, or diagnose query plans and job status. Write tools are only exposed for connections whose user has write permissions.
Requirements
Runs locally as a Python package (Python 3.10+) with the Microsoft ODBC Driver 18 for SQL Server installed. Needs a connection string supplied via the MSSQL_CONNECTION_STRING environment variable, or a .env file pointed to by MSSQL_ENV_FILE. An optional HTTP mode requires the server extra and MCP_HOST/MCP_PORT settings.
Before you install
The connection string contains database credentials; the README says it is read from the environment and kept out of responses and logs, but it still sits in client configuration files. Write tools (procedure execution, UPDATE, index creation, procedure changes, DDL) can modify or delete data and schema; they are only exposed for write-capable users and require explicit confirmation per execution. The optional HTTP mode defaults to binding 0.0.0.0, which can expose the database to the network.

Installation

In SourceWeft

  1. Open SQL Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

mcp-sqlserver

[PyPI version] [License: MIT] [Python versions]

Servidor MCP (Model Context Protocol) para SQL Server, com controle de permissões e modo somente-leitura por padrão. Permite que agentes de IA (Claude, opencode e outros clientes MCP) consultem e administrem bancos SQL Server de forma segura.

Segurança

  • Credenciais nunca expostas ao LLM — a string de conexão é lida do ambiente e nunca aparece nas respostas nem nos logs.
  • Somente leitura por padrão — a ferramenta consulta bloqueia DDL/DML (INSERT, UPDATE, DELETE, DROP, etc.).
  • Escrita sob demanda — ferramentas de escrita (executar_update, executar_ddl, etc.) só são expostas quando o usuário da conexão possui permissão de escrita (roles sysadmin, db_owner, db_datawriter ou db_ddladmin), e exigem confirmação explícita antes de cada execução.

Pré-requisitos

  • Python 3.10+
  • Driver ODBC Driver 18 for SQL Server:
    • macOS: brew install msodbcsql18
    • Windows/Linux: instale o driver correspondente da Microsoft

Instalação

Via PyPI:

bash
pip install sqlserver-mcp-tools

Ou, sem instalar nada (executa direto do PyPI com cache):

bash
uvx --from sqlserver-mcp-tools mcp-sqlserver

Configuração

O servidor lê a string de conexão das seguintes fontes, em ordem de prioridade:

  1. Variável de ambiente MSSQL_CONNECTION_STRING
  2. Variável de ambiente MSSQL_ENV_FILE apontando para um arquivo .env
  3. Arquivo .env no diretório de trabalho (ou na raiz do projeto)

Exemplo de string de conexão:

DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1433;DATABASE=seu_banco;UID=seu_usuario;PWD=sua_senha;TrustServerCertificate=yes

Uso com clientes MCP

Claude Desktop

Adicione ao claude_desktop_config.json:

json
{  "mcpServers": {    "mcp-sqlserver": {      "command": "uvx",      "args": ["--from", "sqlserver-mcp-tools", "mcp-sqlserver"],      "env": {        "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"      }    }  }}

Se instalou via pip install, pode usar o entry point diretamente:

json
{  "mcpServers": {    "mcp-sqlserver": {      "command": "mcp-sqlserver",      "env": {        "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"      }    }  }}

OpenCode

No opencode.json do projeto:

json
{  "mcp": {    "sqlserver": {      "type": "local",      "command": ["mcp-sqlserver"],      "environment": {        "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"      }    }  }}

Alternativa: apontar para um arquivo .env local, mantendo a senha fora do JSON:

json
{  "mcp": {    "sqlserver": {      "type": "local",      "command": ["mcp-sqlserver"],      "environment": {        "MSSQL_ENV_FILE": "/caminho/para/seu/.env"      }    }  }}

Servidor HTTP (Streamable HTTP)

Além do modo local (stdio), o servidor pode ser executado como um MCP remoto via Streamable HTTP, expondo o endpoint /mcp. Instale com o extra server:

bash
pip install 'sqlserver-mcp-tools[server]'

Inicie o servidor:

bash
MSSQL_CONNECTION_STRING="DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes" \  mcp-sqlserver-http

Opcionalmente, ajuste host/porta com MCP_HOST (padrão 0.0.0.0) e MCP_PORT (padrão 8090). O endpoint MCP fica em http://<host>:<porta>/mcp.

Para consumir remotamente no opencode:

json
{  "mcp": {    "sqlserver": {      "type": "remote",      "url": "http://10.177.51.228:8090/mcp"    }  }}

Ferramentas disponíveis

Somente leitura (sempre disponíveis):

FerramentaDescrição
consultaExecuta SELECT (somente leitura, bloqueia DDL/DML)
listar_bancosLista os bancos de dados acessíveis
listar_tabelasLista tabelas e views de um banco
descrever_tabelaEstrutura de uma tabela (colunas, tipos, PK)
listar_indicesÍndices de uma tabela
listar_proceduresLista stored procedures
ler_procedureCódigo-fonte de uma procedure
listar_funcoesLista funções (scalar e table-valued)
ler_funcaoCódigo-fonte de uma função
listar_constraintsConstraints de uma tabela (PK, FK, UNIQUE, CHECK, DEFAULT)
estatisticas_tabelaEstatísticas (linhas, tamanho, uso de dados)
plano_execucaoPlano de execução estimado (sem executar)
status_jobsStatus da última execução de jobs do SQL Agent

Escrita (só com permissão de escrita na conexão):

FerramentaDescrição
executar_procedureExecuta uma stored procedure
executar_updateExecuta UPDATE (exige WHERE)
criar_indiceCria índice
alterar_procedureAltera procedure com backup automático
executar_ddlExecuta DDL com backup do script de reversão

Licença

MIT

Source: README.md at commit 5bea8a3

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

3
  1. v0.1.8LatestOct 11, 2026
  2. v0.1.7Oct 10, 2026
  3. v0.1.6Sep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts