Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fu-orm-code-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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-generator
Usage
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.