DB
- javascript
0
GitHub Stars
javascript
Language
3 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": {
"stucchi-db-mcp-server": {
"command": "uvx",
"args": [
"db-mcp-server"
],
"env": {
"DB_URL": "mongodb://localhost:27017",
"DB_HOST": "localhost",
"DB_MODE": "read-only",
"DB_PORT": "3306",
"DB_TYPE": "mysql or mongodb",
"DB_USER": "root",
"DB_DATABASE": "myapp",
"DB_PASSWORD": "secret"
}
}
}
}You can run a dedicated MCP server instance for each database to safely access your MySQL or MongoDB data. This server provides a consistent set of read and write tools per database, without needing Docker. It connects directly to a single database per instance and exposes actionable tools for querying, describing, and inspecting data.
How to use
You interact with the MCP server through an MCP client by launching a per-database server instance and then selecting the available tools for that database. For example, you can perform read-only queries on MySQL or MongoDB collections, or enable read-write mode when you need to insert, update, or delete data. Each database you want to connect requires its own MCP server configuration, ensuring isolated access and clear separation between environments.
How to install
Prerequisites: ensure you have the runtime tool installed that can run MCP servers (in this case, the uvx tool is used to launch the MCP server). You should also have access to the target databases you plan to connect.
Install and start the MCP server for a database using the runtime command shown in the examples.
Configuration and usage notes
Configure each MCP server instance with environment variables to target a single database. The following variables are provided for MySQL and MongoDB configurations.
Additional notes
If you run multiple databases, you can create multiple MCP server definitions, one per database. The configuration example demonstrates how to define a separate instance for each database in your MCP setup.
MySQL configuration
To connect to a MySQL database, set these environment variables in the MCP server configuration.
Required: DB_TYPE must be mysql; DB_DATABASE must be the database name; DB_PASSWORD must be your database password.
Optional: DB_HOST defaults to localhost; DB_PORT defaults to 3306; DB_USER defaults to root; DB_MODE defaults to read-only. You may choose read-only for safe querying or read-write to allow mutations.
MongoDB configuration
To connect to a MongoDB database, set these environment variables in the MCP server configuration.
Required: DB_TYPE must be mongodb; DB_DATABASE must be the database name; DB_URL must be the MongoDB connection string (for example, mongodb://host:port).
Optional: DB_MODE defaults to read-only. You can set read-only or read-write as needed.
Tools overview
The MCP server provides a set of tools for each database type. Use these through your MCP client to perform common operations.
Security considerations
Limit access to the MCP server to trusted clients and use the read-only mode for environments where write access is not required. When you enable read-write mode, ensure proper authentication and least-privilege access to prevent unintended data changes.
Troubleshooting tips
If a connection fails, verify the host, port, database name, and credentials are correct. Check that the target database accepts connections from the MCP server host and that network rules allow the connection.
Examples and snippets
{
"mcpServers": {
"db-prod": {
"command": "uvx",
"args": ["db-mcp-server"],
"env": {
"DB_TYPE": "mysql",
"DB_MODE": "read-only",
"DB_HOST": "db.example.com",
"DB_PORT": "3306",
"DB_USER": "root",
"DB_PASSWORD": "secret",
"DB_DATABASE": "myapp"
}
}
}
}
Install dependencies and start commands
To run a per-database MCP server, first ensure you have the MCP runtime available (for example, uvx). Then start the server with the appropriate environment variables for your target database.
Available tools
query
Execute read-only operations such as SELECT, SHOW, DESCRIBE, EXPLAIN, or aggregation-like reads for the target database.
execute
Execute write operations such as INSERT, UPDATE, or DELETE. Requires DB_MODE to be set to read-write.
describe
Describe the structure of a table or collection to understand its fields and types.
list_tables
List all tables (MySQL) or collections (MongoDB) in the connected database.
status
Show current connection information and the MCP server’s status.
list_collections
List all collections in a MongoDB database.
aggregate
Run aggregation pipelines on MongoDB; note that operations like $out and $merge may be blocked in read-only mode.