- Home
- MCP servers
- SQL Query Optimizer
SQL Query Optimizer
- python
0
GitHub Stars
python
Language
6 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"uddin-rajaul-mcp-sql-optimizer": {
"command": "C:\\path\\to\\venv\\Scripts\\python.exe",
"args": [
"C:\\path\\to\\mcp-sql-optimizer\\server.py"
],
"env": {
"PYTHONPATH": "C:\\path\\to\\mcp-sql-optimizer"
}
}
}
}You have a dedicated MCP Server that analyzes SQL queries, suggests optimizations, and produces index recommendations to improve performance across multiple dialects. It evaluates complexity, detects common anti-patterns, rewrites queries for efficiency, and presents actionable plans you can apply to your database workload.
How to use
You interact with the server through your MCP client by selecting the available tools to analyze, optimize, or get index suggestions for a SQL query. You can run analysis to understand where a query is heavy, see a breakdown of contributing factors, and view an ASCII representation of the plan. You can then request optimized forms of the query along with alternative approaches, and finally obtain DDL statements to create useful indexes. All results are presented with a prioritization of impact so you can focus on the most critical improvements first.
Key workflows include: 1) Analyze a query to receive a complexity score, anti-pattern alerts, and a plan visualization. 2) Optimize a query to get a rewritten version plus alternative approaches. 3) Get index recommendations, including composite and covering indexes, with DDL statements to implement them.
How to install
# Start a local Python MCP server using the provided entry point
# This example uses a Windows-style path from the repository guidance
# Adjust paths to your environment
C:\path\to\venv\Scripts\python.exe \
C:\path\to\mcp-sql-optimizer\server.py
# Create and activate a virtual environment
python -m venv venv
# On Windows, activate with
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Additional sections
Configuration details below show how to run the server locally and how to connect it to your MCP client. If you prefer containerization, a Docker approach is provided to run the server in a container and connect via the MCP client.
Security: Keep your environment secure by isolating the MCP server in a controlled network, and limit access to trusted clients. Use environment variables to configure sensitive values and avoid hard-coding secrets in commands.
Notes: The server exposes three core tools for you to use: analyze_query, optimize_query, and suggest_indexes. Each tool accepts a SQL query and a dialect, and returns structured results including the explain plan, rewritten queries, and index suggestions.
Available tools
analyze_query
Analyzes a SQL query for performance issues, complexity, and anti-patterns. Can optionally visualize the execution plan.
optimize_query
Rewrites the query to improve performance and provides alternative optimized forms.
suggest_indexes
Suggests indexes to improve query performance, including DDL statements for creation and guidance on composite or covering indexes.