useCallTool and useToolInfo need their tool types written by hand, duplicating your 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.
helpers.ts
views/carousel.tsx
Signature
Type Parameters
ServerType
typeof server. Export it from your server file with export type AppType = typeof server, then pass it here.
Inference works only when the server is built by chaining
.registerTool() calls off the constructor, so the tool types accumulate on the server type.Returns
Two hooks. Both autocomplete tool names and infer types fromServerType, so you write no generics; their surface is otherwise identical to the untyped versions.
useCallTool
The typed useCallTool: the name argument autocompletes, and the input and output types follow the named tool.
useToolInfo
The typed useToolInfo: the tool name (its type argument) autocompletes, and input, output, and responseMetadata follow it.
useCallTool
Call a tool from a view
useToolInfo
Read the tool result the view mounted with
McpServer
The server whose type you infer from