Clean Architecture MCP Server
Initializes and validates Clean Architecture structure in Next.js projects, including generating directory layout, API routes, and ensuring architecture compliance.
Generates Prisma adapters for repositories, integrating Prisma as the data access layer following Clean Architecture principles.
Creates Zod schemas for domain models, enabling runtime validation and type safety in the domain layer.
Click on "Install 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., "@Clean Architecture MCP Servercreate a feature called orders"
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.
Clean Architecture MCP Server
Model Context Protocol Server for scaffolding and managing Clean Architecture in Next.js projects.
🎯 Features
This MCP Server provides 3 powerful tools:
initialize_clean_architecture- Set up complete Clean Architecture structurecreate_feature- Generate new features with all layersvalidate_architecture- Check for architecture violations
Related MCP server: MCP Terminal & Git Server
🚀 Installation
Option 1: Global Installation (Recommended)
# From the mcp-server directory
cd mcp-server
npm install
npm run build
npm link
# Now available globally as 'clean-architecture-mcp'Option 2: Local Installation
cd mcp-server
npm install
npm run build⚙️ Configuration
For Cursor/Claude Desktop
Add to your MCP configuration file:
Mac/Linux: ~/.config/cursor/mcp.json or ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Cursor\mcp.json or %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"clean-architecture": {
"command": "node",
"args": ["/absolute/path/to/mcp-server/dist/index.js"]
}
}
}Or if globally installed:
{
"mcpServers": {
"clean-architecture": {
"command": "clean-architecture-mcp"
}
}
}Restart Cursor/Claude
After configuration, restart Cursor or Claude Desktop to load the MCP server.
📚 Usage
Tool 1: Initialize Architecture
Initialize Clean Architecture in your Next.js project:
In Cursor chat:
Use the clean-architecture MCP server to initialize the project structureWith parameters:
Use clean-architecture to initialize with features: products, orders, customersWhat it does:
✅ Creates complete directory structure
✅ Adds .gitkeep files
✅ Creates README.md in each layer
✅ Updates tsconfig.json paths
✅ Sets up domain/infra/components/tests folders
Tool 2: Create Feature
Generate a complete feature:
In Cursor chat:
Use clean-architecture to create a "products" featureWhat it creates:
src/domain/products/
├── models/product.ts # Zod schema
├── business-rules/ # Pure business logic
├── services/product-service.ts # Use cases
└── ports/product-repository.ts # Interface
src/infra/adapters/
└── product-repository.prisma.ts # Implementation
src/app/api/products/
├── route.ts # GET, POST
└── [id]/route.ts # GET, DELETETool 3: Validate Architecture
Check for architecture violations:
In Cursor chat:
Use clean-architecture to validate the projectWhat it checks:
❌ Next.js imports in domain layer
❌ React imports in domain layer
❌ Direct Prisma imports in domain
⚠️ Missing ports/interfaces
⚠️ Missing tests
Output:
{
"success": true,
"score": 100,
"issues": [],
"warnings": [],
"message": "✅ Architecture validation passed!"
}🎨 Examples
Example 1: New Project Setup
User: Initialize Clean Architecture in this Next.js project with features: users, products, orders
AI: [Uses initialize_clean_architecture tool]
Result:
✅ Created 45 directories
✅ Created 6 README files
✅ Updated tsconfig.json
✅ Ready to develop!Example 2: Create Feature
User: Create a "products" feature with fields: name, price, stock
AI: [Uses create_feature tool with featureName: "products"]
Result:
✅ Created models/product.ts
✅ Created business rules
✅ Created service layer
✅ Created repository port
✅ Created Prisma adapter
✅ Created API routesExample 3: Validate
User: Check if my architecture follows Clean Architecture principles
AI: [Uses validate_architecture tool]
Result:
❌ Found 2 issues:
- src/domain/users/services/create-user.ts: Contains Next.js import
- src/domain/products/models/product.ts: Direct Prisma import
Score: 60/100🛠️ Development
# Install dependencies
npm install
# Build
npm run build
# Watch mode (during development)
npm run dev
# Test the server
node dist/index.js📋 Tool Reference
initialize_clean_architecture
Parameters:
targetDir(optional): Target directory (default: current directory)features(optional): Array of feature names (default:['users', 'auth', 'payments'])
Returns:
{
success: boolean;
message: string;
created: number;
directories: string[];
features: string[];
}create_feature
Parameters:
featureName(required): Feature name in kebab-casetargetDir(optional): Target directory (default: current directory)fields(optional): Custom model fields
Returns:
{
success: boolean;
message: string;
feature: string;
created: string[];
}validate_architecture
Parameters:
targetDir(optional): Directory to validate (default: current directory)
Returns:
{
success: boolean;
score: number;
issues: string[];
warnings: string[];
message: string;
}🔧 Troubleshooting
MCP Server not appearing in Cursor
Check configuration file path
Verify absolute path to
dist/index.jsRestart Cursor completely
Check Cursor logs:
Help > Show Logs
"Command not found" error
If globally installed:
npm link
# Verify
which clean-architecture-mcpTypeScript errors
npm run build
# Check for compilation errorsTool execution fails
Check that you're in a Next.js project directory with package.json.
📦 Publishing
To publish to npm:
npm publishThen users can install globally:
npm install -g clean-architecture-mcp-server🤝 Contributing
Add new tools in
src/index.tsUpdate tool schemas
Test with
npm run build && node dist/index.jsUpdate this README
📄 License
MIT
🔗 Resources
Made with ❤️ for Clean Architecture enthusiasts
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/valentin-harrang/clean-architecture-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server