Get the FREE Ultimate OpenClaw Setup Guide →

mcp-db

A Spring AI-based MCP capable of executing any SQL query. 一个基于 Spring AI 的MCP服务,可执行任意 SQL。

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jamessmith888-mcp-db-server bash -lc ./mvnw spring-boot:run \
  --env JAVA_HOME="path to JDK 21+"

How to use

MCP-DB is a Spring AI-based MCP server that can execute arbitrary SQL across multiple databases. It exposes an SSE-based transport, allowing multiple clients to connect and issue SQL commands through the MCP protocol. To use it, start the server, then configure your MCP client to point to the SSE endpoint at the server’s URL (by default http://localhost:6789/sse). You can connect with the mcp-db-server configuration in your client, enabling you to run queries against one or more configured data sources. The server supports multiple databases, with a data source configuration file enabling distinct connections, and it provides Groovy script extension capabilities for custom functionality. It also enforces SQL safety controls to prevent dangerous operations from being executed by AI models.

In practice, you’ll typically start the server, configure your AI client’s MCP section with the server URL, and define your DataSource in src/main/resources/datasource.yml. When connected, you can select the target data source and execute SQL via the MCP interface, benefiting from multi-database support, source-level security checks, and optional Groovy script-based extensions for advanced capabilities.

How to install

Prerequisites:

  • Java Development Kit (JDK) 21 or newer
  • Git
  • Maven wrapper (mvnw) or Maven installed

Install steps:

  1. Clone the repository git clone https://github.com/JamesSmith888/mcp-db-server.git cd mcp-db-server

  2. Ensure executable permissions (if needed) chmod +x mvnw

  3. Start the server (development mode) ./mvnw spring-boot:run

  4. Verify the server is running

    • Check console output for a message indicating the server is listening (often on port 6789 for SSE)
  5. Optional: configure your environment for SSE client access

  6. If you prefer Docker/native packaging later, build or pull the corresponding image as needed

Additional notes

Notes and tips:

  • The server supports multiple databases via the datasource.yml configuration file. Ensure you define your data sources and set a default source if needed.
  • SSE mode allows multiple clients to connect concurrently; if you need to ensure compatibility with certain clients, verify they support SSE and the server’s authentication (if configured).
  • You can extend functionality via Groovy scripts as documented in EXTENSIONS.md; this enables custom operators, data handling, or pre/post SQL processing.
  • Ensure Java 21+ is available in your environment (JDK 21+ is required for this project).
  • If you encounter connection issues, verify that the host/port (default 6789) is reachable and that any firewall rules allow SSE traffic.
  • Data source configuration is stored in src/main/resources/datasource.yml; review and edit to add your own databases and credentials.

Related MCP Servers

Sponsor this space

Reach thousands of developers