mcp-client-gen
Turn any MCP server into a type-safe TypeScript SDK in seconds - with OAuth 2.1 and multi-provider support
claude mcp add --transport stdio kriasoft-mcp-client-gen npx -y mcp-client-gen
How to use
MCP Client Gen is a tool for generating type-safe TypeScript clients from MCP servers. It reads a server URL (or a local config) and emits a client with TypeScript types that reflect the server's schemas, enabling you to call server methods with auto-complete and compile-time type safety. The generated client supports tree-shaking by only including the methods you import, and it uses OAuth 2.1 with PKCE for authentication when needed. You typically invoke it via npx to either print the client to stdout or write it to a file, and you can point it at a server URL or use a config file for multiple servers.
To use it, run the CLI with a target MCP server URL, for example: npx mcp-client-gen https://mcp.example.com/mcp -o client.ts. The tool will output a ready-to-use TypeScript client that you can import into your application. You can then create a connection using the generated create<Server>Client function and call server methods with full type safety, e.g., const result = await notion.notionSearch({ query: "Meeting Notes" }).
How to install
Prerequisites:
- Node.js (12.x or newer) and npm or a compatible package manager (pnpm, bun, etc.).
Install globally (optional, recommended for quick CLI access):
npm install -g mcp-client-gen
Or use npx without global install:
npx mcp-client-gen <url> # generate to stdout
npx mcp-client-gen <url> -o <file> # generate to a file
If you prefer a config-driven workflow, you can place a .mcp.json file in your project root and run the CLI without arguments to generate clients for configured servers.
Prerequisites summary:
- Node.js installed
- Network access to fetch the mcp-client-gen package (when using npx or npm)
- A target MCP server URL or a local configuration file
Additional notes
Tips and common issues:
- OAuth-protected servers will trigger a browser-based authentication flow using PKCE; ensure your environment can open a browser or complete the flow as prompted.
- The generated client is tree-shakable, so import only the specific API methods you need to reduce bundle size.
- If you run into type mismatches, ensure your MCP server is exposing up-to-date schemas and that you are using a compatible version of mcp-client-gen with your server.
- You can configure multiple servers in a .mcp.json file and run the CLI in config mode for multi-server generation.
- For quick iterations, use npx mcp-client-gen <url> -o client.ts to overwrite a local client file during development.
Related MCP Servers
oh-my-pi
⌥ AI Coding agent for the terminal — hash-anchored edits, optimized tool harness, LSP, Python, browser, subagents, and more
mcp-framework
A framework for writing MCP (Model Context Protocol) servers in Typescript
mcp-telegram
MCP Server for Telegram
recall
Persistent cross-session memory for Claude & AI agents. Self-host on Redis/Valkey, or use the managed SaaS at recallmcp.com.
coplay-unity-plugin
Unity plugin for Coplay
lc2mcp
Convert LangChain tools to FastMCP tools