Skip to main content
Agent components are React components that register MCP tools automatically. Agents interact with these components by calling tools — pushing data into the UI or receiving UI state.

mcpComponent

The recommended way to create agent-driven components. mcpComponent() is a factory that wraps a React component + zod schema into an MCP-registered component with full type safety.

How It Works

  1. On mount, mcpComponent registers an MCP tool with the given name and zod schema
  2. Input is validated against the zod schema before reaching your component
  3. Before any agent invocation, the fallback is rendered
  4. When an agent calls the tool, the validated data is passed as typed props
  5. The tool returns a success response to the agent

Options

Static Properties

The returned component has a .toolName property:

Patterns

Wrapping Existing Components

Inline Components

Lazy Loading

Wrap dynamic import() factories with mcpLazy() so mcpComponent can distinguish them from zero-arg components:

Dashboard Widgets

Use multiple mcpComponent instances to build agent-controlled dashboards:

Direct Props

The returned component accepts partial props directly, which merge with agent-provided data:

Table Mode

When component is null and columns is provided, mcpComponent renders a default <table>. The tool schema is automatically wrapped in { rows: z.array(schema) }.

McpColumnDef

How Table Mode Works

  1. The agent calls the tool with { rows: [...] }
  2. Each row is validated against the zod schema
  3. The table renders with the specified columns
  4. Custom render functions allow formatting (e.g., currency, dates)

Legacy Components

AgentContent

AgentContent is deprecated. Use mcpComponent() instead for type-safe schemas.
A component that registers itself as an MCP tool using raw JSON Schema.

AgentSearch

AgentSearch is deprecated. Use mcpComponent() with the columns option for table-based result rendering.
A headless search component that registers an MCP tool for search execution.

Migration Guide

AgentContent → mcpComponent:
AgentSearch → mcpComponent table mode: