Skip to content
MCP server

legion-mcp

MCP server giving AI assistants read access to PostgreSQL, MySQL, SQL Server and other

legion-mcp is an open-source MCP server for databases. It is available on CLI, API and Self-hosted.

Pricing
Open source
Platforms
CLI, API, Self-hosted
What it can do
Can change data (2 tools)
GitHub stars
95
Last commit

Similar MCP servers

About legion-mcp

Database MCP is a Python server that lets an AI assistant connect to one or several databases and work with them through a common set of tools. Each connection is defined by a database type code and a JSON configuration, so the same tools for listing tables, describing columns and running queries work across PostgreSQL, MySQL, SQL Server, Oracle, BigQuery, SQLite and others.

The server publishes schemas as MCP resources and exposes query execution in both markdown and JSON output. When several databases are configured, the assistant first lists the available connections, then searches for the table it needs and passes a database ID with each request. Connections are built on the Legion Query Runner library.

It suits developers and data teams who want an AI client to explore schemas and draft or explain SQL against live data without writing a custom integration for each database engine. The README notes that the full Legion analytics product is a separate offering.

Tools this server provides (10)

Taken from the project documentation; the running server may differ.

From the tool list in its README, going by the names, 2 of 10 tools change data.

From the server's own tool labels and tool names; not verified by us.

execute_queryName suggests: changes
Execute a SQL query and return results as a markdown table
execute_query_jsonName suggests: changes
Execute a SQL query and return results as JSON
get_table_columnsName suggests: reads
Get column names for a specific table
get_table_typesName suggests: reads
Get column types for a specific table
get_query_historyName suggests: reads
Get the recent query history
list_databasesName suggests: reads
List all available database connections
get_database_infoName suggests: reads
Get detailed information about a database including schema
find_tableName suggests: reads
Find which database contains a specific table
describe_tableName suggests: reads
Get detailed description of a table including column names and types
get_table_sampleName suggests: reads
Get a sample of data from a table

What it does

Multi-database connections
Connect several database instances at once and select the target for each query by ID.
Automatic schema discovery
Table and column metadata is exposed as MCP resources without manual mapping.
Unified query tools
The same tools for finding tables, describing columns and running queries work across supported engines.
Query and sample tools
Run SQL returning markdown or JSON, review query history and pull sample rows from a table.
Flexible configuration
Set connections through environment variables, command-line arguments or an MCP settings file.
Built-in SQL prompts
Prompts for writing, explaining and optimizing queries, plus a guided database selection prompt.

Good for

  • Letting an AI assistant explore an unfamiliar database schema before writing queries
  • Asking natural-language questions against a PostgreSQL or MySQL database from a desktop AI client
  • Comparing or locating tables across several databases from one assistant session
  • Getting SQL explanations and optimization suggestions for existing queries

Pricing

Open source

Free and licensed under GPL-3.0; the separate Legion AI platform has paid plans.

Prices change. Check thelegionai.com before you buy.

legion-mcp FAQ

Which databases are supported?

The README lists PostgreSQL, Redshift, CockroachDB, MySQL, RDS MySQL, Microsoft SQL Server, BigQuery, Oracle DB and SQLite.

How is the server installed?

It can be run with uvx using the database-mcp package, or installed with pip and started as a Python module.

Can legion-mcp connect to more than one database?

Yes. Multiple connections can be defined in a JSON array, and each tool call specifies which database to use.

Is legion-mcp free?

Yes. legion-mcp is open source, so you can use and self-host it for free.

What are the best alternatives to legion-mcp?

The closest alternatives to legion-mcp are sql-query-mcp, mcp-multi-db, mysql_mcp_server, db-mcp-server and postgres_mcp.

Where this comes from

  • Description: written from the project's README and the project's website.

How AIPoweredBot checks servers