mcp-sql-querystore 0.1.0__tar.gz → 0.1.2__tar.gz
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.
- mcp_sql_querystore-0.1.2/LICENSE +21 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/PKG-INFO +4 -1
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/README.md +2 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/pyproject.toml +2 -2
- mcp_sql_querystore-0.1.2/server.json +18 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/src/mcp_sql_querystore/plan_parser.py +9 -2
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/src/mcp_sql_querystore/queries.py +21 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/src/mcp_sql_querystore/server.py +1 -1
- mcp_sql_querystore-0.1.0/API Token.txt +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/.gitignore +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/claude_desktop_config.example.json +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/provisioning/create_readonly_login.sql +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/src/mcp_sql_querystore/__init__.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/src/mcp_sql_querystore/db.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/conftest.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_audit.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_db_guards.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_integration.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_plan_parser.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_secrets.py +0 -0
- {mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/tests/test_sweep.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Deepesh Dhake
|
|
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.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcp-sql-querystore
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Read-only MCP server for SQL Server performance diagnostics over Query Store, DMVs, and execution plans
|
|
5
5
|
Project-URL: Homepage, https://github.com/deepeshd87/mcp-sql-querystore
|
|
6
6
|
Project-URL: Repository, https://github.com/deepeshd87/mcp-sql-querystore
|
|
7
7
|
Project-URL: Issues, https://github.com/deepeshd87/mcp-sql-querystore/issues
|
|
8
8
|
Author: Deepesh Dhake
|
|
9
9
|
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
10
11
|
Keywords: database,dba,mcp,model-context-protocol,mssql,performance-tuning,query-store,sql-server
|
|
11
12
|
Classifier: Development Status :: 4 - Beta
|
|
12
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -23,6 +24,8 @@ Provides-Extra: test
|
|
|
23
24
|
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
24
25
|
Description-Content-Type: text/markdown
|
|
25
26
|
|
|
27
|
+
mcp-name: io.github.deepeshd87/mcp-sql-querystore
|
|
28
|
+
|
|
26
29
|
# mcp-sql-querystore
|
|
27
30
|
|
|
28
31
|
Read-only MCP server exposing SQL Server Query Store diagnostics to LLM agents.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mcp-sql-querystore"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
description = "Read-only MCP server for SQL Server performance diagnostics over Query Store, DMVs, and execution plans"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -44,4 +44,4 @@ packages = ["src/mcp_sql_querystore"]
|
|
|
44
44
|
test = ["pytest>=8.0"]
|
|
45
45
|
|
|
46
46
|
[tool.pytest.ini_options]
|
|
47
|
-
testpaths = ["tests"]
|
|
47
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.deepeshd87/mcp-sql-querystore",
|
|
4
|
+
"description": "Read-only SQL Server diagnostics for LLM agents: Query Store, waits, plans, indexes",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/deepeshd87/mcp-sql-querystore",
|
|
7
|
+
"source": "github"
|
|
8
|
+
},
|
|
9
|
+
"version": "0.1.1",
|
|
10
|
+
"packages": [
|
|
11
|
+
{
|
|
12
|
+
"registryType": "pypi",
|
|
13
|
+
"identifier": "mcp-sql-querystore",
|
|
14
|
+
"version": "0.1.1",
|
|
15
|
+
"transport": { "type": "stdio" }
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -25,12 +25,19 @@ def summarize_plan(plan_xml: str) -> dict[str, Any]:
|
|
|
25
25
|
except ET.ParseError as exc:
|
|
26
26
|
return {"error": f"could not parse plan XML: {exc}"}
|
|
27
27
|
|
|
28
|
+
index_scans = _count_ops(root, "Index Scan")
|
|
29
|
+
clustered_index_scans = _count_ops(root, "Clustered Index Scan")
|
|
30
|
+
table_scans = _count_ops(root, "Table Scan")
|
|
28
31
|
summary: dict[str, Any] = {
|
|
29
32
|
"missing_indexes": _missing_indexes(root),
|
|
30
33
|
"warnings": _warnings(root),
|
|
31
34
|
"key_lookups": _count_ops(root, "Key Lookup"),
|
|
32
|
-
"index_scans":
|
|
33
|
-
"
|
|
35
|
+
"index_scans": index_scans,
|
|
36
|
+
"clustered_index_scans": clustered_index_scans,
|
|
37
|
+
"table_scans": table_scans,
|
|
38
|
+
# Total of every full-scan operator, so a caller can't miss a scan just
|
|
39
|
+
# because it was a Clustered Index Scan rather than a nonclustered one.
|
|
40
|
+
"total_scans": index_scans + clustered_index_scans + table_scans,
|
|
34
41
|
"estimated_subtree_cost": _root_cost(root),
|
|
35
42
|
}
|
|
36
43
|
return summary
|
|
@@ -18,6 +18,20 @@ METRIC_COLUMNS: dict[str, str] = {
|
|
|
18
18
|
"logical_reads": "avg_logical_io_reads",
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
# Observer-effect guard. This tool's OWN diagnostic queries read the
|
|
22
|
+
# sys.query_store_* / sys.dm_db_missing_index_* views, so they get captured in
|
|
23
|
+
# Query Store and -- on a quiet database -- can become the most "expensive"
|
|
24
|
+
# statements, which the detectors then flag as the problem. Any query whose
|
|
25
|
+
# text reads these monitoring views is itself a monitoring query, never
|
|
26
|
+
# application workload, so we exclude it from every candidate list. Fixed,
|
|
27
|
+
# literal predicate (no user input); applied as `AND <SQL_FILTER>` wherever a
|
|
28
|
+
# detector returns query candidates.
|
|
29
|
+
MONITORING_QUERY_EXCLUSION = (
|
|
30
|
+
"qt.query_sql_text NOT LIKE '%sys.query_store_%' "
|
|
31
|
+
"AND qt.query_sql_text NOT LIKE '%sys.dm_db_missing_index%' "
|
|
32
|
+
"AND qt.query_sql_text NOT LIKE '%/* mcp-sql-querystore %'"
|
|
33
|
+
)
|
|
34
|
+
|
|
21
35
|
|
|
22
36
|
def regressed_queries_sql(metric_column: str) -> str:
|
|
23
37
|
"""Baseline-vs-recent regression detection.
|
|
@@ -102,6 +116,8 @@ WHERE b.base_metric > 0
|
|
|
102
116
|
AND r.recent_execs >= ?
|
|
103
117
|
-- regression threshold: recent is at least X% worse than baseline
|
|
104
118
|
AND (r.recent_metric - b.base_metric) / b.base_metric >= ?
|
|
119
|
+
-- exclude this tool's own monitoring queries (observer effect)
|
|
120
|
+
AND """ + MONITORING_QUERY_EXCLUSION + """
|
|
105
121
|
ORDER BY (r.recent_metric - b.base_metric) / b.base_metric DESC;
|
|
106
122
|
"""
|
|
107
123
|
|
|
@@ -180,6 +196,10 @@ SELECT TOP (CAST(? AS INT))
|
|
|
180
196
|
FROM agg a
|
|
181
197
|
JOIN sys.query_store_query q ON q.query_id = a.query_id
|
|
182
198
|
JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
|
|
199
|
+
WHERE """ + MONITORING_QUERY_EXCLUSION + """
|
|
200
|
+
-- require a real workload footprint; monitoring/ad-hoc queries that ran only
|
|
201
|
+
-- a handful of times are not parameter-sniffing candidates.
|
|
202
|
+
AND a.total_execs >= 10
|
|
183
203
|
ORDER BY duration_ratio DESC;
|
|
184
204
|
"""
|
|
185
205
|
|
|
@@ -202,6 +222,7 @@ FROM sys.query_store_plan p
|
|
|
202
222
|
JOIN sys.query_store_query q ON p.query_id = q.query_id
|
|
203
223
|
JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
|
|
204
224
|
WHERE p.query_plan LIKE '%<MissingIndexes>%'
|
|
225
|
+
AND """ + MONITORING_QUERY_EXCLUSION + """
|
|
205
226
|
ORDER BY p.last_execution_time DESC;
|
|
206
227
|
"""
|
|
207
228
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mcp_sql_querystore-0.1.0 → mcp_sql_querystore-0.1.2}/provisioning/create_readonly_login.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|