- Home
- MCP servers
- Database
Database
- python
3
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"georgi-terziyski-database_mcp_server": {
"command": "python",
"args": [
"-m",
"db_mcp_server"
],
"env": {
"DB_CONFIG_PATH": "/path/to/db_config.json",
"DB_CONNECTIONS": "connections_config_or_json_string"
}
}
}
}You run a dedicated MCP server that provides a unified interface for connecting to and operating multiple database systems. It lets you manage connections, execute queries, work with schemas, and control transactions from a single, consistent set of tools.
How to use
You interact with the Database MCP Server through an MCP client or by running its built-in web interface. The server exposes tools for connection management, query execution, schema management, and transaction control. Use it to connect to SQLite, PostgreSQL, MySQL/MariaDB, and SQL Server databases, then perform common operations without switching between database-specific clients.
How to install
Prerequisites: Python 3.8 or higher and the pip package manager.
Clone the project and install the package in editable mode so you can run and develop it locally.
# Clone the repository
git clone <repository-url>
# Install the package in editable mode
pip install -e .
Configuration and runtime
Configure how the server connects to databases and how you start it. You can set connections via a JSON configuration file, environment variables, or by passing details at runtime.
{
"connections": {
"sqlite_conn": {
"type": "sqlite",
"db_path": "/path/to/database.db"
},
"postgres_conn": {
"type": "postgres",
"host": "localhost",
"port": 5432,
"database": "mydatabase",
"user": "myuser",
"password": "mypassword"
}
}
}
Running the server
Run the MCP server as a Python module for your core MCP interface or use the web server for broader access. You can start with default settings or point to a specific configuration file and adjust logging as needed.
# Run the MCP server with default settings
python -m db_mcp_server
# Run with an explicit configuration file
python -m db_mcp_server --config /path/to/config.json
# Set logging level
python -m db_mcp_server --log-level DEBUG
Example configuration and common operations
Below are representative examples showing how to define a configuration and perform common tasks. Use these as a starting point and adapt to your environment.
{
"connections": {
"sqlite_conn": {"type": "sqlite", "db_path": "/path/to/database.db"},
"postgres_conn": {"type": "postgres", "host": "localhost", "port": 5432, "database": "mydatabase", "user": "myuser", "password": "mypassword"}
}
}
Security and maintenance notes
Protect access to the MCP server by configuring strong authentication for any HTTP interfaces, securing configuration files, and rotating credentials regularly. Keep database drivers up to date and monitor connection activity for unusual access patterns.
If you run a web server, consider placing it behind a reverse proxy and enabling TLS to protect data in transit.
Troubleshooting notes
If you encounter connection issues, verify that the database server is reachable from the MCP host, the credentials are correct, and the required database drivers are installed. Check logs for detailed error messages to guide you toward the root cause.
Available tools
add_connection
Add a new database connection to the MCP server configuration.
test_connection
Test the connectivity to a configured database.
list_connections
List all configured database connections.
remove_connection
Remove a configured database connection.
execute_query
Execute a SQL query against a configured database.
get_records
Retrieve records from a table using a query.
insert_record
Insert a new record into a table.
update_record
Update existing records in a table.
delete_record
Delete records from a table.
list_tables
List all tables within a connected database.
get_table_schema
Retrieve the schema for a specific table.
create_table
Create a new table with defined columns.
drop_table
Remove a table from the database.
create_index
Create an index on a table to optimize queries.
drop_index
Remove an index from a table.
alter_table
Change the structure of an existing table.
begin_transaction
Begin a new transaction.
commit_transaction
Commit the current transaction.
rollback_transaction
Rollback the current transaction.