Query Store, 실행 계획, 대기 통계를 사용하여 LLM 에이전트가 읽기 전용 SQL Server 진단을 수행할 수 있도록 합니다.
다른 이름 deepeshd87/mcp-sql-querystore
- 스타
- 1
- Tools
- 6
- 다운로드, 30일
- 124
- 최신 버전
- 0.1.1
- 마지막 커밋
- 2026년 10월 3일
- 라이선스
- MIT
sql-querystore MCP란?
sql-querystore은(는) MCP server입니다. Query Store, 실행 계획, 대기 통계를 사용하여 LLM 에이전트가 읽기 전용 SQL Server 진단을 수행할 수 있도록 합니다. 6개 도구를 제공합니다. 예: get_regressed_queries, get_query_execution_plan, analyze_parameter_sniffing.
프로젝트 README에서 생성된 요약
sql-querystore MCP server 정보
데이터베이스 관리자와 개발자는 이 읽기 전용 MCP server를 통해 AI 클라이언트에서 직접 SQL Server 성능 문제를 진단할 수 있습니다. 이 서버는 SQL Server 인스턴스에 연결하여 Query Store, 동적 관리 뷰(DMV) 및 실행 계획의 진단 데이터를 노출합니다. LLM에 이러한 특정 메트릭에 대한 접근 권한을 제공하면 수동으로 진단 쿼리를 작성하지 않고도 복잡한 성능 분류 작업을 수행할 수 있습니다.
이 서버는 stdio server로 작동하며 호스트에 ODBC Driver 18 for SQL Server가 설치되어 있어야 합니다. 보안은 VIEW DATABASE STATE 권한을 가진 전용 SQL 로그인을 통해 유지되므로, 에이전트가 사용자 테이블에 접근하거나 데이터를 수정할 수 없습니다. 환경 변수를 사용하여 연결을 구성할 수 있으며, 자격 증명을 구성 파일에 저장하지 않도록 통합 인증 또는 비밀번호 파일 옵션을 사용할 수 있습니다.
성능 저하를 식별하는 get_regressed_queries, 불안정한 계획을 찾는 analyze_parameter_sniffing, 인덱싱 우선순위를 정하는 get_missing_index_impact와 같은 특정 도구를 통해 심층 분석이 가능합니다. sweep_regressions 도구를 사용하면 Query Store가 활성화된 모든 데이터베이스를 한 번에 스캔하여 가장 심각한 성능 저하 요인을 찾을 수 있습니다.
활용 사례
- 1성능 저하 쿼리 식별이전 기준점과 비교하여 속도가 현저히 느려진 쿼리를 AI에게 찾도록 요청합니다.
- 2실행 계획 분석경고나 누락된 인덱스를 확인하기 위해 특정 쿼리 실행 계획의 요약을 요청합니다.
- 3대기 통계 진단데이터베이스 느려짐 현상이 CPU, 메모리 또는 IO 병목 현상으로 인해 발생하는지 확인합니다.
- 4파라미터 스니핑 탐지파라미터 스니핑으로 인해 실행 계획이 불안정한 쿼리를 찾습니다.
- 5다중 데이터베이스 스캔 수행에이전트에게 모든 온라인 데이터베이스를 스캔하여 가장 심각한 성능 저하를 찾도록 지시합니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
sql-querystore MCP 설치 방법
형식 확인: 2026년 11월 10일Cursor에 추가Goose에 추가Claude Code에 sql-querystore MCP 설치
$ claude mcp add mcp-sql-querystore -- uvx mcp-sql-querystoreCursor에 sql-querystore MCP 설치
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-sql-querystore": {
"command": "uvx",
"args": [
"mcp-sql-querystore"
]
}
}
}VS Code에 sql-querystore MCP 설치
.vscode/mcp.json
{
"servers": {
"mcp-sql-querystore": {
"type": "stdio",
"command": "uvx",
"args": [
"mcp-sql-querystore"
]
}
}
}VS Code CLI에 sql-querystore MCP 설치
$ code --add-mcp '{"name":"mcp-sql-querystore","type":"stdio","command":"uvx","args":["mcp-sql-querystore"]}'Claude Desktop에 sql-querystore MCP 설치
claude_desktop_config.json
{
"mcpServers": {
"mcp-sql-querystore": {
"command": "uvx",
"args": [
"mcp-sql-querystore"
]
}
}
}Codex에 sql-querystore MCP 설치
$ codex mcp add mcp-sql-querystore -- uvx mcp-sql-querystoreCodex config.toml에 sql-querystore MCP 설치
~/.codex/config.toml
[mcp_servers.mcp-sql-querystore] command = "uvx" args = ["mcp-sql-querystore"]
Gemini CLI에 sql-querystore MCP 설치
$ gemini mcp add -s user mcp-sql-querystore uvx -- mcp-sql-querystoreGemini settings.json에 sql-querystore MCP 설치
~/.gemini/settings.json
{
"mcpServers": {
"mcp-sql-querystore": {
"command": "uvx",
"args": [
"mcp-sql-querystore"
]
}
}
}sql-querystore MCP 도구 6
README에서 감지됨get_regressed_queriesget_query_execution_plananalyze_parameter_sniffingget_missing_index_impactget_wait_statssweep_regressions
| get_regressed_queries | — | |
| get_query_execution_plan | — | |
| analyze_parameter_sniffing | — | |
| get_missing_index_impact | — | |
| get_wait_stats | — | |
| sweep_regressions | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 이는 보안 감사가 아닙니다. 코드를 직접 읽고 서버에 필요한 최소한의 권한만 부여하십시오. 검사 방식
- 소스 저장소 연결 및 접근 가능deepeshd87/mcp-sql-querystore is public and reachablegithub.com/deepeshd87/mcp-sql-querystore ↗통과
- 패키지가 이 저장소를 소스로 명시mcp-sql-querystore names deepeshd87/mcp-sql-querystore as sourcepypi.org/project/mcp-sql-querystore/ ↗통과
- 빌드 출처(Sigstore 증명)No build attestation published for this release검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-10-03github.com/deepeshd87/mcp-sql-querystore ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음No popular package one edit away from mcp-sql-querystore통과
- 패키지 및 해당 종속성에 중요한 보안 권고 없음31 resolved dependencies checked; no critical advisoryosv.dev ↗통과
- 모델에 대한 숨겨진 지침 없음6 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에서 보기mcp-name: io.github.deepeshd87/mcp-sql-querystore
mcp-sql-querystore
Read-only MCP server exposing SQL Server Query Store diagnostics to LLM agents.
Six read-only diagnostic tools over Query Store, DMVs, and execution plans. The tools have been validated against a live SQL Server instance and are covered by a unit + integration test suite. Still validate against a non-prod instance of your own before pointing it at production, especially on SQL Server versions other than those noted under caveats.
Quickstart
-
Provision a read-only login. Run
provisioning/create_readonly_login.sqlagainst your instance (edit names first). This login's permissions are the read-only guarantee — see the security model below. -
Install.
pip install -e .in a virtual environment. ODBC Driver 18 for SQL Server must be installed on the host. -
Store the password outside the repo. Put it in a plain-text file somewhere the repo can't reach (not under the project folder):
# Windows PowerShell, UTF-8, password only, no quotes/newline New-Item -ItemType Directory -Force C:\Users\you\secrets | Out-Null Set-Content -NoNewline -Encoding utf8 C:\Users\you\secrets\mcp_sql.pwd 'your-password'Or skip the password entirely with integrated auth (
MCP_SQL_TRUSTED=yes) — preferred for CJIS/PCI. See Secret handling below for all options. -
Configure your MCP client. Copy the
sql-querystoreblock fromclaude_desktop_config.example.jsoninto your real Claude Desktop config (Windows:%APPDATA%\Claude\claude_desktop_config.json), then replace the placeholder paths, server name, andMCP_SQL_PWD_FILE. SetMCP_SQL_TRUST_CERT=yesonly for a self-signed/local cert; leave itnoagainst instances with proper certificates. -
Restart your MCP client and confirm the server shows as running.
Never commit your real config or your password file. .gitignore already
excludes *.pwd, .env, and claude_desktop_config.json.
Security model (read this first)
The read-only guarantee comes from the SQL login's permissions, not from any code in this repo:
- Provision a dedicated login with
VIEW DATABASE STATE(andVIEW SERVER STATEonly if you use server-scoped DMVs) and nothing else — nodb_datareader, noSELECTon user tables. Seeprovisioning/create_readonly_login.sql. - The keyword screen in
db.pyand the fixed SELECT-only query text are defense-in-depth, not the primary control. ApplicationIntent=ReadOnlyin the connection string only routes to a readable secondary in an availability group. On a standalone instance it does not make the session read-only. Do not rely on it for safety.- Credentials never belong in code. The simplest setup uses the
MCP_SQL_CONNECTION_STRINGenv var, but for CJIS/PCI environments prefer integrated auth or a file/secret-store-sourced password — see the Secret handling section below. - Every query is recorded via the audit logger — see Audit logging below. In a regulated environment, route that logger to a durable file or SIEM.
Setup
ODBC Driver 18 for SQL Server must be installed on the host. Install the package, then configure the connection via environment variables (see Secret handling for all options). The recommended form keeps the password in a file, not inline:
pip install -e .
# PowerShell — connection assembled from parts, password read from a file
$env:MCP_SQL_SERVER = "yourhost\INSTANCE"
$env:MCP_SQL_DATABASE = "master"
$env:MCP_SQL_UID = "mcp_readonly"
$env:MCP_SQL_PWD_FILE = "C:\path\to\your\secret.pwd"
$env:MCP_SQL_TRUST_CERT = "no" # "yes" only for a self-signed/local cert
python -m mcp_sql_querystore.server
Or use integrated auth with no stored password at all (MCP_SQL_TRUSTED=yes).
A full MCP_SQL_CONNECTION_STRING is also accepted for simple cases — see
Secret handling.
Register it with your MCP client (e.g. Claude Desktop) as an stdio server
invoking python -m mcp_sql_querystore.server; see
claude_desktop_config.example.json.
Tools
All tools are read-only and take a database_name (except sweep_regressions,
which can sweep all databases). Each returns JSON, or a structured error dict on
failure rather than raising.
- get_regressed_queries — compares a recent window against an earlier
baseline window per query and flags those worse by at least
regression_threshold. A real baseline-vs-recent comparison, not a top-CPU list. - get_query_execution_plan — returns compiled plans for a
query_idwith a compact JSON summary (missing indexes, warnings incl. implicit conversions, key lookups) and optional raw XML. - analyze_parameter_sniffing — finds queries with multiple compiled plans and ranks them by the ratio of slowest to fastest plan mean duration — the classic parameter-sniffing signature.
- get_missing_index_impact — scans recent plans containing missing-index recommendations, parses the impact score from the plan XML, and aggregates duplicate recommendations across queries, ranked by impact then recurrence.
- get_wait_stats — aggregates query wait time by wait category over a window, showing why queries are slow (CPU, blocking/locks, IO, memory) rather than which. De-duplicates flushed vs in-memory rows per Microsoft guidance.
- sweep_regressions — runs regression detection across all Query Store-enabled
online databases (or an explicit
database_nameslist) and returns the worst per database, ranked. One failing database does not abort the sweep; its error is collected and reported.
Example prompts
Once the server is connected to your MCP client, you drive the tools in plain
language. Name the target database in the prompt (except sweep_regressions,
which can scan all of them). Replace YourDB with your database name.
Wait stats — why queries are slow
- "What are the top wait categories in YourDB over the last week?"
- "Is YourDB waiting on CPU, memory, or IO?"
- "Show me wait stats for YourDB over the last 24 hours."
Execution plans
- "Get the execution plan for query_id 10 in YourDB and summarize it."
- "Does query_id 13 in YourDB have missing index recommendations?"
- "Are there implicit conversion warnings in query 12's plan in YourDB?"
Regression analysis
- "Check YourDB for CPU regressions over the last 24 hours."
- "Which queries in YourDB regressed by more than 30%?"
- "Find duration regressions in YourDB, ignoring anything with fewer than 10 executions."
Parameter sniffing
- "Check YourDB for parameter sniffing."
- "Which queries in YourDB have unstable plans?"
Missing indexes
- "What missing indexes does YourDB need most?"
- "Show me the top 10 index recommendations for YourDB by impact."
Multi-database sweep (no database name needed)
- "Sweep all my databases for CPU regressions."
- "Which database has the worst regressions this week?"
Combined — chaining tools in one turn
- "Find the biggest CPU regression in YourDB, pull its plan, and tell me why it might have regressed."
- "YourDB feels slow — diagnose it." (wait stats → regressions → plans)
- "Full performance triage of YourDB: wait stats, top regressions, and missing indexes."
Known caveats / TODO
- Version differences. Query Store column names assume SQL Server 2019+/2022 and Azure SQL MI. Verify against 2016/2017 if you target those.
- Regression semantics. Current logic uses execution-weighted averages. You
may prefer percentile-based comparison (Query Store doesn't store percentiles
directly, so that needs
*_stdevcolumns and assumptions). - Not time-windowed:
analyze_parameter_sniffingaggregates across all Query Store history; on busy databases consider adding arecent_hoursfilter like the other tools have. - Remaining hardening: connection retry with backoff, and version-aware column handling for mixed 2016/2017/2019/2022 fleets.
Secret handling
The connection string is resolved in this order, so the password need not sit in plaintext config:
MCP_SQL_CONNECTION_STRING— the full string (simplest; back-compat).MCP_SQL_CONNECTION_STRING_FILE— path to a file holding the full string (Docker/K8s secret-mount style).- Assembled from parts:
MCP_SQL_SERVER(+MCP_SQL_DATABASE,MCP_SQL_DRIVER,MCP_SQL_ENCRYPT,MCP_SQL_TRUST_CERT,MCP_SQL_EXTRA). Auth is either:- Integrated (preferred for CJIS/PCI — no password stored):
MCP_SQL_TRUSTED=yes. - SQL auth:
MCP_SQL_UIDplus the password fromMCP_SQL_PWD_FILE(a vault-mounted file),MCP_SQL_PWD_ENV(name of another env var), orMCP_SQL_PWD(direct; least preferred).
- Integrated (preferred for CJIS/PCI — no password stored):
Timeouts: MCP_SQL_CONNECT_TIMEOUT (default 10s) and MCP_SQL_QUERY_TIMEOUT
(default 30s, 0 disables).
Audit logging
Every query attempt is logged via the mcp_sql_querystore.audit logger: tool,
database, a 12-char hash of the SQL (not the text), row count, elapsed ms, and
outcome. Connection strings, SQL text, and parameter values are never logged.
Configure a handler for that logger to route the audit trail to a file or SIEM.
Testing
Unit tests (no database, safe in CI):
pip install -e ".[test]"
pytest
Integration tests (real instance, opt-in):
# set a working connection (any form above), then:
$env:MCP_SQL_TEST_DATABASE = "RAG"
$env:MCP_SQL_RUN_INTEGRATION = "1"
pytest tests/test_integration.py -v
sql-querystore MCP 질문
sql-querystore MCP를 Claude Code에 추가하려면 어떻게 하나요?
터미널에서 claude mcp add mcp-sql-querystore -- uvx mcp-sql-querystore를 실행합니다. 모든 프로젝트에서 사용할 수 있게 하려면 --scope user를 추가합니다.
sql-querystore MCP를 Cursor에 추가하려면 어떻게 하나요?
~/.cursor/mcp.json를 열고 mcpServers 아래에 서버를 추가합니다. 위 설치 섹션에 표시된 Cursor 구성을 사용합니다.
sql-querystore MCP는 어떤 도구를 제공하나요?
6개 도구를 제공합니다. 예: get_regressed_queries, get_query_execution_plan, analyze_parameter_sniffing, get_missing_index_impact, get_wait_stats.
운영 데이터베이스에서 이 서버를 안전하게 사용할 수 있나요?
이 서버는 읽기 전용이지만, 특히 주의 사항에 명시된 버전 이외의 SQL Server를 사용하는 경우 먼저 비운영 인스턴스에서 검증해야 합니다.
AI가 어떤 종류의 진단 정보에 접근할 수 있나요?
성능 저하 쿼리, 실행 계획, 파라미터 스니핑 분석, 누락된 인덱스 영향 및 대기 통계에 대한 도구를 제공합니다.
서버가 SQL 텍스트와 같은 민감한 정보를 로그에 남기나요?
아니요, 감사 로거는 사용된 도구, 데이터베이스, SQL 해시, 행 수, 경과 시간만 기록하며 연결 문자열, SQL 텍스트 또는 파라미터 값은 절대 기록하지 않습니다.