Skip to content
ChatJS
Esc
↑↓navigate↵open⌘Jpreview

Custom Tool Part

Render native EVE tool results with validated schema-inferred props

A registry tool can include a client renderer for its loading and result states. Put the implementation in chatjs/tools/<id>/tool.ts, shared schemas in schemas.ts, and the renderer in renderer.tsx.

Define the server tool with EVE’s defineTool(). Export a renderer with defineToolRenderer and reference its export in chatjs.json. The CLI generates the server and renderer registrations when you install or sync the item.

"use client";

import { defineToolRenderer } from "@/chatjs/core/tools/define-renderer";
import { wordCountInput, wordCountResult } from "./schemas";

export const WordCountRenderer = defineToolRenderer({
  inputSchema: wordCountInput,
  outputSchema: wordCountResult,
  render: ({ tool }) => {
    if (tool.state !== "output-available") {
      return <p>Counting words…</p>;
    }
    return <p>{tool.output.words} words</p>;
  },
});

The schemas determine the renderer’s TypeScript props and validate persisted data at runtime. You do not need to import the server tool or infer an AI SDK tool type.

State Available data
input-streaming Tool call identity
input-available Validated input
output-available Validated input and output

The shared renderer handles invalid data, pending approvals, denied requests, and execution errors. If the tool returns a ChatJS cost receipt, EveToolResult validates and unwraps it before passing visible output to the renderer.

For an extracted view component, use ToolRendererProps<typeof wordCountInput, typeof wordCountResult> from @/chatjs/core/tools/define-renderer. The props still come from the schemas used for runtime validation.

See Authoring Tools for native execution, receipts, descriptor metadata, and registration.

Last updated on Nov 8, 2026

Was this page helpful?