mcp-server-sql-analyzer
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-sql-analyzer validate this SQL: SELECT * FROM orders WHERE id = 1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-sql-analyzer
A Model Context Protocol (MCP) server that provides SQL analysis, linting, and dialect conversion capabilities using SQLGlot.
Overview
The SQL Analyzer MCP server provides tools for analyzing and working with SQL queries. It helps with:
SQL syntax validation and linting
Converting queries between different SQL dialects (e.g., MySQL to PostgreSQL)
Extracting and analyzing table references and dependencies
Identifying column usage and relationships
Discovering supported SQL dialects
How Claude Uses This Server
As an AI assistant, this server enhances my ability to help users work with SQL efficiently by:
Query Validation: I can instantly validate SQL syntax before suggesting it to users, ensuring I provide correct and dialect-appropriate queries.
Dialect Conversion: When users need to migrate queries between different database systems, I can accurately convert the syntax while preserving the query's logic.
Code Analysis: The table and column reference analysis helps me understand complex queries, making it easier to explain query structure and suggest optimizations.
Compatibility Checking: By knowing the supported dialects and their specific features, I can guide users toward database-specific best practices.
This toolset allows me to provide more accurate and helpful SQL-related assistance while reducing the risk of syntax errors or dialect-specific issues.
Tips
Update your personal preferences in Claude Desktop settings to request that generated SQL is first validated using the lint_sql tool.
Related MCP server: mcp-database-tools
Tools
lint_sql
Validates SQL query syntax and returns any errors
Input:
sql (string): SQL query to analyze
dialect (string, optional): SQL dialect (e.g., 'mysql', 'postgres')
Returns: ParseResult containing:
is_valid (boolean): Whether the SQL is valid
message (string): Error message or "No syntax errors"
position (object, optional): Line and column of error if present
transpile_sql
Converts SQL between different dialects
Inputs:
sql (string): SQL statement to transpile
read_dialect (string): Source SQL dialect
write_dialect (string): Target SQL dialect
Returns: TranspileResult containing:
is_valid (boolean): Whether transpilation succeeded
message (string): Error message or success confirmation
sql (string): Transpiled SQL if successful
get_all_table_references
Extracts table and CTE references from SQL
Inputs:
sql (string): SQL statement to analyze
dialect (string, optional): SQL dialect
Returns: TableReferencesResult containing:
is_valid (boolean): Whether analysis succeeded
message (string): Status message
tables (array): List of table references with type, catalog, database, table name, alias, and fully qualified name
get_all_column_references
Extracts column references with table context
Inputs:
sql (string): SQL statement to analyze
dialect (string, optional): SQL dialect
Returns: ColumnReferencesResult containing:
is_valid (boolean): Whether analysis succeeded
message (string): Status message
columns (array): List of column references with column name, table name, and fully qualified name
Resources
SQL Dialect Discovery
dialects://allReturns a list of all supported SQL dialects for use in all tools.
Configuration
Using uvx (recommended)
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"sql-analyzer": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/j4c0bs/mcp-server-sql-analyzer.git",
"mcp-server-sql-analyzer"
]
}
}
}Using uv
After cloning this repo, add this to your claude_desktop_config.json:
{
"mcpServers": {
"sql-analyzer": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-server-sql-analyzer",
"run",
"mcp-server-sql-analyzer"
]
}
}
}Development
To run the server in development mode:
# Clone the repository
git clone git@github.com:j4c0bs/mcp-server-sql-analyzer.git
# Run the server
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-server-sql-analyzer run mcp-server-sql-analyzerTo run unit tests:
uv run pytest .License
MIT
Available Tools
4 toolsget_all_column_referencesA
Extract column references from SQL statement with table context
Args:
sql: SQL statement to analyze
dialect: Optional SQL dialect (e.g., 'mysql', 'postgres')
Returns:
JSON object containing column references with table context and any errors
Inputs: sql (required), dialect.
get_all_table_referencesA
Extract table and CTE names from SQL statement
Args:
sql: SQL statement to analyze
dialect: Optional SQL dialect (e.g., 'mysql', 'postgres')
Returns:
JSON object containing tables with catalog, database, and alias attributes
CTEs are returned as "cte" type
Inputs: sql (required), dialect.
lint_sqlB
Lint SQL query and return syntax errors
Some syntax errors are not detected by the parser like trailing commas
Args:
sql: SQL query to analyze
dialect: Optional SQL dialect (e.g., 'mysql', 'postgres')
Returns:
error message or "No syntax errors" if parsing succeeds
Inputs: sql (required), dialect.
transpile_sqlA
Transpile SQL statement to another dialect
Args:
sql: SQL statement to transpile
read_dialect: SQL dialect to read from
write_dialect: SQL dialect to write to
Returns:
transpiled SQL or syntax error
Inputs: sql (required), read_dialect (required), write_dialect (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: extracting column references, linting syntax, transpiling dialects, and extracting table references. There is no overlap or ambiguity.
All tool names follow a consistent verb_object pattern in snake_case (e.g., get_all_column_references, lint_sql), making them predictable and readable.
With 4 tools, the server is well-scoped for SQL analysis. Each tool serves a core function without being excessive or insufficient.
The tool set covers key SQL analysis tasks (extracting references, linting, transpilation). Missing features like formatting or optimization advice are minor gaps.
Maintenance
Related MCP Connectors
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Database intelligence, AST SQL injection auditing, query optimization & schema guards.
Query Postgres, MySQL, BigQuery, Iceberg and files with DuckDB, with per-query cost checks.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides SQL parsing, transpilation, formatting, extraction, and condition injection via MCP protocol, enabling agents to validate, analyze, and transform SQL.-
- AlicenseAqualityDmaintenanceEnables AI agents to format SQL, explain queries in plain English, analyze schemas, build queries from natural language, and generate migrations, all without requiring a database connection.547 npmMIT
- AlicenseAqualityCmaintenanceEnables SQL lineage analysis, including table-level and column-level lineage, field-level tracing, and support for multiple SQL dialects via sqlglot.3MIT
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to inspect database schemas, list tables, describe table schemas, and execute SQL queries against configured datasets and projects.-