@miragon/mcp-toolkit-tool-codegen
v2.8.1
Published
Build-time codegen + runtime glue for type-safe MCP tool calls: TypedCallTool helper and a CLI that generates TypeScript types + React Query hooks from an MCP server's tools/list.
Readme
@miragon/mcp-toolkit-tool-codegen
Build-time codegen + runtime glue for type-safe MCP tool calls: TypedCallTool helper and a CLI that generates TypeScript types + React Query hooks from an MCP server's tools/list.
Install
Published to the public npm registry under the @miragon scope — no .npmrc
or token needed.
pnpm add -D @miragon/mcp-toolkit-tool-codegen @miragon/mcp-toolkit-coreImport paths
| Subpath | Key exports | Constraint |
| ----------------------------------- | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| @miragon/mcp-toolkit-tool-codegen | generateTools, renderCodegen, writeCodegenOutput, fetchUpstreamTools | Build-time only — never import from runtime code. |
| …-tool-codegen/runtime | ToolShape, TypedCallTool (types only) | The only subpath widget bundles / step modules may import; pulls in no handlebars / codegen deps. |
| …-tool-codegen/templates/* | Handlebars templates used by the codegen | Internal to the CLI. |
CLI
The mcp-tool-codegen bin generates tools.ts + hooks.tsx from a
source server's tools/list:
mcp-tool-codegen generate # reads ./codegen.config.ts (CodegenConfig)
mcp-tool-codegen generate --check # CI: exit 1 on drift vs committed output
mcp-tool-codegen inspect --upstream https://source.example/mcpGenerated code imports only @miragon/mcp-toolkit-tool-codegen/runtime.
Links
- API reference
- Getting started
- Starter template — "Use this template" for a new server project
