================== /// MCP /// /// LEG /// ================== [server:online] [protocol:ready]
legion-mcp
by TheRaLabs
A Python MCP server that exposes multi-database querying capabilities through Legion Query Runner and the Model Context Protocol.
56
12
Open Source01
execute_query
Execute a SQL query and return results as a markdown table
02
execute_query_json
Execute a SQL query and return results as JSON
03
get_table_columns
Get column names for a specific table
04
get_table_types
Get column types for a specific table
05
get_query_history
Get the recent query history
06
list_databases
List all available database connections
07
get_database_info
Get detailed information about a database including schema
08
find_table
Find which database contains a specific table
09
describe_table
Get detailed description of a table including column names and types
10
get_table_sample
Get a sample of data from a table
Installation
1. Prerequisites
• Python 3.9 or higher
• Git (to clone the repository)
• Access credentials for the target databases you plan to query (PostgreSQL, MySQL, etc.)
2. Clone the repository
git clone https://github.com/TheRaLabs/legion-mcp.git
cd legion-mcp
3. Create and activate a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
4. Install server dependencies
pip install -r requirements.txt
5. (Optional) Install extra database drivers you need, e.g.
pip install psycopg2-binary # PostgreSQL
pip install mysqlclient # MySQL/MariaDB
6. Configure the server
• Copy the example environment file if present: cp .env.example .env
• Set the following mandatory variables in .env or your shell:
LEGION_API_KEY = <your-legion-api-key>
MCP_DATABASE_URL = <SQLAlchemy-style DB URL, e.g. postgresql://user:pass@host/db>
MCP_ALLOWED_ORIGINS = <comma-separated CORS origins>
7. Launch the MCP server
python -m legion_mcp.app # or: uvicorn legion_mcp.app:app --host 0.0.0.0 --port 8000
8. Verify
Open http://localhost:8000/health or /docs (if FastAPI-style OpenAPI docs are exposed) to confirm the service is running.
Documentation
License: GNU General Public License v3.0
Updated 7/30/2025