Command Palette

Search for a command to run...

AI Tool Call

Display AI tool/function invocations with status indicators, input/output visualization, and collapsible interface for MCP and function calling workflows.

Open in v0Open in
Input
{
  "query": "React best practices 2025"
}
Output
Found 5 relevant articles about React best practices.
Input
{
  "url": "https://api.example.com/data"
}
Error
Connection timeout after 30s

Overview

A compound component for displaying AI tool/function invocations with real-time status tracking. Supports states like pending, running, completed, error, awaiting-approval, and denied. Built with Radix Collapsible.

Installation

bunx shadcn@latest add @elements/tool-call

Usage

import {
  ToolCall,
  ToolCallHeader,
  ToolCallContent,
  ToolCallInput,
  ToolCallOutput,
  ToolCallError,
} from "@/components/elements/ai-elements/agentic/tool-call";

export function ToolCallExample() {
  return (
    <ToolCall name="searchDatabase" state="completed">
      <ToolCallHeader />
      <ToolCallContent>
        <ToolCallInput input={{ query: "user:123", limit: 10 }} />
        <ToolCallOutput>Found 3 matching records</ToolCallOutput>
      </ToolCallContent>
    </ToolCall>
  );
}

Props

ToolCall

PropTypeDefaultDescription
namestring-Tool/function name to display
stateToolCallState-Current execution state
defaultOpenbooleanfalseInitial open state
openboolean-Controlled open state
onOpenChange(open: boolean) => void-Callback when open state changes

ToolCallState

type ToolCallState =
  | "pending"
  | "running"
  | "completed"
  | "error"
  | "awaiting-approval"
  | "denied";

ToolCallInput

PropTypeDescription
inputRecord<string, unknown>JSON input to display

ToolCallError

PropTypeDescription
errorstringError message to display

Features

  • Collapsible interface with smooth animations
  • Status badges with icons (Loader2, Check, X, AlertTriangle)
  • JSON syntax highlighting for input
  • Auto-opens on completion or error
  • Controlled and uncontrolled modes
  • Keyboard navigation support