AI 에이전트가 여러 SQL Server 인스턴스를 관리하고, 인덱스 감사, 실행 계획 분석 및 그룹화된 연결을 통한 쿼리 실행을 수행할 수 있도록 지원합니다.
다른 이름 cvelasquez/mcp-sqlserver, mcp-sqlserver, @cevelas/mcp-sqlserver
- 스타
- 3
- Tools
- 8
- 다운로드, 30일
- 382
- 최신 버전
- 3.3.0
- 마지막 커밋
- 2026년 10월 12일
- 라이선스
- MIT
SQL MCP란?
SQL은(는) MCP server입니다. AI 에이전트가 여러 SQL Server 인스턴스를 관리하고, 인덱스 감사, 실행 계획 분석 및 그룹화된 연결을 통한 쿼리 실행을 수행할 수 있도록 지원합니다. 8개 도구를 제공합니다. 예: list_connections, reload_connections, query.
프로젝트 README에서 생성된 요약
SQL MCP server 정보
수십 개의 SQL Server 인스턴스를 관리하는 데이터베이스 관리자 및 컨설턴트는 이 도구를 사용하여 단일 인터페이스를 통해 여러 환경을 감독할 수 있습니다. 모든 데이터베이스에 대해 개별 연결 문자열을 구성하는 대신, connectionGroup을 사용하여 클라이언트나 환경별로 인스턴스를 정리한 중앙 connections.json 파일을 유지 관리합니다. 이를 통해 AI 에이전트는 클라이언트 애플리케이션을 재시작할 필요 없이 서로 다른 서버 간을 즉시 전환할 수 있습니다.
사용자는 성능 튜닝을 위한 get_execution_plan, 테이블 레이아웃 감사를 위한 get_indexes, 소스 코드 검사를 위한 get_stored_procedure와 같은 전문 도구를 사용하여 심층적인 기술 분석을 수행할 수 있습니다. 이 서버는 NTLM 및 Entra ID를 포함한 다양한 인증 방식을 지원합니다. 실수로 데이터가 수정되는 것을 방지하려면 특정 연결에 readOnly 설정을 활성화하여 쓰기 문이 로컬 머신을 떠나기 전에 거부하도록 할 수 있습니다. 이 시스템은 대규모 관리에 최적화되어 설계되었으며, 모든 응답에 메타데이터를 제공하여 에이전트가 어떤 서버에서 데이터를 제공했는지 항상 정확히 알 수 있게 합니다.
활용 사례
- 1느린 저장 프로시저 문제 해결에이전트에게 특정 프로시저의 소스 코드와 실행 계획을 분석하여 성능이 저하되는 원인을 조사하도록 요청합니다.
- 2환경 간 데이터베이스 스키마 비교운영 인스턴스와 QA 인스턴스 간의 테이블 구조 비교를 요청합니다.
- 3테이블 인덱스 감사특정 테이블의 인덱스 중 쿼리 커버링에 활용되지 않는 인덱스를 식별합니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
SQL MCP 설치 방법
형식 확인: 2026년 11월 10일Cursor에 추가Goose에 추가Claude Code에 SQL MCP 설치
$ claude mcp add --env 'MSSQL_MCP_CONNECTIONS_JSON=<YOUR_MSSQL_MCP_CONNECTIONS_JSON>' mcp-sqlserver -- npx -y @cevelas/mcp-sqlserverCursor에 SQL MCP 설치
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@cevelas/mcp-sqlserver"
],
"env": {
"MSSQL_MCP_CONNECTIONS_JSON": "<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"
}
}
}
}VS Code에 SQL MCP 설치
.vscode/mcp.json
{
"servers": {
"mcp-sqlserver": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@cevelas/mcp-sqlserver"
],
"env": {
"MSSQL_MCP_CONNECTIONS_JSON": "<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"
}
}
}
}VS Code CLI에 SQL MCP 설치
$ code --add-mcp '{"name":"mcp-sqlserver","type":"stdio","command":"npx","args":["-y","@cevelas/mcp-sqlserver"],"env":{"MSSQL_MCP_CONNECTIONS_JSON":"<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"}}'Claude Desktop에 SQL MCP 설치
claude_desktop_config.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@cevelas/mcp-sqlserver"
],
"env": {
"MSSQL_MCP_CONNECTIONS_JSON": "<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"
}
}
}
}Codex에 SQL MCP 설치
$ codex mcp add mcp-sqlserver --env 'MSSQL_MCP_CONNECTIONS_JSON=<YOUR_MSSQL_MCP_CONNECTIONS_JSON>' -- npx -y @cevelas/mcp-sqlserverCodex config.toml에 SQL MCP 설치
~/.codex/config.toml
[mcp_servers.mcp-sqlserver] command = "npx" args = ["-y", "@cevelas/mcp-sqlserver"] [mcp_servers.mcp-sqlserver.env] MSSQL_MCP_CONNECTIONS_JSON = "<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"
Gemini CLI에 SQL MCP 설치
$ gemini mcp add -s user -e 'MSSQL_MCP_CONNECTIONS_JSON=<YOUR_MSSQL_MCP_CONNECTIONS_JSON>' mcp-sqlserver npx -- -y @cevelas/mcp-sqlserverGemini settings.json에 SQL MCP 설치
~/.gemini/settings.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@cevelas/mcp-sqlserver"
],
"env": {
"MSSQL_MCP_CONNECTIONS_JSON": "<YOUR_MSSQL_MCP_CONNECTIONS_JSON>"
}
}
}
}SQL MCP 도구 8
README에서 감지됨list_connectionsreload_connectionsqueryget_schemaget_indexesget_execution_planget_stored_procedureformat
| list_connections | — | |
| reload_connections | — | |
| query | — | |
| get_schema | — | |
| get_indexes | — | |
| get_execution_plan | — | |
| get_stored_procedure | — | |
| format | — |
구성
MSSQL_MCP_CONNECTIONS_JSON비밀The connections JSON inline, for setups that keep credentials out of the filesystem.
MSSQL_MCP_CONNECTIONSPath to connections.json. Defaults to ~/.mcp-sqlserver/connections.json; create one with --init.
MSSQL_TEST_CONNECTION
| 이름 | 설명 | 유형 |
|---|---|---|
| MSSQL_MCP_CONNECTIONS_JSON | The connections JSON inline, for setups that keep credentials out of the filesystem. | 비밀 |
| MSSQL_MCP_CONNECTIONS | Path to connections.json. Defaults to ~/.mcp-sqlserver/connections.json; create one with --init. | |
| MSSQL_TEST_CONNECTION | — |
자동 검사
2026년 11월 13일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 이는 보안 감사가 아닙니다. 코드를 직접 읽고 서버에 필요한 최소한의 권한만 부여하십시오. 검사 방식
- 소스 저장소 연결 및 접근 가능cvelasquez/mcp-sqlserver is public and reachablegithub.com/cvelasquez/mcp-sqlserver ↗통과
- 패키지가 이 저장소를 소스로 명시@cevelas/mcp-sqlserver names cvelasquez/mcp-sqlserver as sourcenpmjs.com/package/@cevelas/mcp-sqlserver ↗통과
- 빌드 출처(Sigstore 증명)Sigstore attestation for @cevelas/mcp-sqlservernpmjs.com/package/@cevelas/mcp-sqlserver/v/3.3.0#provenance ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-10-12github.com/cvelasquez/mcp-sqlserver ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음No popular package one edit away from @cevelas/mcp-sqlserver통과
- 패키지 및 해당 종속성에 중요한 보안 권고 없음169 resolved dependencies checked; no critical advisoryosv.dev ↗통과
- 모델에 대한 숨겨진 지침 없음8 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨No tool named like delete, drop or exec통과
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기SQL Server MCP for people who manage dozens of instances
One MCP entry, every SQL Server you administer. Connections live in a single
connections.json, grouped by client or environment, hot-reloaded without
restarting your AI agent — plus execution plans, index audits and
stored-procedure analysis.
Built for DBAs and consultants, not for a demo against a single localhost database.
Install
Add this to your AI agent's MCP configuration:
{
"mcpServers": {
"sqlserver": {
"command": "npx",
"args": ["-y", "@cevelas/mcp-sqlserver"]
}
}
}
Then create your connections file and restart the agent:
npx -y @cevelas/mcp-sqlserver --init
That writes ~/.mcp-sqlserver/connections.json from a commented template. Edit
it, and ask your agent to "list all SQL Server connections".
Needs Node.js 22 or newer.
| Agent | Config file |
|---|---|
| Claude Desktop (Windows) | %APPDATA%\Claude\claude_desktop_config.json |
| Claude Desktop (macOS) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Code | claude mcp add sqlserver -- npx -y @cevelas/mcp-sqlserver |
| VS Code / Copilot | .vscode/mcp.json |
| Cursor | ~/.cursor/mcp.json |
Any MCP-compatible agent works — ChatGPT, Gemini, Copilot, Cline, Zed and
others all take the same command / args pair.
Why this one
Most SQL Server MCP servers take a single connection string. That is fine for one database. It falls apart when you administer thirty across eight clients, because every instance needs its own entry in the agent config, its own credentials, and its own restart when something changes.
| Single-DSN servers | This one | |
|---|---|---|
| Instances per MCP entry | 1 | all of them |
| Organised by client or environment | — | connectionGroup |
| Add or change a connection | edit agent config, restart | edit a file, reload_connections |
| Which server answered? | you assume | in every response's metadata |
Beyond SELECT |
— | execution plans, index layout, SP source |
| Read-only safety rail | — | "readOnly": true per connection |
Connections
{
"connections": [
{
"name": "acme-prod",
"connectionGroup": "Acme Corp",
"description": "Production - head office",
"server": "192.168.1.10\\SQLEXPRESS",
"database": "AcmeDB_Prod",
"user": "app_reader",
"password": "${env:ACME_PROD_PASSWORD}",
"port": 1433,
"encrypt": true,
"trustServerCertificate": false,
"readOnly": true
}
]
}
| Field | Required | Notes |
|---|---|---|
name |
yes | Unique; this is what you say to the agent |
server |
yes | Hostname, IP, or host\instance |
connectionGroup |
no | Client, project or environment. Groups the listing |
description |
no | Shown in list_connections and in every response |
database |
no | Defaults to the login's default database |
user, password |
no | Omit for domain or Entra ID auth |
port |
no | Defaults to 1433 |
encrypt, trustServerCertificate |
no | encrypt defaults to true |
readOnly |
no | Rejects writing statements — see below |
Anything else you put here is passed straight to mssql,
so requestTimeout, connectionTimeout, pool, authentication and a nested
options object all work.
Keeping passwords out of the file
Any string may reference an environment variable:
"password": "${env:ACME_PROD_PASSWORD}"
A connection that references a variable you have not set is disabled, and
list_connections names both the connection and the missing variable. Leaving
the literal in place would only move the failure to connect time, where it
arrives as Login failed for user and tells you nothing.
You can also skip the file entirely and pass the whole thing through the agent config, which keeps credentials in one place with the rest of your MCP secrets:
{
"mcpServers": {
"sqlserver": {
"command": "npx",
"args": ["-y", "@cevelas/mcp-sqlserver"],
"env": {
"MSSQL_MCP_CONNECTIONS_JSON": "{\"connections\":[{\"name\":\"prod\",\"server\":\"10.0.0.1\",\"database\":\"App\",\"user\":\"reader\",\"password\":\"...\"}]}"
}
}
}
}
Where the file is looked for
In order, first hit wins:
--connections <path>$MSSQL_MCP_CONNECTIONS— a path$MSSQL_MCP_CONNECTIONS_JSON— the JSON itself, inline./connections.jsonin the working directory~/.mcp-sqlserver/connections.jsonconnections.jsonnext to the installed package
A path given explicitly via 1 or 2 that does not exist is an error — the server will not quietly fall back to a different file and talk to the wrong database.
Checking every connection at once
npx -y @cevelas/mcp-sqlserver --check
Connects to every entry in parallel, runs SELECT 1, and lists which ones
fail and why. Exits non-zero if any did, so it works in a scheduled task.
Useful after a password rotation, or before blaming the agent.
Windows domain and Entra ID authentication
The bundled tedious driver supports NTLM and the Entra ID (Azure AD) family.
Add domain for NTLM:
{
"name": "warehouse",
"server": "dwh.corp.local",
"database": "DWH",
"domain": "CORP",
"user": "svc_analytics",
"password": "${env:DWH_PASSWORD}"
}
{
"name": "azure-sql",
"server": "myserver.database.windows.net",
"database": "reporting",
"encrypt": true,
"authentication": {
"type": "azure-active-directory-password",
"options": { "userName": "${env:AZURE_USER}", "password": "${env:AZURE_PASSWORD}" }
}
}
Fully integrated auth — a trusted connection with no password at all — needs
the native msnodesqlv8 driver, which is not bundled because it would break
the one-line install on machines without a build toolchain. NTLM with an
explicit service account is the supported path.
Tools
| Tool | Arguments | What it does |
|---|---|---|
list_connections |
— | Every connection, grouped |
reload_connections |
— | Re-read the file, drop open pools |
query |
connection, sql, maxRows?, format? |
Run a query |
get_schema |
connection, table? |
Columns, types, nullability, defaults |
get_indexes |
connection, table |
Indexes, types, key and included columns |
get_execution_plan |
connection, sql |
SHOWPLAN_XML — the plan, without running the query |
get_stored_procedure |
connection, name |
Source of a stored procedure |
Every response carries the connection it came from:
{
"metadata": {
"connection": "acme-prod",
"connectionGroup": "Acme Corp",
"description": "Production - head office",
"server": "192.168.1.10\\SQLEXPRESS",
"database": "AcmeDB_Prod"
},
"data": [ ... ]
}
With thirty connections in play, that line is what tells you the answer came from the client you meant.
Query results that fit in a context window
An agent that runs SELECT * FROM Orders does not need four million rows, and
neither does its context window.
- Row cap.
queryreturns at most 1000 rows across all result sets.maxRowschanges that, up to 10000. When the cap is hit the query is cancelled on the server, not trimmed afterwards. - A truncated result says so, first. The response opens with
"truncated": trueand a note stating that more rows exist, that the total is unknown, and how to get it. It sits before the rows on purpose: a 10000-row response runs to hundreds of KB, and a client that cuts long output keeps the beginning. An agent must never conclude "the table has 10000 rows" from a capped result. Asking for more than 10000 is not an error — the cap is lowered to 10000, and if rows were left out the note says what was asked for. format: "csv". JSON repeats every column name on every row. Withcsvthe response is one JSON header line with the metadata, a blank line, then the rows.NULLis an empty cell and an empty string is"", so the two stay distinguishable.- Server messages.
PRINToutput andSET STATISTICS IO, TIME ONresults come back inmessages, so the agent can read logical reads and CPU time instead of guessing. - Every result set. A batch with several
SELECTs returns them all inrecordsets.datais still the first one. - Binary columns come back as hex (
0x8f3a...), truncated after 64 bytes, instead of a JSON array with one number per byte.
rowCount is always present; truncated, messages and recordsets only
appear when they have something to say. Responses are compact JSON.
What this gets you
Things that are tedious by hand and become one sentence to the agent:
- "Why is this stored procedure slow?" —
get_stored_procedurefor the source,get_execution_planfor the plan,get_indexesfor what is missing. - "Compare the Orders schema between acme-prod and acme-qa" —
get_schemaon both, agent diffs them. - "Which indexes on this table are never covering anything?" —
get_indexesplus the queries you care about. - "I added a client to connections.json" —
reload_connections, no restart.
Read-only connections
"readOnly": true
Rejects INSERT, UPDATE, DELETE, MERGE, DROP, TRUNCATE, ALTER,
CREATE, GRANT, EXEC, BACKUP, DBCC, OPENQUERY, DISABLE/ENABLE
and friends before the query leaves your machine. It also requires the batch to
start with something that reads — SELECT, WITH, DECLARE, SET, IF
and so on — because T-SQL lets you call a procedure without EXEC, and
sp_rename 'dbo.Users','Users_old' contains no blocked keyword at all.
String literals, comments and bracketed identifiers are ignored, so
WHERE note = 'please delete this', SELECT [delete] FROM [Audit] and
DECLARE @Create DATETIME all pass. get_execution_plan still works, because
SHOWPLAN_XML returns the plan without executing anything.
Anything other than an explicit false turns the guard on — a hand-written
"readOnly": "false" locks the connection down rather than silently opening
it, and says so in list_connections.
This is a guard rail, not a security boundary. It stops an agent from
"helpfully" fixing a row in production. It will not stop someone determined to
write. The real protection is a SQL login that only has db_datareader:
CREATE LOGIN mcp_reader WITH PASSWORD = '...';
CREATE USER mcp_reader FOR LOGIN mcp_reader;
ALTER ROLE db_datareader ADD MEMBER mcp_reader;
GRANT VIEW DEFINITION TO mcp_reader; -- for get_stored_procedure
GRANT SHOWPLAN TO mcp_reader; -- for get_execution_plan
Use both.
Security notes
connections.jsonholds credentials. Keep it out of version control — the bundled.gitignorecoversconnections*.json.- Prefer
${env:VAR}over literal passwords. - Give each connection the least privilege it needs. Do not use
sa. - Restrict file permissions:
icacls connections.json /inheritance:r /grant:r "%USERNAME%:F"on Windows,chmod 600 connections.jsonelsewhere. - The
querytool runs whatever SQL the agent writes. That is the point of the tool — treat the connection's permissions as the boundary, not the tool.
Web UI
web/connections.html is a standalone page for editing connections.json
without hand-writing JSON: drag and drop between groups, duplicate a
connection, autocompleting group selector, and auto-save through the File
System Access API in Chrome and Edge. No build, no dependencies, entirely
optional. See web/README.md.
Claude Desktop one-click install
Grab the .mcpb bundle from the
latest release
and drag it onto Claude Desktop's extensions settings. Point it at your
connections.json in the extension's settings, or leave that empty to use
~/.mcp-sqlserver/connections.json.
Upgrading from 2.x
Your existing connections.json works unchanged — every new field is optional
and the tools take the same arguments. Two things worth knowing:
- Multi-connection was broken before 3.0. The server used the
mssqlglobal connection pool, which ignores the config it is handed once a connection is already open. In practice every connection after the first silently reused the first one's server and database. If you were relying on results from more than one connection in a session, they may not have come from where you thought. Fixed in 3.0 with a pool per connection. - If your agent config points at
node C:\path\to\index.js, that still works. The file resolution order now checks that path last, so nothing moves.
Development
npm install
npm test # unit tests, no database needed
node .github/scripts/smoke.mjs # packs, installs and speaks MCP to the tarball
Against a real server, name a connection from your own file:
MSSQL_TEST_CONNECTION=local npm run test:integration
The mssql driver is injected, so the unit tests mock only that boundary —
everything else is the real code path. test/contract.test.js freezes the tool
names and arguments so a refactor cannot change the MCP surface by accident.
License
MIT — see LICENSE.
Author
Christian Velasquez — @cvelasquez
SQL MCP 질문
SQL MCP를 Claude Code에 추가하려면 어떻게 하나요?
터미널에서 claude mcp add --env 'MSSQL_MCP_CONNECTIONS_JSON=<YOUR_MSSQL_MCP_CONNECTIONS_JSON>' mcp-sqlserver -- npx -y @cevelas/mcp-sqlserver를 실행합니다. 모든 프로젝트에서 사용할 수 있게 하려면 --scope user를 추가합니다.
SQL MCP를 Cursor에 추가하려면 어떻게 하나요?
~/.cursor/mcp.json를 열고 mcpServers 아래에 서버를 추가합니다. 위 설치 섹션에 표시된 Cursor 구성을 사용합니다.
SQL MCP는 어떤 도구를 제공하나요?
8개 도구를 제공합니다. 예: list_connections, reload_connections, query, get_schema, get_indexes.
여러 SQL Server 연결을 어떻게 관리하나요?
연결 정보는 단일 connections.json 파일에 저장됩니다. 클라이언트나 환경별로 그룹화할 수 있으며, 에이전트를 재시작하지 않고도 실시간으로 반영(hot-reload)할 수 있습니다.
쿼리 결과가 너무 많으면 어떻게 되나요?
서버는 기본적으로 결과값을 1000행으로 제한하며(maxRows 설정을 통해 최대 10000행까지 가능), 컨텍스트 윈도우 공간을 절약하기 위해 제한에 도달하면 서버 측에서 쿼리를 취소합니다.