MCP Hub
Back to servers

UI Preset MCP Server

Enables auto-configuration and validation of React components against a glassmorphic design token system using an AST correction engine. It supports managing UI presets, enforcing design uniformity in Monaco IDE, and exporting tokens as CSS, Tailwind, or JavaScript variables.

Updated
Feb 22, 2026

UI Preset MCP Server

MCP server for auto-configuring React UI against a swappable glassmorphic preset system. Integrates with your Monaco IDE to enforce design uniformity across all business builds.

Architecture

ui-preset-mcp-server/
├── src/
│   ├── index.ts                    # Server entry point (stdio + HTTP transports)
│   ├── constants.ts                # Shared constants and paths
│   ├── types/
│   │   └── index.ts                # All TypeScript types (tokens, presets, corrections)
│   ├── schemas/
│   │   └── toolSchemas.ts          # Zod validation schemas for every tool
│   ├── services/
│   │   ├── presetLoader.ts         # Reads + deep-merges preset files with caching
│   │   ├── sessionState.ts         # Active preset session management + overrides
│   │   ├── uiCorrector.ts          # AST correction engine (10 correction passes)
│   │   ├── tokenResolver.ts        # Resolves {{token:x.y.z}} placeholders + export generators
│   │   └── fileWatcher.ts          # Hot-reload presets on disk changes (dev mode)
│   └── tools/
│       ├── presetTools.ts          # load_preset, swap_template, list_presets, diff_presets, scaffold_preset
│       └── correctionTools.ts      # autocorrect_component, validate_ui, generate_component, generate_tokens, apply_token_overrides
└── presets/
    ├── glassmorphic-base/          # Core preset (all others inherit from this)
    │   ├── manifest.json
    │   ├── tokens.json             # Full design token system
    │   ├── components/
    │   │   ├── shell/Sidebar.json
    │   │   ├── surfaces/GlassCard.json
    │   │   ├── settings/OptionGroup.json
    │   │   └── navigation/NavGroup.json
    │   └── layouts/DashboardLayout.json
    ├── client-fintech/             # Blue accent, dense spacing
    ├── client-saas/                # Purple accent, wider cards
    └── client-dark-minimal/        # Monochrome, reduced glass intensity

MCP Tools

Preset Management

ToolDescription
load_presetActivate a preset bundle by ID
swap_templateHot-swap active preset without restart
list_presetsList all available presets
diff_presetsCompare token/component differences between two presets
scaffold_presetGenerate a new preset directory from a parent
get_session_stateCheck active preset and runtime overrides

Correction & Generation

ToolDescription
autocorrect_componentAuto-fix React component against active preset
validate_uiValidate component and get conformance score (0–100)
generate_componentGenerate a component from a preset template
generate_tokensExport tokens as CSS vars, JS, JSON, or Tailwind config
apply_token_overridesLayer runtime token overrides on the active preset

Installation

npm install
npm run build

Usage

stdio (for Monaco IDE integration)

node dist/index.js

HTTP server

TRANSPORT=http PORT=3001 node dist/index.js

Dev mode with hot-reload

WATCH_PRESETS=true node dist/index.js

Typical Workflow

1. load_preset("glassmorphic-base")          # Activate base preset
2. autocorrect_component(code)               # Fix component on save
3. validate_ui(code)                         # Get conformance score
4. generate_tokens({ format: "css" })        # Export CSS variables
5. swap_template("client-fintech")           # Switch to client variant
6. scaffold_preset({ preset_id: "client-x" })# Create new client preset

Creating New Presets

New presets only need to override tokens that differ from the parent:

// presets/client-newbrand/tokens.json
{
  "colors": {
    "accent": {
      "primary": "#e11d48"
    }
  }
}
// presets/client-newbrand/manifest.json
{
  "id": "client-newbrand",
  "name": "New Brand",
  "extends": "glassmorphic-base",
  "version": "1.0.0",
  "tags": ["custom"],
  "components": [],
  "layouts": []
}

All base tokens, components, and layouts are inherited automatically.

Correction Rules

The correction engine enforces these rules on every component:

  • no-hardcoded-colors (error): All color values must use CSS custom properties
  • no-hardcoded-spacing (warning): Spacing should use the token scale
  • enforce-glass-surface (error): Surface elements must have backdropFilter + semi-transparent bg
  • no-hardcoded-font-family (error): Font families must use typography tokens
  • use-animation-tokens (warning): Transitions must use animation tokens
  • enforce-sidebar-components (error): Sidebar content must use NavGroup/NavItem
  • enforce-settings-components (error): Settings UI must use OptionGroup/OptionRow
  • a11y-img-alt (warning): Images must have alt attributes
  • a11y-icon-button-label (warning): Icon buttons need aria-label

Monaco Integration

In your Monaco editor, call autocorrect_component on the save event:

editor.onDidSaveModel(async () => {
  const code = editor.getValue();
  const result = await mcpClient.callTool('autocorrect_component', {
    code,
    context: 'auto',
    dry_run: false
  });
  if (result.corrected !== code) {
    editor.setValue(result.corrected);
  }
});

Reviews

No reviews yet

Sign in to write a review