Skip to main content

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
lint_file path on disk walks up from the file for .sqlfluff / pyproject.toml / etc.
fix_file path on disk (+ write flag) same directory walk
parse_file path on disk same directory walk
lint_sql raw SQL text + dialect none — dialect supplied explicitly
fix_sql raw SQL text + dialect none — dialect supplied explicitly
parse_sql raw SQL text + dialect none — dialect supplied explicitly
list_dialects lists supported dialect names
clear_config_cache 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.

Requirements

  • Python 3.10+
  • uv (recommended) or pip

Install

git clone <this-repo-url>
cd sqlfluff-mcp-server
uv sync            # or: pip install -e ".[dev]"

Registering with an MCP client

You don't need to start this server yourself. Register it in your MCP client's config (e.g. .claude.json / .mcp.json for Claude Code, or Claude Desktop's config file):

{
  "mcpServers": {
    "sqlfluff": {
      "command": "uv",
      "args": ["--directory", "/path/to/sqlfluff-mcp-server", "run", "sqlfluff-mcp-server"]
    }
  }
}

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)

uv run sqlfluff-mcp-server          # or: sqlfluff-mcp-server, if installed on PATH

This 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

uv sync --extra dev
uv run pytest
uv run ruff check .

Notes on dependencies

  • mcp is pinned to >=2.0.0,<3.0.0. The SDK's 2.0 line renamed mcp.server.fastmcp.FastMCP to mcp.server.mcpserver.MCPServer and moved transport selection to run(transport=...); the @mcp.tool() decorator API is unchanged.
  • sqlfluff is left unpinned above 3.0.0 — SQLFluff releases fairly often and this server only depends on its stable Linter / FluffConfig API.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlfluff_mcp_server-0.1.0.tar.gz (108.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlfluff_mcp_server-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file sqlfluff_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: sqlfluff_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 108.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sqlfluff_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d34ab613a4d5a06b4f35ee688d16fbfee003579a1062d275cfb664b9561e5dd
MD5 c93b8b85e7730bca1c67efac9fc4c4ca
BLAKE2b-256 84fdbc2686722b1b8008c6eafff4c6eaba4a784525d6eba6a823b1e48a9723e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlfluff_mcp_server-0.1.0.tar.gz:

Publisher: publish.yml on gswartwood/sqlfluff-mcp-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlfluff_mcp_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlfluff_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdf4d448f2e3d83b127ac38ea0f06780b53369ab2475656a0f8164d37ef57272
MD5 44eaa3e26124fb6278b65dd665fc1be5
BLAKE2b-256 0d540f0ab57ee2ba2ff5b897c32cece96844eb9de496d2cdb75c499515f2284c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlfluff_mcp_server-0.1.0-py3-none-any.whl:

Publisher: publish.yml on gswartwood/sqlfluff-mcp-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page