GoSQLX
This is a no-auth, read-only GoSQLX MCP server for analyzing and working with SQL queries.
Run a full SQL review with
analyze_sql, combining validation, parsing, metadata extraction, security scanning, linting, and formatting into one report.Validate and parse SQL syntax, optionally using any of 11 supported dialects.
Extract referenced tables, columns, and functions for lineage or impact analysis.
Format SQL with configurable indentation, optional trailing semicolons, and optional uppercase keywords.
Lint SQL style with rules L001–L010 and return violation counts/details.
Scan SQL for injection patterns such as tautologies, UNION attacks, stacked queries, and comment bypasses, with severity counts.
Enables parsing, formatting, validation, and analysis of MySQL SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of PostgreSQL SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of Snowflake SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of SQLite SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
This server has a remotely hosted endpoint. Open its connector listing for connection details, authentication requirements, and setup instructions:
GoSQLX
Pure-Go SQL parser, formatter, linter and security scanner for 8 dialects.
Playground · Docs · Benchmarks · VS Code · MCP server
~2.8M parses/sec† | 363 ns parse latency† | ~80–85% SQL-99 (est.) | 8 dialects | 0 race conditions |
† Parse stage only (pre-tokenized input to AST), SELECT id, name FROM users, Apple M4, Go 1.27, median of 20 runs of BenchmarkPerformanceBaseline. Complex queries take longer (see performance_baselines.json). Reproduce: go test -run ^$ -bench BenchmarkPerformanceBaseline -benchmem -count=20 ./pkg/sql/parser/.
What is GoSQLX?
GoSQLX is a production-ready SQL parsing SDK for Go. It tokenizes, parses, and generates ASTs from SQL with zero-copy optimizations and intelligent object pooling - parsing a simple SELECT in about 363 ns (~2.8M parses/sec).
Why GoSQLX?
Not an ORM - a parser. You get the AST, you decide what to do with it.
Not slow - zero-copy tokenization, sync.Pool recycling, no allocations on hot paths.
Not limited - PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, ClickHouse. CTEs, window functions, MERGE, set operations.
Not just a library - CLI, VS Code extension, GitHub Action, MCP server, WASM playground, Python bindings.
Related MCP server: mcp-server-duckdb
Install
Go library
go get github.com/ajitpratap0/GoSQLXCLI
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latestVS Code
code --install-extension ajitpratap0.gosqlxThe extension bundles the binary, so there is no extra setup. Learn more.
MCP server
claude mcp add --transport http gosqlx https://mcp.gosqlx.dev/mcp7 SQL tools in Claude, Cursor, or any MCP client. MCP guide.
Claude Code plugin (skills, slash commands, SQL reviewer agent): /plugin marketplace add ajitpratap0/GoSQLX then /plugin install gosqlx@gosqlx - details.
ChatGPT app: add https://mcp.gosqlx.dev/mcp as a connector in developer mode for an interactive analysis widget - details.
GitHub Action
- uses: ajitpratap0/GoSQLX@v1
with:
files: '**/*.sql'
validate: trueQuick start
Source: examples/readme_quickstart/main.go, compiled in CI against HEAD and the latest release.
package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/ajitpratap0/GoSQLX/pkg/gosqlx"
"github.com/ajitpratap0/GoSQLX/pkg/sql/ast"
)
func main() {
ctx := context.Background()
// ParseTree is the recommended entry point. It returns an
// opaque handle with built-in helpers.
tree, err := gosqlx.ParseTree(ctx, "SELECT id, name FROM users WHERE active = true",
gosqlx.WithDialect("postgresql"))
if err != nil {
// Sentinel errors work with errors.Is
if errors.Is(err, gosqlx.ErrSyntax) {
log.Fatalf("syntax error: %v", err)
}
log.Fatal(err)
}
fmt.Println("Tables:", tree.Tables())
fmt.Println(tree.Format(gosqlx.WithIndent(2), gosqlx.WithUppercaseKeywords(true)))
// Walk the AST - typed walkers avoid the type-assertion dance:
tree.WalkSelects(func(s *ast.SelectStatement) bool {
fmt.Printf(" SELECT with %d columns\n", len(s.Columns))
return true
})
// The legacy Parse/Format/Validate API still works for v1.x code.
// See docs/MIGRATION.md for the Tree migration guide.
}Output:
Tables: [users]
SELECT id, name
FROM users
WHERE active = true
SELECT with 2 columnsFormatting turns one-line SQL into a readable query:
Features
Parser - zero-copy tokenizer, recursive descent parser and full AST generation.
Analysis - SQL injection scanner, 30 lint rules (L001-L030), 20 optimizer rules and metadata extraction.
Tooling - AST-based formatter, query transforms API, VS Code extension and GitHub Action.
Syntax highlighting - dialect-aware highlighting for terminals (ANSI), HTML/CSS, JSON spans, LSP semantic tokens and WASM;
gosqlx highlight query.sqlorgosqlx.HighlightANSI(sql).Multi-dialect - 8 dialects with dedicated grammar support: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, ClickHouse. The
--dialectflag andWithDialectaccept 11 names: those 8 (postgresql,mysql,mariadb,sqlserver,oracle,sqlite,snowflake,clickhouse) plusgeneric,bigqueryandredshift. BigQuery and Redshift have no dialect-specific keyword set (they use the generic keywords) and only capability-gated grammar, such as BigQuery'sQUALIFY,PIVOT/UNPIVOT,UNNESTinFROMand(struct).fieldaccess.AI-ready - MCP server with 7 tools, public remote endpoint, Streamable HTTP.
Tested - race-detector clean in CI, ~80-85% SQL-99 (estimated).
Documentation
Getting Started - parse your first SQL in 5 minutes
Usage Guide - comprehensive patterns and examples
API Reference - complete API documentation
CLI Guide - command-line tool reference
SQL Compatibility - dialect support matrix
MCP Guide - AI assistant integration
Architecture - system design deep-dive
Benchmarks - performance data and methodology
Changelog - what changed in each version
Contributing
GoSQLX is built by contributors like you. Whether it's a bug fix, new feature, documentation improvement, or just a typo - every contribution matters.
git clone https://github.com/ajitpratap0/GoSQLX.git && cd GoSQLX
task check # fmt → vet → lint → test (with race detection)Fork & branch from
mainWrite tests - we use TDD and require race-free code
Run
task check- must pass before PROpen a PR - we review within 24 hours
Contributing Guide · Code of Conduct · Governance
Community
Questions or ideas: Discussions. Found a bug or want a feature: Issues.
License
Apache License 2.0 - see LICENSE for details.
gosqlx.dev · Playground · Docs · MCP Server · VS Code
Available Tools
7 toolsanalyze_sqlARead-onlyIdempotentInspect
Use this when the user wants a complete review of a SQL query. Runs validate, parse, metadata, security, lint, and format concurrently and returns one composite report; hosts that support MCP Apps render it as an interactive report.
Inputs: sql (required).
extract_metadataARead-onlyIdempotentInspect
Use this when the user wants the tables, columns, and functions a SQL query references (e.g. for lineage or impact analysis). Returns {tables, columns, functions}.
Inputs: sql (required).
format_sqlARead-onlyIdempotentInspect
Use this when the user wants SQL pretty-printed or reformatted: one clause per line, optional upper-case keywords and trailing semicolon. Comments are preserved; unplaceable optimizer hints are refused. Returns {formatted_sql, options}.
Inputs: sql (required), indent_size, add_semicolon, uppercase_keywords.
lint_sqlARead-onlyIdempotentInspect
Use this when the user wants SQL style feedback. Applies the same 10 rules as gosqlx lint: L001 trailing whitespace, L002 mixed indentation, L003 consecutive blank lines, L004 indentation depth, L005 line length (>100), L006 column alignment, L007 keyword case (upper), L008 comma placement (trailing), L009 aliasing consistency, L010 redundant whitespace. Returns {violation_count, violations}.
Inputs: sql (required).
parse_sqlARead-onlyIdempotentInspect
Use this when the user wants to know how SQL parses: returns an AST summary with the statement count and the type of each statement, optionally for a specific dialect. GO batch separators are excluded from the count.
Inputs: sql (required), dialect.
security_scanARead-onlyIdempotentInspect
Use this when the user wants SQL checked for injection patterns: tautologies, UNION attacks, stacked queries, comment bypasses, and more. Returns findings with severity counts.
Inputs: sql (required).
validate_sqlARead-onlyIdempotentInspect
Use this when the user wants to know whether a SQL statement is syntactically valid, optionally for a specific dialect. Returns {valid: bool, error?: string, dialect?: string}.
Inputs: sql (required), dialect.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a distinct primary action: format, parse, validate, lint, security scan, metadata extraction, and a composite analysis report. The main ambiguity is that `analyze_sql` overlaps with all the individual tools by running them concurrently, so an agent may sometimes choose the composite instead of a targeted tool. Descriptions mitigate this by framing `analyze_sql` as a full review, but the boundary is not perfectly sharp.
Six of seven tools follow a clear verb_noun snake_case pattern: format_sql, parse_sql, analyze_sql, extract_metadata, lint_sql, and validate_sql. `security_scan` deviates slightly because it is a noun compound rather than verb_noun, but it remains readable and thematically consistent.
Seven tools is well-scoped for a SQL analysis and formatting server. Each tool corresponds to a meaningful operation, and there are no redundant or trivial entries beyond the intentional composite `analyze_sql`.
The surface covers the full SQL analysis lifecycle: validation, parsing, formatting, linting, security scanning, metadata extraction, and a composite review. There are no obvious dead ends for the stated domain.
Maintenance
Related MCP Connectors
Database intelligence, AST SQL injection auditing, query optimization & schema guards.
Zero-trust SQL AST & MCP firewall enforcing tenant isolation, PII scrubbing, and schema allowlists.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
DBRE-grade SQL analysis inside any MCP client. No connection. No install. Paste a query.
Related MCP Servers
- AlicenseAqualityBmaintenanceAllows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.317,613 PyPI1,422MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities through MCP tools. It would be interesting to have LLM analyze it. DuckDB is suitable for local analysis.5,647 PyPI179MIT

mcp-clickhouseofficial
AlicenseAqualityAmaintenanceClickHouse database integration with schema inspection and query capabilities3911Apache 2.0- AlicenseBqualityDmaintenanceAdded support for STDIO mode and SSE mode Added support for multiple SQL execution, separated by ";" Added ability to query database table names and fields based on table comments Added SQL Execution Plan Analysis Added Chinese field to pinyin conversion528 PyPI249MIT