代码生成平台

CodeForge是一个代码生成平台,帮助开发者快速集成数据库、认证、消息队列等多种能力到应用中,通过自然语言描述需求生成生产就绪的集成代码。

  • by Swaroop86
  • Java
  • 本地部署
  • 更新于
在 GitHub 查看 swaroop86/mcp-capability-server

使用说明

CodeForge-基于人工智能的能力集成平台

为数据库、身份验证、消息传递等生成生产就绪的集成代码

快速开始 • 建筑 • 支持的功能 • 安装脚本


🎯 什么是CodeForge?

CodeForge是一个代码生成平台,可帮助开发人员将各种功能(数据库、身份验证、消息传递、缓存等)快速集成到他们的应用程序中。你不用编写样板集成代码,而是用自然语言描述你需要什么,CodeForge会根据最佳实践生成生产就绪的代码。

CodeForge做什么

  • 生成集成代码:将应用程序连接到数据库、身份验证系统、消息队列等的完整代码。
  • 遵循最佳实践:生成的代码包括正确的错误处理、连接池、重试逻辑和安全模式
  • 多栈支持:适用于Java/Spring Boot、Python/FastAPI、Node.js/Express、Go等
  • IDE集成:在现有开发环境中无缝工作

CodeForge不做什么

  • 不生成业务逻辑或应用程序功能
  • 不会修改您的核心应用程序架构
  • 不需要云依赖(可以完全在本地运行)

🏗️ 建筑

CodeForge的工作原理

┌──────────────────────────────────────────────────────────────────┐
│                        Your Development Machine                    │
│                                                                    │
│  ┌─────────────────┐        ┌─────────────────────────────────┐  │
│  │   Your IDE      │        │   CodeForge MCP Adapter         │  │
│  │  (Cursor/VS    │◄──────►│  • Installed locally            │  │
│  │   Code/etc)    │ stdio  │  • Translates IDE requests      │  │
│  │                │        │  • Manages file operations      │  │
│  └─────────────────┘        └──────────────┬──────────────────┘  │
│                                            │                      │
└────────────────────────────────────────────┼──────────────────────┘
                                             │ HTTPS
                                             ▼
┌──────────────────────────────────────────────────────────────────┐
│                    CodeForge MCP Server                           │
│                  (Cloud or Self-Hosted)                           │
│                                                                    │
│  ┌─────────────────────────────────────────────────────────────┐ │
│  │  • Processes capability requests                             │ │
│  │  • Loads appropriate SDK templates                           │ │
│  │  • Generates integration code                                │ │
│  │  • Returns structured file content                           │ │
│  └─────────────────────────────────────────────────────────────┘ │
│                              │                                     │
│                              ▼                                     │
│  ┌─────────────────────────────────────────────────────────────┐ │
│  │           SDK Repositories (GitHub)                          │ │
│  │  • PostgreSQL + Spring Boot                                  │ │
│  │  • MongoDB + FastAPI                                         │ │
│  │  • Redis + Express.js                                        │ │
│  │  • Auth0 + Next.js                                           │ │
│  │  • Kafka + Go                                                │ │
│  └─────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘

组件责任

  1. MCP适配器 (在您的机器上运行)

    • 将IDE连接到CodeForge服务器
    • 分析您的项目结构
    • 将生成的代码应用于正确的位置
    • 在修改文件之前创建备份
  2. MCP服务器 (云/自托管)

    • 处理生成请求
    • 管理SDK模板
    • 处理代码生成逻辑
    • 缓存性能模板
  3. SDK存储库 (GitHub)

    • 包含特定集成的模板
    • 定义类型映射和约定
    • 包括最佳实践和模式

🚀 快速开始

步骤1:安装CodeForge MCP适配器

为您的操作系统运行相应的安装脚本:

macOS/Linux

# Download and run the installation script
curl -sSL https://codeforge.dev/install.sh | bash

# Or manually install via npm
npm install -g @codeforge/mcp-adapter

# Verify installation
codeforge-mcp --version

视窗

# Download and run the installation script
iwr -useb https://codeforge.dev/install.ps1 | iex

# Or manually install via npm
npm install -g @codeforge/mcp-adapter

# Verify installation
codeforge-mcp --version

步骤2:配置IDE

光标IDE设置

# Run the automatic setup script
codeforge-mcp setup cursor

# This will:
# 1. Detect Cursor installation
# 2. Add CodeForge to MCP servers
# 3. Configure connection settings
# 4. Test the connection

Cursor的手动配置:

  1. 打开光标设置(Cmd/Ctrl + ,)
  2. 搜索“模型上下文协议”或“MCP”
  3. 添加到MCP服务器配置:
{
  "mcpServers": {
    "codeforge": {
      "command": "codeforge-mcp",
      "args": ["--server", "https://api.codeforge.dev/mcp"],
      "env": {
        "CODEFORGE_API_KEY": "optional-api-key"
      }
    }
  }
}

VS代码设置

# Run the automatic setup script
codeforge-mcp setup vscode

# For VS Code with Continue extension
codeforge-mcp setup vscode-continue

# For VS Code with GitHub Copilot
codeforge-mcp setup vscode-copilot

VS代码的手动配置:

  1. 安装Continue扩展或GitHub Copilot
  2. 运行: codeforge-mcp config vscode --print
  3. 将输出复制到您的VS代码设置中

IntelliJ IDEA/WebStorm设置

# Run the automatic setup script
codeforge-mcp setup intellij

步骤3:测试安装

# Test connection to CodeForge server
codeforge-mcp test

# This will verify:
# ✓ Adapter is installed correctly
# ✓ Can connect to CodeForge server
# ✓ IDE configuration is valid
# ✓ Project detection is working

步骤4:开始使用CodeForge

在IDE中,使用自然语言请求功能集成:

// @codeforge integrate PostgreSQL with users and posts tables

// @codeforge add Redis caching for user sessions

// @codeforge integrate JWT authentication with refresh tokens

// @codeforge add Kafka messaging for order events

📦 安装脚本

通用安装脚本

将此另存为 install-codeforge.sh (macOS/Linux)或 install-codeforge.ps1 (Windows):

macOS/Linux(install-codeforge.sh)

#!/bin/bash

set -e

echo "🚀 Installing CodeForge MCP Adapter..."

# Detect OS
OS="$(uname -s)"
ARCH="$(uname -m)"

# Check Node.js
if ! command -v node &> /dev/null; then
    echo "❌ Node.js is required but not installed."
    echo "Please install Node.js 18+ from https://nodejs.org"
    exit 1
fi

NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
    echo "❌ Node.js 18+ is required. Current version: $(node -v)"
    exit 1
fi

# Install adapter
echo "📦 Installing CodeForge MCP Adapter..."
npm install -g @codeforge/mcp-adapter

# Detect IDEs
echo "🔍 Detecting installed IDEs..."

IDES_FOUND=""

# Check for Cursor
if [ -d "$HOME/.cursor" ] || [ -d "/Applications/Cursor.app" ]; then
    IDES_FOUND="$IDES_FOUND cursor"
    echo "✓ Cursor detected"
fi

# Check for VS Code
if command -v code &> /dev/null || [ -d "/Applications/Visual Studio Code.app" ]; then
    IDES_FOUND="$IDES_FOUND vscode"
    echo "✓ VS Code detected"
fi

# Check for IntelliJ
if [ -d "$HOME/.IntelliJIdea"* ] || [ -d "/Applications/IntelliJ IDEA.app" ]; then
    IDES_FOUND="$IDES_FOUND intellij"
    echo "✓ IntelliJ IDEA detected"
fi

# Configure detected IDEs
for IDE in $IDES_FOUND; do
    echo "⚙️  Configuring $IDE..."
    codeforge-mcp setup $IDE --auto
done

# Test installation
echo "🧪 Testing CodeForge installation..."
if codeforge-mcp test; then
    echo "✅ CodeForge successfully installed!"
    echo ""
    echo "📝 Next steps:"
    echo "1. Open your IDE"
    echo "2. Create or open a project"
    echo "3. Type: @codeforge <your integration request>"
    echo ""
    echo "📚 Examples:"
    echo "  @codeforge integrate PostgreSQL with user management"
    echo "  @codeforge add Redis caching"
    echo "  @codeforge integrate JWT authentication"
else
    echo "⚠️  Installation completed but test failed."
    echo "Run 'codeforge-mcp test --debug' for more information."
fi

窗户(install-codeforge.ps1)

# PowerShell installation script for Windows

Write-Host "🚀 Installing CodeForge MCP Adapter..." -ForegroundColor Cyan

# Check Node.js
try {
    $nodeVersion = node -v
    $majorVersion = [int]($nodeVersion -replace 'v(\d+)\..*', '$1')
    if ($majorVersion -lt 18) {
        Write-Host "❌ Node.js 18+ is required. Current version: $nodeVersion" -ForegroundColor Red
        exit 1
    }
} catch {
    Write-Host "❌ Node.js is required but not installed." -ForegroundColor Red
    Write-Host "Please install Node.js 18+ from https://nodejs.org" -ForegroundColor Yellow
    exit 1
}

# Install adapter
Write-Host "📦 Installing CodeForge MCP Adapter..." -ForegroundColor Green
npm install -g @codeforge/mcp-adapter

# Detect IDEs
Write-Host "🔍 Detecting installed IDEs..." -ForegroundColor Cyan

$idesFound = @()

# Check for Cursor
if (Test-Path "$env:LOCALAPPDATA\Programs\cursor" -or Test-Path "$env:USERPROFILE\.cursor") {
    $idesFound += "cursor"
    Write-Host "✓ Cursor detected" -ForegroundColor Green
}

# Check for VS Code
if (Get-Command code -ErrorAction SilentlyContinue) {
    $idesFound += "vscode"
    Write-Host "✓ VS Code detected" -ForegroundColor Green
}

# Configure detected IDEs
foreach ($ide in $idesFound) {
    Write-Host "⚙️  Configuring $ide..." -ForegroundColor Yellow
    codeforge-mcp setup $ide --auto
}

# Test installation
Write-Host "🧪 Testing CodeForge installation..." -ForegroundColor Cyan
$testResult = codeforge-mcp test

if ($LASTEXITCODE -eq 0) {
    Write-Host "✅ CodeForge successfully installed!" -ForegroundColor Green
    Write-Host ""
    Write-Host "📝 Next steps:" -ForegroundColor Cyan
    Write-Host "1. Open your IDE"
    Write-Host "2. Create or open a project"
    Write-Host "3. Type: @codeforge <your integration request>"
} else {
    Write-Host "⚠️  Installation completed but test failed." -ForegroundColor Yellow
    Write-Host "Run 'codeforge-mcp test --debug' for more information."
}

单线安装

为了快速安装,用户可以运行:

# macOS/Linux
curl -sSL https://codeforge.dev/install.sh | bash

# Windows (PowerShell)
iwr -useb https://codeforge.dev/install.ps1 | iex

# Or use npm directly
npm install -g @codeforge/mcp-adapter && codeforge-mcp setup --auto

🔧 支持的功能

数据库集成

数据库 支持的操作 框架
PostgreSQL CRUD、关系、迁移、索引 Spring Boot、Django、Express、FastAPI
MySQL CRUD、存储过程、视图 Spring Boot、Laravel、Express
MongoDB 文档、聚合、索引 Spring Boot、FastAPI、Express
雷迪斯 缓存、发布/订阅、会话 所有框架
DynamoDB 数据库 表、GSI、流 无服务器、Spring Boot
弹性搜索 索引、搜索、聚合 Spring Boot、FastAPI

身份验证和授权

提供者 功能 框架
JWT公司 令牌、刷新、声明 所有框架
OAuth2 社交登录,PKCE Spring Boot,Express
身份验证0 完全集成 React、Next.js、Angular
Firebase身份验证 用户、角色、规则 React、Flutter
AWS Cognito 用户池、联合 无服务器、Spring Boot

消息和事件

系统 模式 框架
卡夫卡 生产者、消费者、流媒体 Spring Boot、Go
RabbitMQ 发布、订阅、RPC 所有框架
AWS SQS 队列、DLQ、FIFO 无服务器、Spring Boot
Redis Pub/Sub 实时消息 Node.js、Python

云服务

服务 集成 框架
AWS S3 上传、下载、预签名网址 所有框架
SendGrid 电子邮件模板、Webhooks 所有框架
条纹 支付、订阅 Node.js、Python
提里奥 短信、语音、视频 所有框架

🎯 使用示例

数据库集成

// In your IDE, type:
@codeforge integrate PostgreSQL with these tables:
- users: id, email, username, password_hash, created_at
- posts: id, user_id, title, content, published_at
- comments: id, post_id, user_id, content, created_at

// CodeForge will generate:
// ✓ Entity classes with relationships
// ✓ Repository interfaces
// ✓ Service layer with business logic
// ✓ REST controllers
// ✓ Database migrations
// ✓ Connection configuration

身份验证设置

@codeforge add JWT authentication with:
- Access tokens (15 min expiry)
- Refresh tokens (7 days)
- Role-based access (admin, user, guest)
- Password reset flow
- Email verification

// Generates complete auth system

消息队列集成

@codeforge integrate Kafka for:
- Order events (created, processed, shipped)
- Inventory updates
- Email notifications

// Generates producers, consumers, and event schemas

缓存层

@codeforge add Redis caching for:
- User sessions (30 min TTL)
- API responses (5 min TTL)
- Rate limiting (100 req/min)

// Generates caching service and decorators

🔍 工作原理-一步一步

  1. 您请求能力

    • 在IDE中用自然语言键入您的请求
    • 示例:“集成PostgreSQL进行用户管理”
  2. 适配器分析您的项目

    • 检测语言(Java、Python、TypeScript等)
    • 标识框架(Spring Boot、FastAPI、Express等)
    • 查找项目结构和包组织
  3. 服务器创建集成计划

    • 选择合适的SDK模板
    • 计划生成/修改哪些文件
    • 计算所需的依赖关系
  4. 您查看了计划

    • 查看将生成的内容
    • 自定义选项(龙目、验证等)
    • 批准或修改计划
  5. 代码生成

    • 服务器生成所有集成代码
    • 适配器将文件应用于您的项目
    • 创建已修改文件的备份
  6. 准备使用

    • 完整的集成代码到位
    • 已将依赖项添加到构建文件中
    • 配置文件已更新
    • 运行您的应用程序

🛠️ 配置

服务器配置

默认情况下,CodeForge连接到云服务器。对于自托管或开发:

# Use a different server
export CODEFORGE_SERVER=https://your-server.com/mcp

# Or configure in .env file
CODEFORGE_SERVER=http://localhost:8080/mcp
CODEFORGE_API_KEY=your-api-key

项目配置

创建 .codeforgerc.json 在项目根目录中:

{
  "preferences": {
    "language": "java",
    "framework": "spring-boot",
    "useLombok": true,
    "generateTests": true,
    "includeDocumentation": true
  },
  "exclude": [
    "node_modules",
    "target",
    "build"
  ]
}

🧪 测试您的设置

安装后,验证一切正常:

# Full system test
codeforge-mcp test --full

# This checks:
# ✓ Adapter installation
# ✓ Node.js version
# ✓ IDE configuration
# ✓ Server connectivity
# ✓ Project detection
# ✓ File permissions
# ✓ Backup directory

# Quick connectivity test
codeforge-mcp ping

# Check project detection
codeforge-mcp analyze

🔧 故障排除

常见问题及解决方法

“找不到命令:codeforge mcp”

# Ensure npm global bin is in PATH
export PATH="$PATH:$(npm config get prefix)/bin"

# Or reinstall
npm install -g @codeforge/mcp-adapter

“无法连接到服务器”

# Check server status
curl https://api.codeforge.dev/mcp/health

# Try with explicit server
codeforge-mcp test --server https://api.codeforge.dev/mcp

“IDE无法识别CodeForge”

# Reinstall IDE configuration
codeforge-mcp setup [ide-name] --force

# Check IDE logs
codeforge-mcp diagnose [ide-name]

“未检测到项目类型”

# Manually specify project type
codeforge-mcp --project-type spring-boot

# Or add to project config
echo '{"project": {"type": "spring-boot"}}' > .codeforgerc.json

📊 地方发展

对于使用本地服务器进行测试:

# Clone and run the MCP server locally
git clone https://github.com/codeforge/mcp-server
cd mcp-server
mvn spring-boot:run

# Configure adapter to use local server
export CODEFORGE_SERVER=http://localhost:8080/mcp

# Test local setup
codeforge-mcp test

🤝 获取帮助

资源

支持命令

# Get system information for bug reports
codeforge-mcp info --system

# Generate diagnostic report
codeforge-mcp diagnose --output report.json

# Check for updates
codeforge-mcp update --check

CodeForge -在几秒钟内而不是几小时内生成功能集成

文档 • Discord 的中文翻译是“不和谐”或“纷争”。 • GitHub