Back to MCP Directory
Legion
Model Context Protocol moderate risk

Legion

Database MCP provides a unified interface to query and manage multiple databases via the Model Context Protocol, enabling AI assistants to interact with data.

Connections & Capabilities

Connects To

GitHubPostgreSQLMySQLSQLite

Capabilities

readwriteexec

Quickstart

Install

pip install database-mcp

Config

{
    "mcpServers": {
      "database-mcp": {
        "command": "uvx",
        "args": [
          "database-mcp"
        ],
        "env": {
          "DB_CONFIGS": "[{\"id\":\"pg_main\",\"db_type\":\"pg\",\"configuration\":{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"postgres\"},\"description\":\"PostgreSQL Database\"},{\"id\":\"mysql_data\",\"db_type\":\"mysql\",\"configuration\":{\"host\":\"localhost\",\"port\":3306,\"user\":\"root\",\"password\":\"pass\",\"database\":\"mysql\"},\"description\":\"MySQL Database\"}]"
        },
        "disabled": true,
        "autoApprove": []
      }
    }
}

Exposed MCP Tools (10)

high
execute_query

Executes a SQL query against the database and returns the results as a markdown table.

Allows arbitrary SQL execution, potentially leading to data modification or deletion.

high
execute_query_json

Executes a SQL query and returns results as JSON.

Allows arbitrary SQL execution, potentially leading to data modification or deletion.

safe
get_table_columns

Retrieves the column names for a specified table.

Read-only operation, no side effects.

safe
get_table_types

Retrieves the column types for a specified table.

Read-only operation, no side effects.

safe
get_query_history

Retrieves the recent query history.

Read-only operation, no side effects.

safe
list_databases

Lists all available database connections.

Read-only operation, no side effects.

safe
get_database_info

Retrieves detailed information about a database, including its schema.

Read-only operation, no side effects.

safe
find_table

Finds which database contains a specific table.

Read-only operation, no side effects.

safe
describe_table

Retrieves a detailed description of a table, including column names and types.

Read-only operation, no side effects.

safe
get_table_sample

Retrieves a sample of data from a table.

Read-only operation, no side effects.

Safety Assessment

Database MCP offers a convenient way to access databases, but the ability to execute arbitrary SQL queries presents a significant risk. It is safe when used with read-only databases and carefully constructed queries. It is risky when used with write-enabled databases and untrusted queries.

  • Database access is mediated through the Legion Query Runner, providing a degree of abstraction.
  • MCP integration allows for controlled exposure of database operations to AI assistants.
  • Secure credential management aims to separate credentials from application code.
  • Multi-database configurations allow for isolation of sensitive data.
  • Direct SQL query execution can lead to SQL injection vulnerabilities if not properly sanitized.
  • Lack of explicit RBAC means access control relies on the underlying database permissions.
  • Improperly configured database connections can expose sensitive data.
  • The `execute_query` tool allows arbitrary SQL execution, which can be destructive.