Skip to content

Commit 70ba765

Browse files
committed
Release v1.1.0: Type safety, bug fixes, and Ruff compliance
- Fixed 2000+ Pyright strict mode type issues (100% type-safe codebase) - Added 10 MCP Resources for intelligent database meta-awareness - Added 10 MCP Prompts for guided workflows - Fixed JSON serialization errors (datetime, IPv4Address, Decimal) - Fixed SQL query bugs (column names, parameter binding) - Fixed text search operator conversion (AND/OR/NOT to &/|/!) - Applied Ruff formatting and linting (zero errors) - All 63 tools + 10 resources tested and verified working
1 parent a3dbc9c commit 70ba765

18 files changed

+422
-441
lines changed

security/test_sql_injection_security.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
from dataclasses import dataclass
3434
from enum import Enum
3535
from typing import Any
36-
from typing import cast
3736
from typing import Dict
3837
from typing import List
3938
from typing import Optional
4039
from typing import TypedDict
40+
from typing import cast
4141

4242
# Fix Windows event loop compatibility with psycopg3
4343
if sys.platform == "win32":
@@ -102,13 +102,15 @@ class TestResult:
102102

103103
class VulnerabilitySummary(TypedDict):
104104
"""Summary of vulnerabilities by severity"""
105+
105106
critical: int
106107
high: int
107108
medium: int
108109

109110

110111
class ModeSummary(TypedDict):
111112
"""Summary of test results for a specific mode"""
113+
112114
total_tests: int
113115
vulnerable: int
114116
protected: int
@@ -118,6 +120,7 @@ class ModeSummary(TypedDict):
118120

119121
class Recommendation(TypedDict):
120122
"""Security recommendation"""
123+
121124
priority: str
122125
issue: str
123126
description: str
@@ -126,6 +129,7 @@ class Recommendation(TypedDict):
126129

127130
class SecurityReport(TypedDict):
128131
"""Complete security report structure"""
132+
129133
summary: Dict[str, ModeSummary]
130134
detailed_results: Dict[str, List[TestResult]]
131135
recommendations: List[Recommendation]
@@ -626,12 +630,7 @@ async def run_comprehensive_test_suite(self) -> SecurityReport:
626630
def generate_security_report(self, results: Dict[str, List[TestResult]]) -> SecurityReport:
627631
"""Generate a comprehensive security report"""
628632

629-
report: SecurityReport = {
630-
"summary": {},
631-
"detailed_results": results,
632-
"recommendations": [],
633-
"security_score": 0.0
634-
}
633+
report: SecurityReport = {"summary": {}, "detailed_results": results, "recommendations": [], "security_score": 0.0}
635634

636635
for mode, mode_results in results.items():
637636
total_tests = len(mode_results)

src/postgres_mcp/explain/explain_plan.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
from typing import TYPE_CHECKING
66
from typing import Any
7-
from typing import Optional
87
from typing import cast
98

109
from ..artifacts import ErrorResult
@@ -96,7 +95,7 @@ async def explain_with_hypothetical_indexes(
9695
try:
9796
# Validate index definitions format (type is already list[dict[str, Any]] from signature)
9897
# Note: isinstance checks removed as they're redundant with type annotations
99-
98+
10099
for idx in hypothetical_indexes:
101100
if "table" not in idx:
102101
return ErrorResult("Missing 'table' in index definition")
@@ -165,10 +164,10 @@ async def _run_explain_query(self, query: str, analyze: bool = False, generic_pl
165164

166165
if not isinstance(query_plan_data, list):
167166
return ErrorResult(f"Expected list from EXPLAIN, got {type(query_plan_data)}")
168-
167+
169168
# Cast to properly typed list after runtime check
170169
typed_plan_data: list[dict[str, Any]] = cast(list[dict[str, Any]], query_plan_data)
171-
170+
172171
if len(typed_plan_data) == 0:
173172
return ErrorResult("No results returned from EXPLAIN")
174173

@@ -186,7 +185,7 @@ async def generate_explain_plan_with_hypothetical_indexes(
186185
query_text: str,
187186
indexes: frozenset[IndexDefinition],
188187
use_generic_plan: bool = False,
189-
dta: Optional[Any] = None,
188+
dta: Any | None = None,
190189
) -> dict[str, Any]:
191190
"""
192191
Generate an explain plan for a query with specified indexes.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""PostgreSQL MCP Server Resources & Prompts.
22
3-
This module provides MCP Resources for database meta-awareness and
3+
This module provides MCP Resources for database meta-awareness and
44
MCP Prompts for guided workflows.
55
"""
66

77
from .database_resources import register_resources
88
from .prompt_handlers import register_prompts
99

10-
__all__ = ["register_resources", "register_prompts"]
11-
10+
__all__ = ["register_prompts", "register_resources"]

0 commit comments

Comments
 (0)