fu-orm-code-generator
v1.0.11
Published
A Model Context Protocol (MCP) server for MyBatis code generation with enterprise-grade layered architecture
Downloads
18
Maintainers
Readme
Fu ORM Code Generator
A Model Context Protocol (MCP) server for MyBatis code generation with enterprise-grade layered architecture.
Features
- 🚀 Batch Code Generation: Generate ORM code for multiple database tables at once
- 🏗️ Enterprise Architecture: Built with layered architecture and dependency injection
- 🔄 Smart Conversion: Automatically converts database field names (snake_case) to Java property names (camelCase)
- 📋 Template Support: Multiple code generation templates including MyBatis Plus and enterprise patterns
- 🎯 Type Mapping: Comprehensive database type to Java type mapping
- 📝 Rich Documentation: Generated code includes complete Javadoc comments
Installation
npm install -g fu-orm-code-generatorUsage
This MCP server provides tools for generating MyBatis ORM code. It's designed to work with MCP-compatible clients like Claude Desktop.
Available Tools
- generate_orm_code: Batch generate ORM code from database table structures
- visit_online_templates: Browse available online templates
- download_online_template: Download templates from remote server
- choose_local_template: Select a local template for code generation
- visit_local_templates: View locally available templates
- set_user_info: Configure user information for code comments
- get_user_info: View current user configuration
Example Usage
// Generate ORM code for multiple tables
{
"basePackage": "com.example.project",
"mainSourceDirectory": "/path/to/project/src/main/java",
"tables": [
{
"tableName": "user_info",
"remark": "User information table",
"fields": [
{
"fieldName": "id",
"dataType": "BIGINT",
"remark": "User ID"
},
{
"fieldName": "user_name",
"dataType": "VARCHAR",
"remark": "Username"
}
]
}
]
}Generated Code Structure
For a table named user_info, the generator creates:
- Entity:
com.example.entity.UserInfo.java - Mapper:
com.example.mapper.UserInfoMapper.java - Repository:
com.example.repository.IUserInfoRepository.java - Service:
com.example.service.IUserInfoService.java - Controller:
com.example.controller.UserInfoController.java
Type Mappings
| Database Type | Java Type | |---------------|-----------| | TINYINT, SMALLINT, INT, INTEGER | java.lang.Integer | | BIGINT | java.lang.Long | | FLOAT, DOUBLE, DECIMAL, NUMERIC | java.math.BigDecimal | | CHAR, VARCHAR, TEXT, etc. | java.lang.String | | DATE, TIME, DATETIME, TIMESTAMP | java.lang.String | | BOOLEAN, BOOL, BIT | java.lang.Boolean |
Configuration
The server stores configuration in data/config.json and supports:
- Template selection
- User information (author name and email)
- Custom template directories
Templates
Two built-in templates are available:
- mybatis_plus: Standard MyBatis Plus template
- 期货管理平台(无需审批): Enterprise futures management platform template
Architecture
The project follows a clean layered architecture:
- Presentation Layer: MCP tool handlers
- Application Layer: Business logic services
- Domain Layer: Core entities and repository interfaces
- Infrastructure Layer: Concrete implementations
Requirements
- Node.js >= 16.0.0
- MCP-compatible client (e.g., Claude Desktop)
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
