--- title: generateHelpers description: "Generate typed hooks inferred from your server" --- Without it, [`useCallTool`](/api-reference/use-call-tool) and [`useToolInfo`](/api-reference/use-tool-info) need their [tool](/build/tools) types written by hand, duplicating your [server](/api-reference/mcp-server). `generateHelpers` infers them from your server type, so you import already-typed hooks. Set it up once and use the hooks across your views. ## Example `helpers.ts` wires your server type to the hooks; views import the typed hooks from it. ```ts helpers.ts import type { AppType } from "./server"; // type-only import import { generateHelpers } from "skybridge/web"; export const { useCallTool, useToolInfo } = generateHelpers(); ``` ```tsx views/carousel.tsx import { useCallTool, useToolInfo } from "../helpers.js"; function Carousel() { const { output } = useToolInfo<"search-products">(); // output typed from the tool const { callTool } = useCallTool("create-checkout"); // name autocompleted, input typed return ( ); } ``` ## Signature ```tsx const { useCallTool, useToolInfo } = generateHelpers(); ``` ## Type Parameters ### `ServerType` ```tsx ServerType extends McpServer; ``` Your app's type, `typeof app`. Export it from `src/server.ts` with `export type AppType = typeof app`, then pass it here. Inference works only when `handler` chains `.registerTool()` calls on the server it receives and returns the result, so the tool types accumulate on `typeof app`. ## Returns Two hooks. Both autocomplete tool names and infer types from `ServerType`, so you write no generics; their surface is otherwise identical to the untyped versions. ### `useCallTool` The typed [`useCallTool`](/api-reference/use-call-tool): the `name` argument autocompletes, and the input and output types follow the named tool. ### `useToolInfo` The typed [`useToolInfo`](/api-reference/use-tool-info): the tool name (its type argument) autocompletes, and `input`, `output`, and `responseMetadata` follow it. Call a tool from a view Read the tool result the view mounted with The server whose type you infer from