Loading...

Database MCP provides a unified interface to query and manage multiple databases via the Model Context Protocol, enabling AI assistants to interact with data.
Boost this tool
Subscribe to listing upgrades or segmented pushes.
Database MCP provides a unified interface to query and manage multiple databases via the Model Context Protocol, enabling AI assistants to interact with data.
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.
Performance depends on the complexity of the SQL queries and the performance of the underlying databases. Consider optimizing queries and using database indexes to improve performance.
Cost depends on the resources used by the databases and the MCP server. Consider the cost of database hosting, network bandwidth, and server resources.
pip install database-mcp{
"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": []
}
}
}DB_TYPEDB_CONFIGDB_CONFIGSexecute_queryExecutes 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.
execute_query_jsonExecutes a SQL query and returns results as JSON.
Allows arbitrary SQL execution, potentially leading to data modification or deletion.
get_table_columnsRetrieves the column names for a specified table.
Read-only operation, no side effects.
get_table_typesRetrieves the column types for a specified table.
Read-only operation, no side effects.
get_query_historyRetrieves the recent query history.
Read-only operation, no side effects.
list_databasesLists all available database connections.
Read-only operation, no side effects.
get_database_infoRetrieves detailed information about a database, including its schema.
Read-only operation, no side effects.
find_tableFinds which database contains a specific table.
Read-only operation, no side effects.
describe_tableRetrieves a detailed description of a table, including column names and types.
Read-only operation, no side effects.
get_table_sampleRetrieves a sample of data from a table.
Read-only operation, no side effects.
Environment Variable
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.
Autonomy depends on the configured database permissions and the queries executed. Exercise caution when granting autonomous access to write-enabled databases.
Production Tip
Monitor database performance and resource usage to ensure optimal performance and prevent bottlenecks.
PostgreSQL, MySQL, SQL Server, and other databases supported by Legion Query Runner.
Using environment variables or command-line arguments with JSON configuration.
Use the `db_id` parameter with the database-specific tools.
Yes, the server automatically discovers and exposes database schemas.
Store credentials securely using environment variables and restrict access to the server.
Yes, the server is designed to work with AI development environments like LangChain.
MCP is a specification for maintaining context in AI applications, used here to expose database operations as tools.