SuperAPI AI Directory

mcp-server-sql-analyzer

SQL analysis, linting and dialect conversion using SQLGlot.

Open website

About this tool

mcp-server-sql-analyzer is a Model Context Protocol (MCP) server for SQL static analysis, providing SQL analysis, linting, and dialect transpilation capabilities based on SQLGlot. It is intended for scenarios that need to handle SQL queries and helps with the following tasks: SQL syntax validation and linting; transpiling queries between different SQL dialects (for example, from MySQL to PostgreSQL); extracting and analyzing table references and dependencies; identifying column usage and relationships; discovering the supported SQL dialects.

The server can be used by AI assistants (such as Claude) to enhance SQL-related assistance capabilities, specifically including: query validation, validating syntax immediately before suggesting SQL to the user to ensure correct and dialect-compliant queries are provided; dialect transpilation, when users need to migrate queries between different database systems, accurately transpiling syntax while preserving query logic; code analysis, understanding complex queries through table and column reference analysis, making it easier to explain query structure and suggest optimizations; compatibility checking, using knowledge of supported dialects and their features to guide users toward best practices for a specific database.

The tools provided by this toolset are as follows:

lint_sql: Validate SQL query syntax and return errors. Input is sql (string) - the SQL query to analyze; dialect (string, optional) - the SQL dialect (for example 'mysql', 'postgres'). Returns ParseResult, including is_valid (boolean) indicating whether the SQL is valid, message (string) as the error message or "No syntax errors", position (object, optional) as the line and column where the error occurs (if present).

transpile_sql: Transpile SQL between different dialects. Input is sql (string) - the SQL statement to transpile; read_dialect (string) - the source SQL dialect; write_dialect (string) - the target SQL dialect. Returns TranspileResult, including is_valid (boolean) indicating whether the transpilation succeeded, message (string) as the error message or success confirmation, sql (string) as the successfully transpiled SQL.

get_all_table_references: Extracts table and CTE references from SQL . Input is sql (string) - the SQL statement to analyze; dialect (string, optional) - the SQL dialect. Returns TableReferencesResult, including is_valid (boolean) indicating whether the analysis succeeded, message (string) as status information, tables (array) as the 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. Input is sql (string) - the SQL statement to analyze; dialect (string, optional) - the SQL dialect. Returns ColumnReferencesResult, including is_valid (boolean) indicating whether the analysis succeeded, message (string) as status information, columns (array) as the list of column references, with column name, table name, and fully qualified name.

SQL dialect discovery: returns the list of all supported SQL dialects for use by all tools.

In terms of usage, running with uvx is recommended, and the configuration can be added to claude_desktop_config.json; alternatively, after cloning the repository, the relevant configuration can be added to claude_desktop_config.json. Specific contents for commands such as running the server in development mode and running unit tests are not given in the material. In addition, the material mentions that personal preferences can be updated in Claude Desktop settings, requiring generated SQL to first be validated through the lint_sql tool.

Applicable scenarios include: performing syntax validation before outputting SQL to the user; transpiling query dialects during cross-database migration; analyzing table and column reference relationships in complex queries; querying the supported SQL dialects to confirm compatibility. In terms of limitations, the material does not provide further explanation about the runtime environment, dependency versions, or error handling details.