关于 JDBC-MCP - Database Access for AI Assistants
JDBC-MCP 通过 JDBC 连接让 AI 助手检查和查询数据库,也支持创建或修改数据。它基于 Quarkus MCP JDBC Server,提供 Docker 部署,并默认禁用写入 SQL。
主要功能
- 01通过 JDBC 访问数据库
- 02支持 MCP SSE 和 STDIO
- 03Docker 容器部署
- 04默认禁用写入 SQL
适用场景
- 01让 AI 助手检查数据库结构
- 02使用自然语言辅助查询数据
- 03在容器中部署数据库 MCP 服务
- 04需要时显式启用数据修改操作
MCP 相关
此 MCP 服务通过 JDBC 连接数据库,向 AI 客户端提供检查、查询、创建和修改数据库内容的能力;INSERT、UPDATE、DELETE 默认关闭。可通过 MCP SSE 或 STDIO 使用。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
JDBC-MCP - 面向 AI 助手的数据库访问
这是 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
| Variable | Description | Default |
|---|---|---|
jdbc.url | JDBC connection URL (required) | - |
jdbc.user | Database username | - |
jdbc.password | Database password | - |
enable.write.sql | Enable SQL operations that modify data | false |
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:
- Configure the LLM to use the MCP server endpoint
- Define the capabilities you want to allow (read-only vs. read-write)
- 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=trueas 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
- Original project: Quarkiverse MCP Servers
- Built with Quarkus
- Containerized with Docker
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。