# TheRaLabs/legion-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/TheRaLabs/legion-mcp  
**GitHub Stars:** 94  
**npm Downloads (last month):** 1082816  
**Views:** 5  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/theralabs-legion-mcp

## Description
Universal database MCP server supporting multiple database types including PostgreSQL, Redshift, CockroachDB, MySQL, RDS MySQL, Microsoft SQL Server, BigQuery, Oracle DB, and SQLite.

## Tools
Capabilities this server exposes over MCP:

- **execute_query** — Execute a SQL query and return results as a markdown table
- **execute_query_json** — Execute a SQL query and return results as JSON
- **get_table_columns** — Get column names for a specific table
- **get_table_types** — Get column types for a specific table
- **get_query_history** — Get the recent query history
- **list_databases** — List all available database connections
- **get_database_info** — Get detailed information about a database including schema
- **find_table** — Find which database contains a specific table
- **describe_table** — Get detailed description of a table including column names and types
- **get_table_sample** — Get a sample of data from a table

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "legion-mcp": {
    "command": "npx",
    "args": ["-y","@modelcontextprotocol/inspector"],
    "env": {
      "DB_TYPE": "",
      "DB_CONFIG": "",
      "DB_CONFIGS": ""
    }
  }
}
```

**Requires environment variables:** `DB_TYPE`, `DB_CONFIG`, `DB_CONFIGS` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What TheRaLabs/legion-mcp MCP server does

TheRaLabs/legion-mcp MCP server provides a common MCP interface for querying and inspecting several database systems. Supported connection types include PostgreSQL, Redshift, CockroachDB, MySQL, RDS MySQL, Microsoft SQL Server, BigQuery, Oracle DB, and SQLite. Database access is provided through Legion Query Runner connectors rather than separate database-specific MCP tools.

The server supports both single-database and multi-database configurations. In a multi-database setup, each connection can have an ID and description. Agents can inspect the available connections, identify the database containing a table, review schema details, and then run queries against the selected database.

## How it works

TheRaLabs/legion-mcp MCP server uses the MCP Python SDK to expose database operations as tools. It also provides database schema and metadata as MCP resources and includes prompts intended to guide database operations. The `select_database` prompt helps with choosing a connection when several databases are configured.

For a single connection, set `DB_TYPE` to a supported database code and provide its connection settings in `DB_CONFIG` as JSON. For multiple connections, use `DB_CONFIGS`, a JSON array containing each connection's type, configuration, and optional descriptive information. Tools that operate on a selected connection can receive its `db_id`.

The server can be configured through environment variables, command-line arguments, or MCP client settings JSON. The README documents `uvx` and pip-based setup, as well as running the server from the repository with Python.

## Setup and configuration

The documented direct runner is `uvx database-mcp`. An MCP client configuration passes database settings through the `env` object. A single-database setup uses `DB_TYPE` and `DB_CONFIG`; a multi-database setup uses `DB_CONFIGS` instead. The JSON format inside these variables depends on the selected database connector, so connection fields must follow the configuration expected by Legion Query Runner.

Database IDs may be supplied explicitly in a multi-database configuration. If an ID is omitted, the server generates one from the database type and description. The README also shows command-line options named `--db-type`, `--db-config`, and `--db-configs` for starting the server without those environment variables.

## Tools and capabilities

TheRaLabs/legion-mcp MCP server exposes tools for:

- Running SQL and returning results as a markdown table with `execute_query`.
- Running SQL and returning results as JSON with `execute_query_json`.
- Listing columns or column types for a specific table.
- Reviewing recent query history.
- Listing configured database connections.
- Viewing database information and schema details.
- Finding which configured database contains a named table.
- Getting a detailed table description, including column names and types.
- Retrieving a sample of table data.

In multi-database deployments, `list_databases`, `get_database_info`, and `find_table` support connection discovery before query execution. Database-specific credentials are kept in the connection configuration rather than embedded in SQL or application logic.

## Limitations and notes

The server does not provide one universal connection format for every database. Each supported type has its own configuration requirements, which are documented by the Legion Query Runner connectors. Multi-database queries require the caller to identify the target connection, commonly by supplying `db_id`.

The available material documents database querying, metadata inspection, resources, and prompts. It does not describe write restrictions, query timeouts, result-size limits, role-based access controls, or transaction behavior. Review the connector-specific documentation and deployment environment before granting an agent access to production data.

_Full upstream README: https://allmcps.com/mcp/theralabs-legion-mcp/readme_

