Database

by theralabs

13 stars
2.6k downloads
Not rated
GitHub Website

About

Enables natural language querying and management of multiple database types (PostgreSQL, MySQL, SQL Server, BigQuery) for data analysis, business intelligence, and database exploration.

Details

Author
theralabs
Repository
TheRaLabs/legion-mcp
GitHub stars
13
Downloads
2,561
License
GNU General Public License v3.0
Categories
Database, Community, Other, AI, Design, Search, Infrastructure, Frontend

- Multi-database support - connect to multiple databases simultaneously
- Database access via Legion Query Runner
- Model Context Protocol (MCP) support for AI assistants
- Expose database operations as MCP resources, tools, and prompts
- Multiple deployment options (standalone MCP server, FastAPI integration)
- Query execution and result handling
- Flexible configuration via environment variables, command-line arguments, or MCP settings JSON
- User-driven database selection for multi-database setups

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Database
    Command (node, npx, python, etc.) uvx
    Arguments
    • Argument 1 database-mcp
    Environment
    • DB_TYPE pg
    • DB_CONFIG {"host":"localhost","port":5432,"user":"user","password":"pw","dbname":"dbname"}

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

export DB_TYPE="pg"  # or mysql, postgresql, etc.
export DB_CONFIG='{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"}'
uv run src/database_mcp/mcp_server.py
export DB_CONFIGS='[{"id":"pg_main","db_type":"pg","configuration":{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"},"description":"PostgreSQL Database"},{"id":"mysql_users","db_type":"mysql","configuration":{"host":"localhost","port":3306,"user":"root","password":"pass","database":"mysql"},"description":"MySQL Database"}]'
uv run src/database_mcp/mcp_server.py

If you don't specify an ID, the system will generate one automatically based on the database type and description:

```bash
export DB_CONFIGS='[{"db_type":"pg","configuration":{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"},"description":"PostgreSQL Database"},{"db_type":"mysql","configuration":{"host":"localhost","port":3306,"user":"root","password":"pass","database":"mysql"},"description":"MySQL Database"}]'

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

sql_query

Create an SQL query against the database

explain_query

Explain what a SQL query does

optimize_query

Optimize a SQL query for better performance

select_database

Help user select which database to use

| Tool | Description |
|------|-------------|
| 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 |

All database-specific tools (like execute_query, get_table_columns, etc.) require a db_id parameter to specify which database to use.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "database": {
            "env": {
                "DB_TYPE": "pg",
                "DB_CONFIG": "{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"dbname\"}"
            },
            "args": [
                "database-mcp"
            ],
            "command": "uvx"
        }
    }
}

Linux

{
    "env": {
        "DB_TYPE": "pg",
        "DB_CONFIG": "{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"dbname\"}"
    },
    "args": [
        "database-mcp"
    ],
    "command": "uvx"
}

Macos

{
    "env": {
        "DB_TYPE": "pg",
        "DB_CONFIG": "{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"dbname\"}"
    },
    "args": [
        "database-mcp"
    ],
    "command": "uvx"
}

Windows

{
    "env": {
        "DB_TYPE": "pg",
        "DB_CONFIG": "{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"dbname\"}"
    },
    "args": [
        "database-mcp"
    ],
    "command": "uvx"
}

Multi-Database MCP Server (by Legion AI)

A server that helps people access and query data in databases using the Legion Query Runner with integration of the Model Context Protocol (MCP) Python SDK.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.