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