@frontmcp/react includes headless UI components that auto-generate forms from MCP tool/prompt schemas and display results. They render unstyled by default and support custom renderers.
ToolForm
Generates a form from a tool’sinputSchema.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tool | ToolInfo | — | Required. Tool definition with inputSchema |
onSubmit | (args: Record<string, unknown>) => void | — | Required. Called with parsed form values |
renderField | (props: FieldRenderProps) => ReactNode | — | Custom field renderer |
submitLabel | string | 'Call Tool' | Submit button text |
Custom Field Rendering
FieldRenderProps
| Field | Type | Description |
|---|---|---|
name | string | Field name from schema |
type | string | 'string' | 'number' | 'integer' | 'boolean' | 'enum' |
required | boolean | Whether the field is required |
description | string? | Schema description |
enumValues | string[]? | Enum options (renders <select>) |
value | string | Current value |
onChange | (value: string) => void | Change handler |
PromptForm
Generates a form from a prompt’sarguments array.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
prompt | PromptInfo | — | Required. Prompt definition with arguments |
onSubmit | (args: Record<string, string>) => void | — | Required. Called with form values |
renderField | (props: FieldRenderProps) => ReactNode | — | Custom field renderer |
submitLabel | string | 'Get Prompt' | Submit button text |
ResourceViewer
Displays the contents of aReadResourceResult.
Props
| Prop | Type | Description |
|---|---|---|
data | { contents?: ResourceContent[] } | null | Resource result |
loading | boolean | Show loading indicator |
error | Error | null | Show error message |
application/json mimeType) is automatically pretty-printed in a <pre> block.
OutputDisplay
Renders any tool/prompt output as formatted JSON or plain text.Props
| Prop | Type | Description |
|---|---|---|
data | unknown | Output value — objects are JSON-stringified |
loading | boolean | Show loading indicator |
error | Error | null | Show error message |
DynamicRenderer
Recursively renders aComponentNode tree using the ComponentRegistry.
Resolution Order
- Exact URI match in registry
component://{type}in registryelement://{type}in registry- Fallback component (or
<div>)
ComponentRegistry
Maps URI protocols to React components. Used byDynamicRenderer and populated via the provider’s components prop.
AgentContent
A component that registers itself as an MCP tool. When an agent calls the tool, it renders the args via therender prop. See Agent Components for full details and patterns.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Required. MCP tool name |
description | string | — | Required. Tool description |
inputSchema | Record<string, unknown> | { type: 'object' } | JSON Schema for input |
render | (data: Record<string, unknown>) => ReactNode | — | Required. Render function |
fallback | ReactNode | null | Shown before first invocation |
server | string | — | Target a named server |
AgentSearch
A headless search component powered by an MCP tool. Registers a tool for delivering results and a resource for the current query. See Agent Components for full details.Props
| Prop | Type | Default | Description |
|---|---|---|---|
toolName | string | — | Required. MCP tool name |
description | string | — | Required. Tool description |
placeholder | string | — | Input placeholder |
onResults | (results: unknown) => void | — | Required. Results callback |
renderInput | (props: SearchInputRenderProps) => ReactNode | — | Custom input renderer |
server | string | — | Target a named server |