@frontmcp/ui library to build professional-looking tool outputs.
Prerequisites:
- A working FrontMCP tool (see Your First Tool)
- Basic understanding of HTML/CSS
What You’ll Build
A weather tool that displays temperature, conditions, and other data in a styled card with badges and description lists.Step 1: Install the UI Package
Step 2: Create a Tool with UI Template
Theui property in the @Tool decorator lets you define a template function that renders HTML:
UI Configuration Options
Human-readable description of what the widget displays. Shown to users in UI-capable hosts.
How the widget should be displayed:
inline- Rendered directly in the conversationmodal- Opens in a modal dialogpanel- Shows in a side panel
How the HTML is served:
static- HTML string is returned directlyiframe- Content is served via iframe URL
A function that receives the execution context and returns an HTML string.
Available UI Components
Card
Wrap content in a styled container:Badge
Display status or category labels:Description List
Show key-value pairs:Button
Create styled buttons:Form and Input
Build forms with validation:Template Context
The template function receives a context object with:Available Helpers
| Helper | Description |
|---|---|
escapeHtml(str) | Escape HTML entities to prevent XSS |
formatDate(date) | Format a date string |
formatNumber(num, options) | Format numbers with locale support |
Practical Example: Expense Summary
Platform Detection
Different platforms (OpenAI, Claude, browsers) have different capabilities. Use theme utilities to adapt:Next Steps
UI Library Reference
Complete UI component documentation
Tool Reference
Full @Tool decorator options
CodeCall CRM Demo
See UI in a full application
Create Prompts
Build prompts alongside tools