mcpField
J
JDBC-MCP - Database Access for AI Assistants

JDBC-MCP - Database Access for AI Assistants

本地服务
github.com/guanghuang数据库033 周前更新

关于 JDBC-MCP - Database Access for AI Assistants

JDBC-MCP 通过 JDBC 连接让 AI 助手检查和查询数据库,也支持创建或修改数据。它基于 Quarkus MCP JDBC Server,提供 Docker 部署,并默认禁用写入 SQL。

主要功能

  1. 01通过 JDBC 访问数据库
  2. 02支持 MCP SSE 和 STDIO
  3. 03Docker 容器部署
  4. 04默认禁用写入 SQL

适用场景

  1. 01让 AI 助手检查数据库结构
  2. 02使用自然语言辅助查询数据
  3. 03在容器中部署数据库 MCP 服务
  4. 04需要时显式启用数据修改操作

MCP 相关

此 MCP 服务通过 JDBC 连接数据库,向 AI 客户端提供检查、查询、创建和修改数据库内容的能力;INSERT、UPDATE、DELETE 默认关闭。可通过 MCP SSE 或 STDIO 使用。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"jdbc": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"\\"
]
}
}
}
启动命令docker run -i --rm '\'

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
oci\

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

JDBC-MCP - 面向 AI 助手的数据库访问

Docker Hub GitHub License

这是 Quarkus MCP JDBC Server 的一个分支版本,新增了以下功能:

  • Docker 部署 - 轻松将 MCP SSE 或 MCP STDIO 作为容器化应用运行
  • 增强安全性 - 默认禁用写入查询(INSERT、UPDATE、DELETE),需要显式启用

模型上下文协议(MCP)服务可让 AI 助手通过 JDBC 连接与数据库交互,使大模型能够检查、查询、创建和修改数据库内容。

新功能

Docker 部署

现在可以在 Docker 容器中运行 JDBC-MCP 服务。

MCP SSE
简单用法
docker run -d --name jdbc-mcp \
  -p 8080:8080 \
  -e enable.write.sql=false \
  -e jdbc.user=db_user \
  -e jdbc.password=db_password \
  -e jdbc.url=jdbc:postgresql://host:port/database \
  guang1/jdbc-mcp:latest
使用环境文件

创建一个 .env 文件:

enable.write.sql=false
jdbc.user=db_user
jdbc.password=db_password
jdbc.url=jdbc:postgresql://host:port/database

然后运行:

docker run -d --name jdbc-mcp \
  -p 8080:8080 \
  --env-file .env \
  guang1/jdbc-mcp:latest
用于 SSE 的 Docker Compose
基本示例
services:
  jdbc-mcp:
    container_name: jdbc-mcp
    ports:
      - 8080:8080
    environment:
      - enable.write.sql=false
      - jdbc.user=db_user
      - jdbc.password=db_password
      - jdbc.url=jdbc:postgresql://host:port/database
    restart: always
    image: guang1/jdbc-mcp:latest
使用环境文件
services:
  jdbc-mcp:
    container_name: jdbc-mcp
    ports:
      - 8080:8080
    env_file:
      - .env
    restart: always
    image: guang1/jdbc-mcp:latest
MCP SSE URL

http://localhost:8080/mcp/sse

MCP STDIO

Must pass quarkus.mcp.server.stdio.enabled=true, quarkus.log.console.enable=false and quarkus.log.console.stderr=false environment variables with -i interactive option.

Simple usage
docker run --rm \
  -e enable.write.sql=false \
  -e jdbc.user=db_user \
  -e jdbc.password=db_password \
  -e jdbc.url=jdbc:postgresql://host:port/database \
  -e quarkus.mcp.server.stdio.enabled=true \
  -e quarkus.log.console.enable=false \
  -e quarkus.log.console.stderr=false \  
  guang1/jdbc-mcp:latest
Using an Environment File
docker run --rm 
  --env-file .env \
   -e quarkus.mcp.server.stdio.enabled=true \
   -e quarkus.log.console.enable=false \
   -e quarkus.log.console.stderr=false \  
  guang1/jdbc-mcp:latest
Claude Desktop Configuration (STDIO)

To use the Docker version with Claude Desktop, add this to your claude_desktop_config.json or server_config.json file:

Simple usage
{
  "mcpServers": {
    "jdbc": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-e",
        "enable.write.sql=false",
        "-e",
        "jdbc.user=db_user",
        "-e",
        "jdbc.password=db_password",
        "-e",
        "jdbc.url=jdbc:postgresql://host:port/database",
        "-e",
        "quarkus.mcp.server.stdio.enabled=true",
        "-e",
        "quarkus.log.console.enable=false",
        "-e",
        "quarkus.log.console.stderr=false",
        "-i",
        "guang1/jdbc-mcp:latest"
      ]
    }
  }
}
Using an Environment File
{
  "mcpServers": {
    "jdbc": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "--env-file",
        ".env",
        "-e",
        "quarkus.mcp.server.stdio.enabled=true",
        "-e",
        "quarkus.log.console.enable=false",
        "-e",
        "quarkus.log.console.stderr=false",
        "-i",
        "guang1/jdbc-mcp:latest"
      ]
    }
  }
}

Configuration

Environment Variables
VariableDescriptionDefault
jdbc.urlJDBC connection URL (required)-
jdbc.userDatabase username-
jdbc.passwordDatabase password-
enable.write.sqlEnable SQL operations that modify datafalse
Supported Database Types

This MCP server supports multiple database types through JDBC. For detailed information on supported JDBC variants, please see the quarkus-mcp-servers/jdbc documentation.

Security Considerations

⚠️ Warning: When enable.write.sql is set to true, the MCP server can execute SQL statements that modify data. Use with caution in production environments.

Consider these best practices:

  • Use read-only database users when possible
  • Implement network-level access controls
  • Run in an isolated network environment

Using with LLMs

This MCP server provides a standardized API that Large Language Models can use to interact with your database. To connect your LLM:

  1. Configure the LLM to use the MCP server endpoint
  2. Define the capabilities you want to allow (read-only vs. read-write)
  3. Ensure your database schema is accessible to the MCP server
Write Query Security

By default, write operations (INSERT, UPDATE, DELETE) are disabled for security. To enable them:

  • When using Docker: add -e enable.write.sql=true as shown above

Original Documentation

For all other features, including supported databases, general usage, example databases, MCP components, and troubleshooting, please refer to the original repository documentation:

Quarkus MCP JDBC Server Documentation

License

This project is licensed under the Apache License 2.0.

Acknowledgments

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。