MCP server for UIH - Smart loading with 70% token reduction, interactive templates, and automatic logic implementation
npm install uih-mcp-serverMCP (Model Context Protocol) server for UIH - enables Claude Code to generate UI components using the UIH language natively.
This MCP server allows Claude Code to:
- Get UIH language guide - Learn UIH syntax and generate code directly
- Compile UIH to React, Vue, or Svelte components
No API Key Required! Claude Code generates UIH code directly using its own capabilities.
``bash`Build the MCP server
pnpm --filter uih-mcp-server build
`bash`
npm install -g uih-mcp-server
Add this to your Claude Code MCP settings (~/.claude/mcp_settings.json):
`json`
{
"mcpServers": {
"uih": {
"command": "/absolute/path/to/uih/packages/mcp-server/bin/uih-mcp-server.js"
}
}
}
Important:
- Replace /absolute/path/to/uih with the actual path to this repositorybin/uih-mcp-server.js
- Make sure has execute permissions (chmod +x)
- No API key needed! Claude Code generates UIH code directly
Example for your system:
`json`
{
"mcpServers": {
"uih": {
"command": "/Users/jaewonlee/Documents/CODESBYLEEJAEWON/uih/packages/mcp-server/bin/uih-mcp-server.js"
}
}
}
Smart Loading Feature π―: Automatically loads only relevant patterns based on user request, reducing token usage by ~70%!
Parameters:
- section (optional): Which section to retrieve:full
- - Complete guide (~500 tokens)syntax
- - Basic UIH syntax only (~100 tokens)form
- - Form patterns (login, signup, inputs) (~150 tokens)layout
- - Dashboard and grid layouts (~180 tokens)navigation
- - Headers, footers, menus (~140 tokens)data
- - Tables and lists with loops (~160 tokens)interaction
- - Modals, loading, errors (~170 tokens)best-practices
- - Design system guidelines (~120 tokens)userRequest
- (optional): User's original request for automatic context detection
Auto-Detection Keywords:
- Form: form, login, signup, input, submit, νμ, λ‘κ·ΈμΈ, κ°μ
, νΌ
- Layout: dashboard, grid, layout, card, stats, λμ보λ, λ μ΄μμ, μΉ΄λ
- Navigation: nav, menu, header, footer, bar, λ€λΉ, λ©λ΄, ν€λ, νΈν°
- Data: table, list, data, row, column, ν
μ΄λΈ, 리μ€νΈ, λ°μ΄ν°, λͺ©λ‘
- Interaction: modal, loading, error, dialog, toast, λͺ¨λ¬, λ‘λ©, μλ¬, λ€μ΄μΌλ‘κ·Έ
Examples:
`Auto-detection (recommended)
Claude Code: [uses mcp__uih__get_uih_guide]
userRequest: "Create a login form"
β Auto-detects: form context
β Returns: syntax + form pattern (~150 tokens)
$3
Compile UIH code to React, Vue, or Svelte with optional interactive templates.Parameters:
-
uih_code (required): UIH code to compile
- target (optional): Target framework (react, vue, svelte). Default: react
- interactive (optional): Generate interactive template with logic placeholders. Default: false
- features (optional): Specific features to generate placeholders for: ["validation", "api", "animation", "modal", "tabs"]
- output_file (optional): File path to save the generated componentInteractive Mode:
When
interactive: true, the compiler automatically:
- Detects forms, inputs, buttons, modals, and tabs in your UIH code
- Generates smart placeholders with π€ TODO comments
- Injects state management (useState), validation logic, submit handlers, and input change handlers
- Creates a hybrid template: UIH generates structure β Claude Code implements logicExample (Basic):
`
Claude Code: [uses mcp__uih__compile_uih]
uih_code: "meta { route: \"/login\"; } ..."
target: "react"
output_file: "src/components/Login.tsx"
`Example (Interactive):
`
Claude Code: [uses mcp__uih__compile_uih]
uih_code: "meta { route: \"/login\"; } layout { Form { Input(id:\"email\", type:\"email\") ... } }"
target: "react"
interactive: true
output_file: "src/components/Login.tsx"β Generates React component with:
- useState for form data, errors, loading state
- validateForm() with email/password validation
- handleSubmit() with API call skeleton
- handleInputChange() with error clearing
- π€ TODO comments for Claude Code to complete
`
Usage in Claude Code
Once configured, Claude Code will automatically discover and use these tools:
$3
`
You: "Create a login form component with UIH"Claude Code:
[Reads UIH guide with mcp__uih__get_uih_guide]
β Generates UIH code directly
β Compiles with mcp__uih__compile_uih
β Saves to src/components/login-form.tsx
"β
Created login-form.tsx in src/components/"
`$3
`
You: "Create a login form with validation and API integration"Claude Code:
[Reads UIH guide with mcp__uih__get_uih_guide]
β Generates UIH code with Form and Inputs
β Compiles with mcp__uih__compile_uih (interactive: true)
β Detects form features automatically
β Injects smart placeholders with π€ TODO comments
β Implements the logic based on placeholders
β Saves completed component to src/components/login-form.tsx
"β
Created interactive login form with validation and API integration!"
`$3
`
You: "Compile examples/booking.uih to Vue"Claude Code:
[Reads examples/booking.uih]
[Uses mcp__uih__compile_uih with target: "vue"]
β Compiles to Vue
β Saves to out/booking.vue
"β
Compiled to Vue: out/booking.vue"
`How It Works
`mermaid
graph LR
A[User Request] --> B[Claude Code]
B --> C[UIH MCP Server]
C --> D{Tool Selection}
D -->|get_uih_guide| E[Return Guide]
D -->|compile_uih| F[UIH Parser]
E --> B
B -->|Generate UIH| G[UIH Code]
G --> F
F --> H[React/Vue/Svelte]
`Comparison: With vs Without MCP
$3
`bash
Step 1: Generate UIH
node packages/cli/dist/index.js ai "login form" > login.uihStep 2: Compile to React
node packages/cli/dist/index.js compile login.uih out --target reactStep 3: Move to project
cp out/login.tsx src/components/
`$3
`
You: "Create a login form component"
Claude Code: [Automatically does all 3 steps] β
Done!
`Benefits
β
Seamless Integration: Claude Code discovers tools automatically
β
Single Command: Generate and compile in one step
β
Type Safe: Full TypeScript support with schema validation
β
Error Handling: Clear error messages and validation
β
Flexible: Use individual tools or complete workflow
Troubleshooting
$3
- Check ~/.claude/mcp_settings.json syntax
- Verify the absolute path to dist/index.js
- Restart Claude Code after configuration changes$3
- Run pnpm install in the repository root
- Run pnpm build to rebuild all packages
- Check that all workspace dependencies are installedDevelopment
$3
`bash
pnpm --filter uih-mcp-server build
`$3
`bash
Run the MCP server directly
node packages/mcp-server/dist/index.js
`$3
The MCP server supports debug logging via environment variables:
`bash
Enable debug logging
DEBUG=true node packages/mcp-server/dist/index.jsOr use UIH-specific flag
UIH_DEBUG=true node packages/mcp-server/dist/index.js
`Debug logs show:
- Project root detection
- Context auto-detection
- Guide/code size truncation warnings
- Feature detection for interactive mode
All logs go to stderr, which is visible in Claude Code's MCP logs.
Architecture
`
packages/mcp-server/
βββ src/
β βββ index.ts # MCP server implementation
βββ dist/ # Built output (ESM)
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ tsup.config.ts # Build configuration
`Dependencies:
-
@modelcontextprotocol/sdk - MCP protocol implementation
- uih-parser - UIH language parser
- uih-codegen-react` - Multi-framework code generatorMIT
- UIH Language Documentation
- UIH CLI
- UIH Parser
- MCP Protocol Specification