> ## Documentation Index
> Fetch the complete documentation index at: https://docs.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`](https://docs.skybridge.tech/api-reference/use-call-tool) and [`useToolInfo`](https://docs.skybridge.tech/api-reference/use-tool-info) need their [tool](https://docs.skybridge.tech/build/tools.md) types written by hand, duplicating your [server](https://docs.skybridge.tech/api-reference/mcp-server.md). `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 app's type, `typeof app`. Export it from `src/server.ts` with `export type AppType = typeof app`, then pass it here.

> [!NOTE]
>
> 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`](https://docs.skybridge.tech/api-reference/use-call-tool): the `name` argument autocompletes, and the input and output types follow the named tool.

### `useToolInfo`

The typed [`useToolInfo`](https://docs.skybridge.tech/api-reference/use-tool-info): the tool name (its type argument) autocompletes, and `input`, `output`, and `responseMetadata` follow it.

> [card] [useCallTool](https://docs.skybridge.tech/api-reference/use-call-tool.md)
>
> Call a tool from a view

> [card] [useToolInfo](https://docs.skybridge.tech/api-reference/use-tool-info.md)
>
> Read the tool result the view mounted with

> [card] [McpServer](https://docs.skybridge.tech/api-reference/mcp-server.md)
>
> The server whose type you infer from


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.