sqlserver-mcp-tools 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlserver-mcp-tools
3
+ Version: 0.1.0
4
+ Summary: Servidor MCP (Model Context Protocol) para SQL Server com controle de permissões e modo somente-leitura
5
+ Author: hlgurgel
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/hlgurgel/mcp-sqlserver
8
+ Project-URL: Issues, https://github.com/hlgurgel/mcp-sqlserver/issues
9
+ Keywords: mcp,model-context-protocol,sql-server,sqlserver,mcp-server,pyodbc,sql
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Database
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp<2.0,>=1.0.0
22
+ Requires-Dist: pyodbc>=5.0.0
23
+ Requires-Dist: python-dotenv>=1.0.0
24
+ Dynamic: license-file
25
+
26
+ # mcp-sqlserver
27
+
28
+ [![PyPI version](https://img.shields.io/pypi/v/sqlserver-mcp-tools.svg)](https://pypi.org/project/sqlserver-mcp-tools/)
29
+ [![License: MIT](https://img.shields.io/github/license/hlgurgel/mcp-sqlserver.svg)](https://github.com/hlgurgel/mcp-sqlserver/blob/main/LICENSE)
30
+ [![Python versions](https://img.shields.io/pypi/pyversions/sqlserver-mcp-tools.svg)](https://pypi.org/project/sqlserver-mcp-tools/)
31
+
32
+ Servidor MCP (Model Context Protocol) para SQL Server, com controle de permissões
33
+ e modo somente-leitura por padrão. Permite que agentes de IA (Claude, opencode e
34
+ outros clientes MCP) consultem e administrem bancos SQL Server de forma segura.
35
+
36
+ ## Segurança
37
+
38
+ - **Credenciais nunca expostas ao LLM** — a string de conexão é lida do ambiente
39
+ e nunca aparece nas respostas nem nos logs.
40
+ - **Somente leitura por padrão** — a ferramenta `consulta` bloqueia DDL/DML
41
+ (INSERT, UPDATE, DELETE, DROP, etc.).
42
+ - **Escrita sob demanda** — ferramentas de escrita (`executar_update`, `executar_ddl`,
43
+ etc.) só são expostas quando o usuário da conexão possui permissão de escrita
44
+ (roles `sysadmin`, `db_owner`, `db_datawriter` ou `db_ddladmin`), e exigem
45
+ confirmação explícita antes de cada execução.
46
+
47
+ ## Pré-requisitos
48
+
49
+ - Python 3.10+
50
+ - Driver **ODBC Driver 18 for SQL Server**:
51
+ - macOS: `brew install msodbcsql18`
52
+ - Windows/Linux: instale o driver correspondente da Microsoft
53
+
54
+ ## Instalação
55
+
56
+ Via PyPI:
57
+
58
+ ```bash
59
+ pip install sqlserver-mcp-tools
60
+ ```
61
+
62
+ Ou, sem instalar nada (executa direto do PyPI com cache):
63
+
64
+ ```bash
65
+ uvx --from sqlserver-mcp-tools mcp-sqlserver
66
+ ```
67
+
68
+ ## Configuração
69
+
70
+ O servidor lê a string de conexão das seguintes fontes, em ordem de prioridade:
71
+
72
+ 1. Variável de ambiente `MSSQL_CONNECTION_STRING`
73
+ 2. Variável de ambiente `MSSQL_ENV_FILE` apontando para um arquivo `.env`
74
+ 3. Arquivo `.env` no diretório de trabalho (ou na raiz do projeto)
75
+
76
+ Exemplo de string de conexão:
77
+
78
+ ```
79
+ DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1433;DATABASE=seu_banco;UID=seu_usuario;PWD=sua_senha;TrustServerCertificate=yes
80
+ ```
81
+
82
+ ## Uso com clientes MCP
83
+
84
+ ### Claude Desktop
85
+
86
+ Adicione ao `claude_desktop_config.json`:
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "mcp-sqlserver": {
92
+ "command": "uvx",
93
+ "args": ["--from", "sqlserver-mcp-tools", "mcp-sqlserver"],
94
+ "env": {
95
+ "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Se instalou via `pip install`, pode usar o entry point diretamente:
103
+
104
+ ```json
105
+ {
106
+ "mcpServers": {
107
+ "mcp-sqlserver": {
108
+ "command": "mcp-sqlserver",
109
+ "env": {
110
+ "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"
111
+ }
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### OpenCode
118
+
119
+ No `opencode.json` do projeto:
120
+
121
+ ```json
122
+ {
123
+ "mcp": {
124
+ "sqlserver": {
125
+ "type": "local",
126
+ "command": ["mcp-sqlserver"],
127
+ "environment": {
128
+ "MSSQL_CONNECTION_STRING": "DRIVER={ODBC Driver 18 for SQL Server};SERVER=...;DATABASE=...;UID=...;PWD=...;TrustServerCertificate=yes"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ Alternativa: apontar para um arquivo `.env` local, mantendo a senha fora do JSON:
136
+
137
+ ```json
138
+ {
139
+ "mcp": {
140
+ "sqlserver": {
141
+ "type": "local",
142
+ "command": ["mcp-sqlserver"],
143
+ "environment": {
144
+ "MSSQL_ENV_FILE": "/caminho/para/seu/.env"
145
+ }
146
+ }
147
+ }
148
+ }
149
+ ```
150
+
151
+ ## Ferramentas disponíveis
152
+
153
+ Somente leitura (sempre disponíveis):
154
+
155
+ | Ferramenta | Descrição |
156
+ |---|---|
157
+ | `consulta` | Executa SELECT (somente leitura, bloqueia DDL/DML) |
158
+ | `listar_bancos` | Lista os bancos de dados acessíveis |
159
+ | `listar_tabelas` | Lista tabelas e views de um banco |
160
+ | `descrever_tabela` | Estrutura de uma tabela (colunas, tipos, PK) |
161
+ | `listar_indices` | Índices de uma tabela |
162
+ | `listar_procedures` | Lista stored procedures |
163
+ | `ler_procedure` | Código-fonte de uma procedure |
164
+ | `listar_funcoes` | Lista funções (scalar e table-valued) |
165
+ | `ler_funcao` | Código-fonte de uma função |
166
+ | `listar_constraints` | Constraints de uma tabela (PK, FK, UNIQUE, CHECK, DEFAULT) |
167
+ | `estatisticas_tabela` | Estatísticas (linhas, tamanho, uso de dados) |
168
+ | `plano_execucao` | Plano de execução estimado (sem executar) |
169
+ | `status_jobs` | Status da última execução de jobs do SQL Agent |
170
+
171
+ Escrita (só com permissão de escrita na conexão):
172
+
173
+ | Ferramenta | Descrição |
174
+ |---|---|
175
+ | `executar_procedure` | Executa uma stored procedure |
176
+ | `executar_update` | Executa UPDATE (exige WHERE) |
177
+ | `criar_indice` | Cria índice |
178
+ | `alterar_procedure` | Altera procedure com backup automático |
179
+ | `executar_ddl` | Executa DDL com backup do script de reversão |
180
+
181
+ ## Licença
182
+
183
+ MIT
@@ -0,0 +1,10 @@
1
+ mcp_sqlserver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mcp_sqlserver/connection.py,sha256=8ZPe7tmIApDkJdTMmJQhHseojCAbUw_dVFXPD9poyAY,4460
3
+ mcp_sqlserver/server.py,sha256=lYWQRu4XJXdRxVNukXD5tLxN7svJ3F8zKKYqC-oATyA,18224
4
+ mcp_sqlserver/tools.py,sha256=Opbw702ALXq-yV-1tror1Z3audDD0Xbd1s9vw4iXGfc,31894
5
+ sqlserver_mcp_tools-0.1.0.dist-info/licenses/LICENSE,sha256=3xe45b4TocAsp-tMhbkUGqSQ7zQEe3uNgBWFjC5B06k,1065
6
+ sqlserver_mcp_tools-0.1.0.dist-info/METADATA,sha256=gZaAf154zr4LXpjYSvHq1hCxdBdl0axu0pqJIViK8h4,5765
7
+ sqlserver_mcp_tools-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
8
+ sqlserver_mcp_tools-0.1.0.dist-info/entry_points.txt,sha256=mIiJSUQQBZYbNciTKyKsniqsJJRbQeSqqYWQmxjwRQk,60
9
+ sqlserver_mcp_tools-0.1.0.dist-info/top_level.txt,sha256=zUjTiYotm_8ZVGEGsXra4EMEVMwPYx6_9ikVbFbPB-8,14
10
+ sqlserver_mcp_tools-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcp-sqlserver = mcp_sqlserver.server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hlgurgel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ mcp_sqlserver