Get the FREE Ultimate OpenClaw Setup Guide →

DatabaseMcpServer

MCP server from ttcc666/DatabaseMcpServer

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ttcc666-databasemcpserver DatabaseMcpServer \
  --env DB_CONFIG_PATH="D:\config\databases.json"

How to use

DatabaseMcpServer is a powerful MCP (Model Context Protocol) server focused on database operations across 19 database types, including mainstream relational databases, some NoSQL options, and domestically-supported engines. It runs as a .NET global tool and exposes a single, configurable MCP entry point that can manage multiple database connections within one server instance. After configuring the databases.json file and wiring up the MCP config (mcp.json or equivalent), you can issue MCP commands through your AI assistant to perform trusted operations like querying, schema management, and health checks across the configured databases. Useful capabilities include multi-database switching within a single instance, safe operation guards, and automatic connection handling to improve performance and reliability.

Available tools cover common database interactions such as querying data, executing updates, examining schemas, managing transactions, invoking stored procedures, and performing health checks. The repository provides command mappings and helper tools for managing connections, testing connectivity, and validating configurations. Typical workflows involve creating a databases.json with multiple connections, pointing the MCP configuration to that file via the DB_CONFIG_PATH environment variable, starting the MCP server, and then using the AI assistant to run predefined MCP actions like list_databases, switch_database, get_current_database, test_connection_by_name, health_check, and test_connection_with_retry.

How to install

Prerequisites:

  • .NET SDK (supported versions as per project, e.g., .NET 9/10 as referenced in the README)
  • Basic familiarity with JSON configuration files

Step 1: Install the DatabaseMcpServer tool globally

# Install latest version
dotnet tool install --global DatabaseMcpServer
# Optional: update in future
# dotnet tool update --global DatabaseMcpServer

Step 2: Prepare database configuration file (databases.json) Create a JSON file that lists your databases, for example:

{
  "databases": [
    {
      "name": "default",
      "connectionString": "Server=localhost;Database=test;Uid=root;Pwd=123456;",
      "dbType": "MySql",
      "description": "默认数据库",
      "isDefault": true
    }
  ]
}

Step 3: Configure MCP server entry (mcp.json) to point to the config file

{
  "mcpServers": {
    "databasemcpserver": {
      "command": "DatabaseMcpServer",
      "env": {
        "DB_CONFIG_PATH": "D:\\config\\databases.json"
      }
    }
  }
}

Step 4: Run the server

  • If you installed as a global tool, you can start using the MCP configuration you created. Typically you would start the IC service (depending on your setup) and then issue MCP commands through your AI assistant or client tooling.

Step 5: Validate installation

  • Use your AI assistant to issue a basic command like "测试数据库连接" or the English equivalent to confirm the server can connect to the configured database and return a sample result.

Additional notes

Notes and tips:

  • The DB_CONFIG_PATH environment variable is required and must point to a valid databases.json file with the correct structure.
  • You can define multiple databases in databases.json and switch between them using the MCP toolset (list_databases, switch_database, get_current_database, test_connection_by_name).
  • Performance and security features include connection pooling and SQL injection safeguards. Review optimizationSettings in each database entry to tailor behavior.
  • If migrating from older 1.x environments, follow the 2.x migration guidance in the README to map old environment variables to the new JSON configuration.
  • Optional environment variables for logging and advanced tuning may be available; consult the official documentation for Seq server integration and additional optimization flags.

Related MCP Servers

Sponsor this space

Reach thousands of developers