Skip to main content
generateHelpers already types useCallTool and useToolInfo for you. These utilities go one level lower: they pull a tool’s input, output, or name types straight from your server type, so you can type your own components and helpers from the same source of truth.

Example

Type a component’s props from a tool’s output, with no shape to redeclare:
import type { ToolOutput } from "skybridge/server";
import type { AppType } from "../server";

type Products = ToolOutput<AppType, "search-products">["products"];

function ProductGrid({ products }: { products: Products }) {
  return (
    <ul>
      {products.map((p) => (
        <li key={p.id}>{p.name}</li>
      ))}
    </ul>
  );
}

Utilities

Each takes your server type (AppType, that is typeof server), and the tool-specific ones also take a tool name. All import from skybridge/server.
UtilityResolves to
ToolInput<AppType, Name>The tool’s input type.
ToolOutput<AppType, Name>The tool’s output (structuredContent) type.
ToolResponseMetadata<AppType, Name>The tool’s response _meta type.
ToolNames<AppType>A union of the server’s tool names.
InferTools<AppType>The full tool registry, mostly used internally by generateHelpers.

generateHelpers

Typed hooks, the common path

useToolInfo

Read the tool result in the view

McpServer

The server you infer from