Skip to main content
FrontMCP tools can render rich HTML widgets for display in OpenAI Apps, Claude Artifacts, and other UI-capable hosts. This guide shows you how to use the @frontmcp/ui library to build professional-looking tool outputs.
Prerequisites:

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

The ui property in the @Tool decorator lets you define a template function that renders HTML:

UI Configuration Options

string
Human-readable description of what the widget displays. Shown to users in UI-capable hosts.
'inline' | 'modal' | 'panel'
How the widget should be displayed:
  • inline - Rendered directly in the conversation
  • modal - Opens in a modal dialog
  • panel - Shows in a side panel
'static' | 'iframe'
How the HTML is served:
  • static - HTML string is returned directly
  • iframe - Content is served via iframe URL
function
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

Always use helpers.escapeHtml() when rendering user-provided data to prevent XSS vulnerabilities.

Practical Example: Expense Summary


Platform Detection

Different platforms (OpenAI, Claude, browsers) have different capabilities. Use theme utilities to adapt:

Next Steps

React SDK Components

Pre-built React components

Tool Reference

Full @Tool decorator options

CodeCall CRM Demo

See UI in a full application

Create Prompts

Build prompts alongside tools