Model Context Protocol integration for Claude Desktop, Claude Code, Cursor, and other AI coding assistants.
MCP (Model Context Protocol) allows AI assistants like Claude to call tools directly without API calls. This makes backend generation 10x faster for AI coding assistants.
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"archetype": {
"command": "npx",
"args": ["-y", "archetype-engine@latest", "mcp"]
}
}
}Add to your project's .cursorrules or .windsurfrules:
# Archetype Backend Generator
When user asks to create a backend, use archetype CLI with JSON manifests:
1. Create manifest.json with all entities
2. Run: npx archetype validate manifest.json --json
3. Run: npx archetype generate manifest.json
4. Run: npx drizzle-kit push && npm run dev
See CLAUDE.md for details.
Create a manifest.json with entity definitions.
Example:
{
"entities": [
{
"name": "User",
"fields": {
"email": { "type": "text", "email": true, "unique": true },
"name": { "type": "text", "required": true }
}
},
{
"name": "Post",
"fields": {
"title": { "type": "text", "min": 1, "max": 200 },
"content": { "type": "text" }
},
"relations": {
"author": { "type": "hasOne", "entity": "User" }
},
"protected": "write"
}
],
"database": {
"type": "sqlite",
"file": "./app.db"
}
}Validate manifest.json before generating.
Input:
manifestPath(optional): Path to manifest file (default: "manifest.json")
Generate all backend code from manifest.json.
Input:
manifestPath(optional): Path to manifest file (default: "manifest.json")
Generates:
generated/db/schema.ts- Drizzle ORM schemasgenerated/schemas/*.ts- Zod validationgenerated/trpc/routers/*.ts- tRPC CRUD APIsgenerated/hooks/*.ts- React Query hooksgenerated/erd.md- Entity diagram
Open ERD viewer in browser.
Input:
configPath(optional): Path to config/manifest (default: "manifest.json")
User: "Create a blog with users and posts"
Claude calls:
archetype_create_manifestwith:
{
"entities": [
{ "name": "User", "fields": { "email": {...}, "name": {...} } },
{ "name": "Post", "fields": { "title": {...}, "content": {...} }, "relations": { "author": { "type": "hasOne", "entity": "User" } } }
],
"database": { "type": "sqlite", "file": "./app.db" }
}archetype_validate_manifestarchetype_generate
Result: 400+ lines of production-ready code in 3 tool calls.
User: "Build an e-commerce site with products, orders, and customers"
Claude calls:
archetype_create_manifestwith Product, Order, Customer, OrderItem entitiesarchetype_validate_manifestarchetype_generatearchetype_view_schemato visualize
Result: Complete backend with:
- Product catalog with pagination/filtering
- Order management with line items
- Customer authentication
- Type-safe APIs and hooks
// AI makes 10+ API calls to OpenAI/Anthropic
await generateText({
model: openai('gpt-4'),
tools: aiTools.vercel(builder),
prompt: "Create a blog",
maxSteps: 10
})
// → $0.50 in API costs, 30 secondsUser: "Create a blog"
Claude: [calls archetype_create_manifest directly]
Claude: [calls archetype_generate]
→ FREE, 2 seconds, no API round-trips
| Aspect | API (OpenAI/Anthropic) | MCP Server |
|---|---|---|
| Speed | 30+ seconds | 2 seconds |
| Cost | $0.20-0.50 per generation | FREE |
| Round-trips | 10+ API calls | Direct function calls |
| Reliability | Rate limits, network errors | Local execution |
| Setup | API keys, billing | One config line |
┌─────────────┐
│ Claude Code │
│ / Cursor │
└──────┬──────┘
│ stdio/JSON-RPC
│
┌──────▼──────────┐
│ MCP Server │
│ (archetype) │
└──────┬──────────┘
│
│ Direct function calls
│
┌──────▼──────────┐
│ Archetype │
│ Core Engine │
└──────┬──────────┘
│
│ Write files
│
┌──────▼──────────┐
│ Project Files │
│ (generated/) │
└─────────────────┘
To test the MCP server locally:
# Build
npm run build
# Test MCP server
echo '{"method":"tools/call","params":{"name":"archetype_create_manifest","arguments":{...}}}' | node dist/src/mcp-server.js- Check config location:
~/Library/Application Support/Claude/claude_desktop_config.json - Restart Claude Desktop completely
- Check logs:
~/Library/Logs/Claude/mcp*.log
Ensure Node.js 20+ is installed:
node --version # Should be v20+
which npx # Should show pathCheck stderr output in Claude Desktop logs:
tail -f ~/Library/Logs/Claude/mcp-server-archetype.log- MCP Specification
- Archetype Docs
- CLAUDE.md - Guidance for Claude Code