sqlfluff-mcp-server
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., "@sqlfluff-mcp-server Lint this SQL: SELECT * FROM users 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.
sqlfluff-mcp-server
An MCP server that exposes SQLFluff's linting, fixing, and parsing over the Model Context Protocol, so any MCP-aware client (Claude, other agents, IDE integrations) can lint and fix SQL directly.
This project is independent of the SQLFluff maintainers — it's a thin wrapper
around the public sqlfluff Python package.
Tools
Tool | Input | Config resolution |
| path on disk | walks up from the file for |
| path on disk (+ | same directory walk |
| path on disk | same directory walk |
| raw SQL text + | none — dialect supplied explicitly |
| raw SQL text + | none — dialect supplied explicitly |
| raw SQL text + | none — dialect supplied explicitly |
| — | lists supported dialect names |
| — | clears SQLFluff's cached config-file contents |
The *_file tools honor project config the same way the sqlfluff CLI does
(via FluffConfig.from_path, which walks up the directory tree looking for
.sqlfluff, pyproject.toml, setup.cfg, or tox.ini). The *_sql tools
are for content that hasn't been written to disk (e.g. streamed from an
editor buffer) and require you to pass dialect explicitly since there's no
file location to resolve config from.
Config caching
SQLFluff caches the contents of config files it reads while walking a
directory tree, for the lifetime of the process. Because this server is
long-running (unlike the sqlfluff CLI, which is a fresh process per
invocation), editing a .sqlfluff file after the server has started won't
be picked up by lint_file / fix_file / parse_file until you call
clear_config_cache. Call it whenever config on disk changes, or just
proactively before a lint/fix/parse call if you're unsure.
Related MCP server: dbt-mcp
Requirements
Python 3.10+
uv (recommended) or
pipx/pipmcp>=2.0.0,<3.0.0 andsqlfluff>=3.0.0 (installed automatically as dependencies — see Notes on dependencies)
Registering with an MCP client
This package is published on PyPI,
so there's nothing to clone or install ahead of time. Point your MCP
client's config (e.g. .claude.json / .mcp.json for Claude Code, or
Claude Desktop's config file) at it via uvx, and it's fetched into an
isolated cache and launched on demand:
{
"mcpServers": {
"sqlfluff": {
"command": "uvx",
"args": ["sqlfluff-mcp-server"]
}
}
}No uv? pipx run sqlfluff-mcp-server as the command/args works the
same way.
For stdio-based servers like this one, the client itself launches the process — automatically, when the client session starts, not when a prompt first needs it. Once it's registered, just ask the client to lint or fix a SQL file; the server is already running in the background and the tools are already available. If the server process crashes, the client restarts it for you.
Running it manually (for local testing/debugging)
uvx sqlfluff-mcp-serverThis starts the server over stdio and blocks, waiting for an MCP client to speak the protocol to it on stdin/stdout — it's not something you'd run interactively day to day, just useful for sanity-checking the install or piping through the MCP Inspector.
Development
Clone the repo to work on the server itself (rather than just consuming it
via uvx):
git clone <this-repo-url>
cd sqlfluff-mcp-server
uv sync --extra dev
uv run pytest
uv run ruff check .To point an MCP client at your local checkout instead of the PyPI release (e.g. to test unreleased changes):
{
"mcpServers": {
"sqlfluff": {
"command": "uv",
"args": ["--directory", "/path/to/sqlfluff-mcp-server", "run", "sqlfluff-mcp-server"]
}
}
}Notes on dependencies
mcpis pinned to>=2.0.0,<3.0.0. The SDK's 2.0 line renamedmcp.server.fastmcp.FastMCPtomcp.server.mcpserver.MCPServerand moved transport selection torun(transport=...); the@mcp.tool()decorator API is unchanged.sqlfluffis left unpinned above3.0.0— SQLFluff releases fairly often and this server only depends on its stableLinter/FluffConfigAPI.
License
MIT — see LICENSE.
Available Tools
8 toolsclear_config_cacheA
Clear SQLFluff's internal config-file cache.
SQLFluff caches the contents of .sqlfluff / pyproject.toml / setup.cfg / tox.ini files it reads while walking up a directory tree (keyed by file path, for the lifetime of this server process). If you edit a config file on disk while this server is running, the *_file tools may keep returning results based on the old contents until this cache is cleared. Call this tool after editing any SQLFluff config file to force the next lint_file / fix_file / parse_file call to re-read it from disk.
Inputs: no named parameters. Returns: object
fix_fileA
Fix a SQL file on disk, honoring discovered .sqlfluff config.
Args: path: Path to the SQL file to fix. write: If True, overwrite the file in place with the fixed SQL. If False (default), just return the fixed SQL without touching the file. config_path: Optional path to an extra config file to layer on top of whatever is discovered by walking the directory tree.
Inputs: path (required), write, config_path. Returns: object
fix_sqlA
Fix a raw SQL string using an explicitly specified dialect and return the fixed SQL text (does not touch any file).
Args: sql: The SQL text to fix. dialect: SQLFluff dialect name, e.g. "ansi", "bigquery", "snowflake", "postgres". rules: Optional list of rule codes/names to restrict fixing to.
Inputs: sql (required), dialect (required), rules. Returns: object
lint_fileA
Lint a SQL file on disk, honoring any .sqlfluff / pyproject.toml config found by walking up from the file's directory.
Args: path: Path to the SQL file to lint. config_path: Optional path to an extra config file to layer on top of whatever is discovered by walking the directory tree.
Inputs: path (required), config_path. Returns: object
lint_sqlA
Lint a raw SQL string using an explicitly specified dialect.
Args: sql: The SQL text to lint. dialect: SQLFluff dialect name, e.g. "ansi", "bigquery", "snowflake", "postgres". See sqlfluff.list_dialects() for the full set. rules: Optional list of rule codes/names to restrict linting to.
Inputs: sql (required), dialect (required), rules. Returns: object
list_dialectsA
List the SQL dialects SQLFluff supports (for use with lint_sql / fix_sql / parse_sql).
Inputs: no named parameters. Returns: result
parse_fileA
Parse a SQL file on disk and return its parse tree, honoring discovered .sqlfluff config.
Args: path: Path to the SQL file to parse. config_path: Optional path to an extra config file to layer on top of whatever is discovered by walking the directory tree.
Inputs: path (required), config_path. Returns: object
parse_sqlA
Parse a raw SQL string using an explicitly specified dialect and return its parse tree.
Args: sql: The SQL text to parse. dialect: SQLFluff dialect name, e.g. "ansi", "bigquery", "snowflake", "postgres".
Inputs: sql (required), dialect (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clear, distinct purpose: the three file-based tools operate on paths, the three SQL-based tools operate on raw strings, and list_dialects/clear_config_cache serve separate helper roles. No two tools overlap in a way that would confuse an agent.
All tool names follow a consistent verb_noun pattern: lint/fix/parse paired with file/sql, plus list_dialects and clear_config_cache. The style is uniform (lowercase with underscores) with no mixed conventions.
Eight tools is well-scoped for a SQLFluff wrapper: it covers the core operations (lint, fix, parse) for both file and string inputs, plus a dialect listing and cache-clearing utility. No redundancy and no missing essential operation.
The tool surface covers the main SQLFluff functionality comprehensively—lint, fix, and parse for both files and raw SQL. A few advanced capabilities like rendering or rule-specific configuration are absent, but core workflows are fully supported.
Maintenance
Related MCP Connectors
MCP server for StyleKit styles, tokens, recipes, lint and repair over stdio or HTTP.
MCP server for interacting with the Supabase platform
The official Svelte MCP server providing docs and autofixing tools for Svelte development
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables integration of Semgrep in development environments via the MCP protocol, supporting static code analysis, rule management, and scan result operations.2MIT
- AlicenseBqualityBmaintenanceA MCP (Model Context Protocol) server for interacting with dbt.1623,033 PyPI624Apache 2.0
- AlicenseAqualityFmaintenanceMCP server that integrates sql-sop SQL linter into LLM clients, enabling linting SQL queries and listing lint rules via chat tools.2MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that wraps Spectral to lint OpenAPI specifications, enabling LLMs to validate and fix API definitions.1MIT