MCP server Microsoft SQL
Permite que um cliente de IA explore esquemas do SQL Server e execute consultas SELECT de leitura segura.
Também conhecido como bilims/mcp-sqlserver, @bilims/mcp-sqlserver
- Stars
- 47
- Ferramentas
- 8
- Downloads, 30 dias
- 4.376
- Versão mais recente
- —
- Último commit
- 31 de mar. de 2026
- Licença
- MIT
O que é o MCP Microsoft SQL?
Microsoft SQL é um MCP server. Permite que um cliente de IA explore esquemas do SQL Server e execute consultas SELECT de leitura segura. Ele expõe 8 ferramentas, como list_databases, list_tables, list_views.
Resumo gerado a partir do README do projeto
Sobre o MCP server de Microsoft SQL
Este servidor permite explorar esquemas do Microsoft SQL Server e executar consultas de apenas leitura a partir de um cliente de IA. Ele permite que desenvolvedores e analistas de dados interajam com Azure SQL Database, SQL Server on-premises ou instâncias locais do SQL Server Express usando linguagem natural por meio de ferramentas como Claude Desktop ou Claude Code CLI. O servidor funciona conectando-se ao seu banco de dados via variáveis de ambiente, como host, usuário, senha e nome do banco de dados.
A segurança é o foco principal, pois o servidor restringe as operações a comandos SELECT de leitura para evitar modificações acidentais de dados. Ele inclui proteções integradas contra SQL injection e utiliza uma blacklist para bloquear palavras-chave perigosas como INSERT ou DELETE. Os usuários podem descobrir estruturas de banco de dados usando ferramentas como list_tables, describe_table e get_foreign_keys. Para recuperação de dados, a ferramenta execute_query permite uma exploração segura com limites de linhas e timeouts configuráveis para garantir a estabilidade durante consultas complexas.
O que você pode fazer com ele
- 1Explorar estruturas de banco de dadosPeça à IA para identificar todas as tabelas e suas definições de colunas dentro de um esquema de banco de dados específico.
- 2Analisar relacionamentos entre tabelasSolicite um resumo de como diferentes tabelas estão conectadas por meio de chaves estrangeiras.
- 3Recuperar amostras de dadosUse linguagem natural para buscar um conjunto limitado de registros de uma tabela específica para inspeção.
- 4Auditar o tamanho das tabelasIdentifique quais tabelas no banco de dados estão consumindo mais espaço ou contêm o maior número de linhas.
Escrito a partir do README do projeto. Cada caso de uso é verificado com uma citação dele.
Como instalar o MCP Microsoft SQL
Formatos verificados em 10 nov 2026Adicionar ao CursorAdicionar ao GooseInstalar o MCP Microsoft SQL no Claude Code
$ claude mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserverInstalar o MCP Microsoft SQL no Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}Instalar o MCP Microsoft SQL no VS Code
.vscode/mcp.json
{
"servers": {
"mcp-sqlserver": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}Instalar o MCP Microsoft SQL no VS Code CLI
$ code --add-mcp '{"name":"mcp-sqlserver","type":"stdio","command":"npx","args":["-y","@bilims/mcp-sqlserver"]}'Instalar o MCP Microsoft SQL no Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}Instalar o MCP Microsoft SQL no Codex
$ codex mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserverInstalar o MCP Microsoft SQL no Codex config.toml
~/.codex/config.toml
[mcp_servers.mcp-sqlserver] command = "npx" args = ["-y", "@bilims/mcp-sqlserver"]
Instalar o MCP Microsoft SQL no Gemini CLI
$ gemini mcp add -s user mcp-sqlserver npx -- -y @bilims/mcp-sqlserverInstalar o MCP Microsoft SQL no Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}Ferramentas do MCP Microsoft SQL 8
Detectadas a partir do READMElist_databaseslist_tableslist_viewsdescribe_tableget_foreign_keysget_table_statsexecute_queryget_server_info
| list_databases | — | |
| list_tables | — | |
| list_views | — | |
| describe_table | — | |
| get_foreign_keys | — | |
| get_table_stats | — | |
| execute_query | — | |
| get_server_info | — |
Configuração
SQLSERVER_DATABASESQLSERVER_ENCRYPTSQLSERVER_HOSTSQLSERVER_PASSWORDSQLSERVER_TRUST_CERTSQLSERVER_USER
| Nome | Descrição | Tipo |
|---|---|---|
| SQLSERVER_DATABASE | — | |
| SQLSERVER_ENCRYPT | — | |
| SQLSERVER_HOST | — | |
| SQLSERVER_PASSWORD | — | |
| SQLSERVER_TRUST_CERT | — | |
| SQLSERVER_USER | — |
Verificações automatizadas
Executado em 14 de nov. de 2026Relatório completo →Ainda não verificado. Um servidor precisa de uma pontuação de 80, nenhum problema grave e dados suficientes para verificarmos. Como as verificações funcionam · O que corrigir para ganhar mais pontos
- Repositório de origem vinculado e acessívelbilims/mcp-sqlserver is public and reachablegithub.com/bilims/mcp-sqlserver ↗Passou
- O pacote indica este repositório como sua origem@bilims/mcp-sqlserver names bilims/mcp-sqlserver as sourcenpmjs.com/package/@bilims/mcp-sqlserver ↗Passou
- Proveniência da build (atestação Sigstore)No build attestation published for this releaseNão verificado
- Licença de código aberto (OSI)MITspdx.org/licenses/MIT.html ↗Passou
- Commit ou release no último anoLast commit or release 2026-03-31github.com/bilims/mcp-sqlserver ↗Passou
- OpenSSF ScorecardNão verificado
- Nome do pacote não é próximo a um pacote popularNo popular package one edit away from @bilims/mcp-sqlserverPassou
- Nenhum aviso crítico no pacote ou em suas dependênciasNão verificado
- Sem instruções ocultas para o modelo8 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPassou
- Ferramentas destrutivas estão rotuladasNão verificado
- O endpoint remoto responde ao handshake do MCPNão verificado
README
Ver no GitHubMCP SQL Server
A read-only Model Context Protocol (MCP) server for Microsoft SQL Server that enables AI agents to safely explore and query SQL Server databases.
Quick Start
Step 1: Install the Package
# Global installation (recommended)
npm install -g @bilims/mcp-sqlserver
# Verify installation
mcp-sqlserver --version
Step 2: Configure Your SQL Server Connection
Choose your SQL Server type and follow the configuration:
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-Premises SQL Server
export SQLSERVER_HOST="your-sql-server.company.com"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true" # For self-signed certificates
Local SQL Server Express
export SQLSERVER_HOST="localhost\\SQLEXPRESS"
export SQLSERVER_USER="sa"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="master"
export SQLSERVER_ENCRYPT="false"
export SQLSERVER_TRUST_CERT="true"
Step 3: Test the Connection
# Test your configuration
mcp-sqlserver --help
# Quick connection test (press Ctrl+C to exit)
mcp-sqlserver
Step 4: Add to Claude Desktop
-
Find your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the MCP server configuration:
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database",
"SQLSERVER_ENCRYPT": "true",
"SQLSERVER_TRUST_CERT": "false"
}
}
}
}
- Restart Claude Desktop
Step 5: Start Exploring!
Try these commands in Claude Desktop:
"Test the SQL Server connection""List all databases on the server""Show me the tables in [database name]""Describe the structure of the Users table""Show me foreign key relationships"
Features
- 🔒 Read-only operations: Only SELECT queries allowed, with comprehensive security validation
- 🗄️ Schema discovery: Explore databases, tables, views, relationships, and metadata
- 📊 Data exploration: Execute safe queries with built-in limits and timeouts
- 🔐 Enterprise-ready: Encrypted connections with certificate trust for production environments
- 🛡️ Security-first: Query validation, SQL injection protection, and access controls
Available Tools
Schema Discovery
list_databases- List all databases on the SQL Server instancelist_tables- List tables in a database or schemalist_views- List views in a database or schemadescribe_table- Get detailed table schema including columns, data types, and constraints
Relationship Analysis
get_foreign_keys- Get foreign key relationships for tablesget_table_stats- Get table statistics including row counts and size information
Data Exploration
execute_query- Execute read-only SELECT queries with safety validationget_server_info- Get SQL Server version, edition, and configuration details
Common Commands for Claude Desktop
Once your MCP server is configured, try these natural language commands:
Getting Started Commands
"Test the SQL Server connection"
"Show me server information"
"List all databases on this server"
"What tables are in the [database name] database?"
Database Exploration
"Describe the structure of the Users table"
"Show me foreign key relationships in this database"
"What are the largest tables by row count?"
"Give me a sample of data from the Orders table"
Advanced Analysis
"Help me understand the relationship between Orders and Customers"
"Show me all lookup tables in this database"
"What columns contain date/time information?"
"Find tables that might contain user authentication data"
Custom Queries
"Run this query: SELECT TOP 10 * FROM Products WHERE Price > 100"
"Show me all customers created in the last 30 days"
"What are the different product categories in the database?"
Installation
npm install
npm run build
Configuration
The server is configured using environment variables:
Required
SQLSERVER_USER- SQL Server usernameSQLSERVER_PASSWORD- SQL Server password
Optional
SQLSERVER_HOST- Server hostname (default: localhost)SQLSERVER_DATABASE- Default database nameSQLSERVER_PORT- Port number (default: 1433)SQLSERVER_ENCRYPT- Enable encryption (default: true)SQLSERVER_TRUST_CERT- Trust server certificate (default: true)SQLSERVER_CONNECTION_TIMEOUT- Connection timeout in ms (default: 30000)SQLSERVER_REQUEST_TIMEOUT- Request timeout in ms (default: 60000)SQLSERVER_MAX_ROWS- Maximum rows per query (default: 1000)
Usage
Environment Variables
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
Running the Server
npm start
Installation Options
Option 1: Global Installation (Recommended)
npm install -g @bilims/mcp-sqlserver
Option 2: Local Installation
npm install @bilims/mcp-sqlserver
npx mcp-sqlserver
Option 3: Run with npx (No Installation)
npx @bilims/mcp-sqlserver
Integration Examples
Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database"
}
}
}
}
Claude Code CLI
# Set environment variables
export SQLSERVER_HOST="your-server"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
# Use with Claude Code
claude mcp add sqlserver mcp-sqlserver
VSCode with MCP Extension
Install the MCP extension for VSCode and add the server configuration.
Security Features
Query Validation
- Only SELECT, WITH, SHOW, DESCRIBE, and EXPLAIN statements allowed
- Comprehensive blacklist of dangerous keywords (INSERT, UPDATE, DELETE, DROP, etc.)
- SQL injection pattern detection
- Automatic query sanitization
Connection Security
- TLS/SSL encryption enabled by default
- Server certificate trust options for enterprise environments
- Connection pooling with timeout controls
- Configurable request timeouts
Result Limits
- Maximum row limits per query (configurable)
- Automatic TOP clause injection for SELECT queries
- Query execution time tracking
- Memory usage protection
Example Queries
Once connected, you can use the tools through your MCP client:
// List all databases
await callTool("list_databases", {});
// List tables in a specific schema
await callTool("list_tables", { schema: "dbo" });
// Get table schema details
await callTool("describe_table", {
table_name: "Users",
schema: "dbo"
});
// Execute a read-only query
await callTool("execute_query", {
query: "SELECT TOP 10 * FROM Users WHERE active = 1",
limit: 10
});
// Get foreign key relationships
await callTool("get_foreign_keys", {
table_name: "Orders"
});
Development
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run linting
npm run lint
# Run tests
npm test
Troubleshooting
Connection Issues
- Verify server hostname and port
- Check if encryption/certificate settings match your SQL Server configuration
- Ensure user has appropriate read permissions
- Test connection using SQL Server Management Studio first
Permission Issues
The user account needs at minimum:
CONNECTpermission to the databaseSELECTpermission on tables/views you want to query- Access to system views for metadata queries
Common SQL Server Configurations
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-premises SQL Server with self-signed certificates
export SQLSERVER_HOST="sql-server.company.com"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
License
MIT
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section above
- Review SQL Server connection documentation
- Ensure MCP client compatibility
Built with the Model Context Protocol SDK for seamless AI integration.
Perguntas sobre o MCP Microsoft SQL
Como adiciono o MCP Microsoft SQL ao Claude Code?
Execute claude mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserver no seu terminal. Adicione --scope user para torná-lo disponível em todos os projetos.
Como adiciono o MCP Microsoft SQL ao Cursor?
Abra ~/.cursor/mcp.json e adicione o servidor em mcpServers, usando a configuração do Cursor mostrada na seção de instalação acima.
Quais ferramentas o MCP Microsoft SQL oferece?
Ele expõe 8 ferramentas, incluindo list_databases, list_tables, list_views, describe_table, get_foreign_keys.
Este MCP server pode modificar ou excluir dados no SQL Server?
Não, ele é apenas de leitura: apenas comandos SELECT, WITH, SHOW, DESCRIBE e EXPLAIN são permitidos, e palavras-chave perigosas estão na blacklist.
Como eu configuro a conexão com o SQL Server?
Defina variáveis de ambiente como SQLSERVER_HOST, SQLSERVER_USER, SQLSERVER_PASSWORD e SQLSERVER_DATABASE, além de opções de criptografia.
Quais ferramentas o servidor oferece para descoberta de esquema?
Ele expõe list_databases, list_tables, list_views e describe_table, além de ferramentas de relacionamento e consulta.
Funciona com Azure SQL Database?
Sim, com a criptografia habilitada e a confiança de certificado desabilitada para a configuração do Azure.
Quantas linhas uma consulta pode retornar?
O número de linhas por consulta é limitado pela variável SQLSERVER_MAX_ROWS, que tem o padrão de 1000.