DBJavaGenix
The DBJavaGenix MCP server automates AI-driven reverse engineering of databases into Spring Boot Java projects, offering 29 tools across database interaction, code generation, semantic analysis, visualization, and observability.
Database Connection & Exploration
Connect to MySQL, PostgreSQL, SQLite, Oracle, or SQL Server
List databases and tables, check table existence, execute safe SELECT queries
Describe table structure: columns, types, primary keys, foreign keys, indexes, and Java type mappings
Atomic Code Generation (Recommended Workflow)
Build a reusable template context from a DB table (
codegen_build_context)Render and preview individual Spring Boot layers before saving:
codegen_render_entity– JPA/MyBatis-Plus Entitycodegen_render_dao– DAO/Repository layercodegen_render_service– Service interface + ServiceImplcodegen_render_controller– REST Controller with Bean Validationcodegen_render_mapper– MyBatis XML or MapStruct mapper
Legacy single-shot generation (analyze + write all layers at once) also available
Spring Boot Project Management
Validate project structure and dependencies
Analyze dependencies for recommendations (Lombok, Swagger, MapStruct, etc.)
Read YAML/Properties config and infer base package
AI Semantic Enhancement
Infer business-appropriate Java class/field names using 15 naming rules or Claude API
Recommend template category (Default, MybatisPlus, MybatisPlus-Mixed, Spring Boot 3.5 + Java 21) and detect business patterns (RBAC, e-commerce, CMS, ticketing)
Summarize entire database schema in natural language
View AI usage metrics: cache hit rate, tokens saved
Visualization
Generate Mermaid ER diagrams for multiple tables
Observability & Health
Monitor runtime metrics: tool call counts, average latency, error rates
Check server health: Python/SDK versions, module status, active DB connections
Progressive Tool Discovery
Search available tools by keyword, reducing startup token usage by ~70%
Provides tools for connecting to MySQL databases, querying tables, and retrieving schema information for Spring Boot code generation
Generates complete Spring Boot projects including Entity, DAO, Service, Controller, and Mapper layers from database schemas
Supports SQLite databases with tools for connection, table discovery, and schema extraction for code generation
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DBJavaGenix generate Spring Boot code from sys_user and sys_role tables"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
DBJavaGenix
把"用 LLM 看着数据库做反向工程"做成一件可重复、可审计的事。 Skills 定义"怎么做" · MCP 提供"能做什么" · MCP Apps 让结果"看得见"。

graph LR
Client[Claude Desktop / Cursor / Cherry] -->|Skill 加载| Skills
Skills[".claude/skills/<br/>java-codegen-from-db<br/>springboot-migration"]
Skills -->|按需调用| MCP
subgraph MCP[MCP Server 34 工具]
direction TB
DB[db_* 连接 / 查询 / 描述]
Atom[codegen_build_context<br/>codegen_render_entity/dao/service/<br/>controller/dto/mapper]
Graph[schema_topo_order<br/>schema_cluster_tables<br/>schema_check_cycles]
AI[ai_infer_business_names<br/>ai_recommend_template<br/>ai_summarize_schema]
Vis[db_render_er_diagram]
Obs[server_metrics / server_health<br/>ai_metrics / search_tools]
end
MCP -->|返回 _meta| Apps[MCP Apps 渲染]
Apps -->|mermaid / dashboard / code-diff / tree| Client
MCP -->|读取| Data[MySQL / PostgreSQL / SQLite + Mustache templates]它解决什么问题
把数据库表反向生成成 Spring Boot 工程 (Entity/DAO/Service/Controller/DTO/Mapper) 不是新东西 —— EasyCode、MyBatis-Plus Generator、Renren-generator 都做了多年。LLM 时代的区别在于:
维度 | 老工具 | DBJavaGenix v0.2 |
工作流谁定 | 用户在 IDE 点配置面板 | Skill 文件显式编排 (LLM 不会乱调) |
调用粒度 | 一个大按钮一步到位 | 7 个原子工具 (build_context + 6 个 render_*),LLM 可中途让用户改 context 重渲 |
启动开销 | (插件,常驻) | 默认 ~3300 tok / 渐进模式 ~985 tok (节省 70%) |
命名 | 表前缀机械映射 | 15 条规则 + Claude API,识别 RBAC/电商/CMS 模式 |
输出可视化 | IDE 内文本 | MCP Apps: Mermaid ER 图 / 依赖仪表盘 / code-diff / 包结构树 |
可观测性 | 无 | server_metrics + ai_metrics + server_health |
Related MCP server: spring-api-intel-mcp
快速开始
Docker (推荐)
docker build -t dbjavagenix:latest .在 claude_desktop_config.json 添加:
{
"mcpServers": {
"dbjavagenix": {
"command": "docker",
"args": ["run", "-i", "--rm",
"-e", "DBJAVAGENIX_PROGRESSIVE=1",
"-e", "ANTHROPIC_API_KEY",
"dbjavagenix:latest"]
}
}
}本地 dev
git clone https://github.com/ZhaoXingPeng/DBJavaGenix.git
cd DBJavaGenix
uv venv && uv pip install -e ".[dev]"
PYTHONPATH=src python -m dbjavagenix.cli server数据库支持范围
当前可连接、查询并读取元数据的数据库为 MySQL、PostgreSQL 和 SQLite。Oracle 与 SQL Server 的类型映射保留为后续扩展准备,但尚未实现运行时驱动和元数据契约,不能作为 当前可用数据库声明。
第一次使用
在 LLM 客户端里说 "从数据库 myapp 的 sys_user / sys_role / sys_user_role 三张表生成 Spring Boot 代码",Claude 会:
加载
java-codegen-from-dbSkill,按 5 阶段工作流推进调用
db_connect_test→db_table_describe→db_table_foreign_keys收集 schema调用
db_render_er_diagram→ 客户端渲染 Mermaid ER 图调用
ai_infer_business_names推断 →sys_user_role应是UserRoleAssignment调用
ai_recommend_template推荐 → 检测到 RBAC,推MybatisPlus-Mixed用
codegen_build_context+ 6 个codegen_render_*分层生成,每层返回 code-diff用户确认后写盘
会话结束时调用
db_disconnect(connection_id)释放连接
核心能力 (Phase 1 → 5)
Phase 1 现代化基础
Python ≥ 3.11 / mcp ≥ 1.6 / Spring Boot 3.5 + Java 21 模板
单元测试 620+,GitHub Actions 分层 CI(提交策略、三版本质量、格式、数据库集成、模板、Docker、打包安装)
多阶段 Dockerfile (
python:3.11-slim+ 非 root 用户)
Phase 2 Skills 层与原子工具
.claude/skills/java-codegen-from-db/SKILL.md显式定义 5 阶段工作流db_codegen_generate拆为 7 原子工具,context 显式传递search_tools工具实现 progressive discovery,启动 token 节省 70.2%第二个 Skill
springboot-migration(2.7→3.x 升级 checklist)
Phase 3 MCP Apps 集成
4 个交互式 UI 组件:
组件 | 类型 | 来源工具 |
ER 图 |
|
|
依赖健康仪表盘 |
|
|
代码预览 + Diff |
|
|
包结构树 |
|
|
Phase 4 AI 语义增强
ai_infer_business_names: 15 条规则 + 可选 Claude API (Anthropic SDK + prompt caching)ai_recommend_template: 检测 RBAC / 电商 / CMS / 工单 4 种模式ai_summarize_schema: 整库自然语言概述ai_metrics: 暴露 cache_hit_rate / tokens_saved设计取舍: 规则先于 LLM,无
ANTHROPIC_API_KEY也能跑
Phase 5 可观测性与生产就绪
server_metrics: 每个工具的 calls / avg_duration / error_rateserver_health: Python / mcp / anthropic SDK 版本 + 模块导入状态结构化日志:
DBJAVAGENIX_LOG_FORMAT=json可输出单行 JSON,适合 Loki/ELK部署手册: 3 种部署模式 + 6 个排障场景
工具总览 (34 个)
类别 | 工具 |
连接 / 查询 | db_connect_test / db_disconnect / db_query_databases / db_query_tables / db_query_table_exists / db_query_execute |
表结构 | db_table_describe / db_table_columns / db_table_primary_keys / db_table_foreign_keys / db_table_indexes |
Schema 图算法 | schema_topo_order / schema_cluster_tables / schema_check_cycles |
代码生成 (atomic) | codegen_build_context / codegen_render_entity / codegen_render_dao / codegen_render_service / codegen_render_controller / codegen_render_dto / codegen_render_mapper |
代码生成 (legacy) | db_codegen_analyze / db_codegen_generate |
Spring Boot 项目 | springboot_validate_project / springboot_analyze_dependencies / springboot_read_config |
可视化 | db_render_er_diagram |
AI 语义 | ai_infer_business_names / ai_recommend_template / ai_summarize_schema / ai_metrics |
可观测 | server_metrics / server_health |
元工具 | search_tools (渐进发现) |
与同类工具对比
维度 | DBJavaGenix v0.2 | EasyCode | MyBatis-Plus generator | Renren-generator |
驱动方式 | LLM + MCP | IDEA 插件 | 命令行 / Maven plugin | Web UI |
工作流编排 | Skill 显式 5 阶段 | 配置面板 | 一次性代码 | 表单 |
工具粒度 | 6 原子 (可中途让用户改) | 单按钮 | 单命令 | 单按钮 |
AI 命名 | ✅ 15 规则 + 可选 LLM | ❌ 纯模板 | ❌ | ❌ |
模板扩展 | ✅ Mustache + 4 分类 (sb35-java21 含) | ✅ Velocity | ⚠️ 仅 MybatisPlus | ⚠️ 仅 freemarker |
ER 图渲染 | ✅ Mermaid (MCP App) | ❌ | ❌ | ⚠️ 静态 |
依赖适配 | ✅ 智能档案 + 健康分 | ❌ | ❌ | ❌ |
可观测性 | ✅ in-process metrics + health | ❌ | ❌ | ❌ |
客户端兼容 | Claude Desktop / Cursor / Cherry / ... | 仅 IDEA | CLI | 浏览器 |
技术架构

详见 iteration-plan/01-target-architecture.md。三层职责:
[ Skills 层 ] 定义"怎么做" — .claude/skills/*.md 显式 5 阶段工作流
↓
[ MCP 层 ] 提供"能做什么" — 34 个原子工具 context 显式传递
↓
[ Apps 层 ] 让结果"看得见" — 4 个 UI 组件 (mermaid/dashboard/code-diff/tree)每层都做"工程克制":
不引入向量数据库 (schema 是结构化数据,LLM 直接读更准)
不引入 LangChain (Skill 已显式编排,不需要 chain 抽象)
不引入 prometheus_client / opentelemetry-sdk (stdio 单进程过度设计)
文档
文档 | 内容 |
6 阶段重构方案 (目标架构 / 路线图 / 决策记录 / 演示故事) | |
部署模式 / 环境变量 / 健康检查 / 排障 | |
tool schema token 测量 | |
功能冻结后的架构、集成、质量与发布收尾路线 | |
MCP Apps 4 组件客户端兼容性 | |
v0.2.1 schema 图算法 (topo / cluster / cycle) | |
生成器与生成代码中的设计模式 | |
15 个 ADR (架构 / 原子 / 渐进 / 规则 / 不引依赖 / schema 算法 / 规范配置 / MCP v3 / 1h 缓存 / agentic / 多方言 / SDK 契约 / 工具契约 / 元数据契约 / 连接生命周期) | |
主 Skill: 代码生成 5 阶段工作流 | |
第二 Skill: Spring Boot 2.7→3.x 迁移 |
路线图
Phase 1: 基础设施现代化 (Python 3.11 / mcp 1.6 / Spring Boot 3.5 模板 / CI / Docker)
Phase 2: Skills 层抽离 + 原子工具 + Progressive Discovery (token -70%)
Phase 3: MCP Apps 集成 (4 个 UI 组件)
Phase 4: AI 语义增强 (规则 + 可选 LLM)
Phase 5: 可观测性 + 生产就绪
Phase 6: 文档与演示
v0.2.1: Java 工程补完 (schema 算法 3 个 / 工程规范配置生成器 / 设计模式 catalog)
v0.2.2: MCP v3 + AI 工程化 (elicitation 表单 / sampling 借 LLM / 1h prompt caching / agentic-runner)
下一步 (v0.3 候选):
完整优先级、前置条件和验收证据见
docs/roadmap-v0.3.md。当前列表仅代表候选工作,不代表已实现或预先承诺的性能收益;CI 收尾安排在功能冻结之后。
启动模式
模式 | 入口 | 触发 | 依赖 | 适用场景 |
MCP server |
| 客户端连接 (Claude Desktop / Cursor 等) | 无额外 | 探索 / 多轮交互 / 默认 |
Agentic runner |
| CLI 单次启动 |
| 批处理 / CI / 一次性任务 |
两种模式共用同一 database.mcp_tools 注册表 (ADR-010)。
调试技巧
# 启用 progressive 模式 (仅暴露 6 个 always_visible 工具)
DBJAVAGENIX_PROGRESSIVE=1 PYTHONPATH=src python -m dbjavagenix.cli server
# JSON 日志 (适合 Loki / ELK)
DBJAVAGENIX_LOG_FORMAT=json DBJAVAGENIX_LOG_LEVEL=DEBUG \
PYTHONPATH=src python -m dbjavagenix.cli server
# headless 验证所有 MCP App 组件
PYTHONPATH=src python scripts/verify_mcp_apps.py贡献
Fork → 创建 feature/* 分支
写测试 (
tests/unit/),pytest tests/unit/应保持 620+ 全过ruff check src/ tests/通过 (CI 会跑)提 PR,链接到对应的 iteration-plan 阶段
许可证
MIT — 见 LICENSE。
致谢
EasyCode — 早期模板设计灵感
Model Context Protocol — Anthropic / Linux Foundation
Anthropic Claude — AI 语义层
联系
Available Tools
29 toolsai_infer_business_namesA
从数据库表/列推断 Spring Boot 项目中业务上合理的 Java 命名。默认基于 15 条命名规则; 设 prefer_llm=true 且 ANTHROPIC_API_KEY 可用时,优先调用 Claude (启用 prompt caching 节省 token)。返回每张表的 class_name + reason + table_kind (entity/association/log/dict/config)。
Inputs: tables (required), prefer_llm, model.
ai_metricsA
返回进程内累积的 AI 调用指标 (Prompt Caching 命中率、token 消耗、错误次数)。对应 P4.4: ai.cache_hit_rate / ai.tokens_saved_via_cache 等。可在每次 ai_infer_business_names 等工具调用后查询。
Inputs: reset.
ai_recommend_templateA
根据整库表名 + FK 关系推荐 template_category (Default/MybatisPlus/MybatisPlus-Mixed/sb35-java21) + 生成选项 (useSwagger/useLombok/include_mapstruct/generate_dto/generate_vo)。检测 RBAC / 电商 / CMS / 工单 等典型业务模式。传 hint_modern_stack=true 强制推 sb35-java21 (Java 21 + jakarta)。
Inputs: table_names (required), foreign_keys, hint_modern_stack.
ai_summarize_schemaA
对整库 schema 做自然语言概述: 总览、模块划分 (按前缀)、核心实体 (列数 + 命中模式)、关键关系。便于用户理解大库,或在生成前对齐 LLM 的 mental model。
Inputs: table_names (required), foreign_keys, table_column_counts.
codegen_build_contextA
构建代码生成所需的完整模板上下文(不写盘,不渲染)。这是原子代码生成工作流的第一步,后续 codegen_render_* 工具的输入。返回的 context dict 可被 LLM 检视或修改,再传给后续工具。
Inputs: connection_id (required), table_name (required), database, template_category, +6 more.
codegen_render_controllerA
渲染 REST Controller(@RestController + Bean Validation)。需要先调用 codegen_build_context 获取 context。
Inputs: context (required).
codegen_render_daoA
渲染 DAO/Repository 层(JpaRepository 或 BaseMapper)。需要先调用 codegen_build_context 获取 context。
Inputs: context (required).
codegen_render_entityA
渲染 Entity 层(JPA @Entity / MybatisPlus @TableName)。需要先调用 codegen_build_context 获取 context。返回单个 java 文件源码。
Inputs: context (required).
codegen_render_mapperA
渲染 MyBatis XML mapper 或 MapStruct mapper。适用模板: Default(mapper.xml) / MybatisPlus-Mixed(mapper) / 含 useMapStruct(mapstruct_mapper)。sb35-java21 分类不需要 mapper,会返回空 files 列表。
Inputs: context (required).
codegen_render_serviceA
渲染 Service 接口 + ServiceImpl 实现。需要先调用 codegen_build_context 获取 context。返回 2 个 java 文件。
Inputs: context (required).
db_codegen_analyzeC
Analyze database table structure for code generation with template context
Inputs: connection_id (required), table_name (required), database, template_category, +3 more.
db_codegen_generateA
[Legacy / single-shot] Generate Java code from database table analysis using templates. Prefer the atomic workflow: codegen_build_context + codegen_render_entity/dao/service/controller/mapper (P2.2). This single-shot tool also writes files to disk in one go, with no preview/edit cycle.
Inputs: connection_id (required), table_name (required), database, template_category, +6 more.
db_connect_testB
Test database connection and create connection session
Inputs: host (required), port (required), username (required), password (required), +3 more.
db_query_databasesB
List all databases on the server
Inputs: connection_id (required).
db_query_executeA
Execute custom SQL query (SELECT only for safety)
Inputs: connection_id (required), query (required), limit.
db_query_table_existsA
Check if a table exists in the database
Inputs: connection_id (required), database (required), table (required).
db_query_tablesB
List all tables in a specific database
Inputs: connection_id (required), database (required).
db_render_er_diagramA
生成多个表的 Mermaid ER 图 (MCP App: mermaid 组件)。调用前需已通过 db_connect_test 建立连接。支持 MCP Apps 的客户端会渲染图表;不支持的客户端会看到纯文本摘要 + mermaid 源码。
Inputs: connection_id (required), database (required), tables (required), include_non_pk_columns.
db_table_columnsC
Get detailed column information for a table
Inputs: connection_id (required), database (required), table (required).
db_table_describeB
Get complete table structure information including columns, types, constraints
Inputs: connection_id (required), database (required), table (required), include_java_types.
db_table_foreign_keysC
Get foreign key relationships for a table
Inputs: connection_id (required), database (required), table (required).
db_table_indexesC
Get index information for a table
Inputs: connection_id (required), database (required), table (required).
db_table_primary_keysC
Get primary key information for a table
Inputs: connection_id (required), database (required), table (required).
search_toolsA
按关键词搜索可用 MCP 工具,用于渐进式发现 (Progressive Discovery)。当用户提到的操作不在当前可见工具列表中时,先用此工具搜索,再调用返回的工具。示例: query='render dao' → 返回 codegen_render_dao + 相关工具。传空 query 列出所有 always_visible 工具。
Inputs: query, limit.
server_healthA
返回 server 健康状态: Python 版本、mcp SDK 版本、核心模块导入是否成功、DB 连接活跃数、OS 信息。用于部署后冒烟检查。
Inputs: no named parameters.
server_metricsB
返回 DBJavaGenix MCP server 的运行时指标: uptime、每个工具的调用次数 / 平均时延 / 错误率。轻量级 in-process,不依赖 Prometheus。
Inputs: reset.
springboot_analyze_dependenciesB
Analyze project dependencies and generate intelligent recommendations for code generation
Inputs: template_category (required), database_type (required), include_swagger, include_lombok, +2 more.
springboot_read_configB
Read Spring Boot project configuration (YAML/Properties/Bootstrap) and infer base package
Inputs: project_path, active_profile, include_profiles, merge_strategy.
springboot_validate_projectB
Validate SpringBoot project structure and dependencies before code generation
Inputs: check_dependencies, create_missing_dirs, template_category.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 29 tools
Each tool targets a distinct action: database exploration, code generation layers, AI assistance, server health, and Spring Boot analysis. Overlap is minimal, and even similar tools (e.g., db_table_columns vs. db_table_describe) have clearly different purposes.
While most tools follow a prefix_verb_noun pattern, there are inconsistencies: legacy tools use db_codegen_ instead of codegen_, and some tools (ai_metrics, server_health) omit the verb entirely. This mixed convention can confuse an agent.
With 29 tools, the count exceeds the '25+' threshold for 'too many' per the rubric. The surface includes granular DB detail tools (e.g., separate tools for each table attribute) and duplicate code generation workflows (legacy vs. atomic), inflating the count unnecessarily.
The tool set covers the full lifecycle from database connection and schema analysis to AI-powered naming and code generation for various layers. Minor gaps include lack of batch generation for multiple tables or an update mechanism for changes after generation.
Maintenance
Related MCP Connectors
Design domain models and generate deterministic multi-stack code, driven by your coding agent.
Build Spring Boot applications, ready for coding agents, including best practices.
Generate, edit, and export data-architecture diagrams from your AI. Column lineage, PNG in chat.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables natural language database operations on MySQL databases with AI integration, supporting CRUD operations, schema inspection, and audit logging with built-in security features including SQL injection protection and permission controls.828 npmMIT
- AlicenseAqualityDmaintenanceEnables AI assistants to understand and analyze Spring Boot codebases through static analysis, allowing natural language queries about endpoints, classes, dependencies, and architecture without running the application.13MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read and write MySQL databases, dynamically switch databases/servers, and auto-configure from Spring Boot projects.828 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEnables enterprise database schema exploration and Spring Boot code generation (MyBatis, JPA) through MCP, supporting both online DB connections and offline DDL parsing.-