> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging.skybridge.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# generateHelpers

> 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 theme={null}
import type { AppType } from "./server"; // type-only import
import { generateHelpers } from "skybridge/web";

export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
```

```tsx views/carousel.tsx theme={null}
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 (
    <button onClick={() => callTool({ items: output.products })}>Check out</button>
  );
}
```

## Signature

```tsx theme={null}
const { useCallTool, useToolInfo } = generateHelpers<ServerType>();
```

## Type Parameters

### `ServerType`

```tsx theme={null}
ServerType extends McpServer<AnyToolRegistry>;
```

Your server's type, `typeof server`. Export it from your server file with `export type AppType = typeof server`, then pass it here.

<Info>
  Inference works only when the server is built by chaining `.registerTool()` calls off the constructor, so the tool types accumulate on the server type.
</Info>

## 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.

<CardGroup cols={3}>
  <Card title="useCallTool" icon="square-function" href="/api-reference/use-call-tool">
    Call a tool from a view
  </Card>

  <Card title="useToolInfo" icon="database" href="/api-reference/use-tool-info">
    Read the tool result the view mounted with
  </Card>

  <Card title="McpServer" icon="server" href="/api-reference/mcp-server">
    The server whose type you infer from
  </Card>
</CardGroup>
