MCP cover image
See in Github
2025-01-31

MCP server for SQL static analysis.

1

Github Watches

1

Github Forks

11

Github Stars

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:

  1. Query Validation: I can instantly validate SQL syntax before suggesting it to users, ensuring I provide correct and dialect-appropriate queries.

  2. Dialect Conversion: When users need to migrate queries between different database systems, I can accurately convert the syntax while preserving the query's logic.

  3. Code Analysis: The table and column reference analysis helps me understand complex queries, making it easier to explain query structure and suggest optimizations.

  4. 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.

Tools

  1. 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', 'postgresql')
    • 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
  2. 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
  3. 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
  4. 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://all

Returns 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-analyzer

To run unit tests:

uv run pytest .

License

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • https://jgadvisorycpa.com
  • This GPT assists in finding a top-rated business CPA - local or virtual. We account for their qualifications, experience, testimonials and reviews. Business operators provide a short description of your business, services wanted, and city or state.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • OffchainLabs
  • Go implementation of Ethereum proof of stake

  • modelcontextprotocol
  • Model Context Protocol Servers

  • huahuayu
  • A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

    Reviews

    2 (1)
    Avatar
    user_U9lKrKSi
    2025-04-15

    "Building AI-Powered Applications with Spring AI and Model Context Protocol is a game changer for AI enthusiasts and developers! The integration of Spring AI with MCP provides a robust framework for creating intelligent applications. Highly recommended for its comprehensive approach and ease of implementation. Great job by tguless!"