π Generate type-safe TypeScript clients from any MCP (Model Context Protocol) server.
import { notion, github, slack } from "./src/mcp-client";
// Type-safe client calls with full IntelliSense
const page = await notion.createPage({
title: "Meeting Notes",
content: "Discussion about Q4 roadmap...",
});
const issue = await github.createIssue({
title: "Bug: Login failure",
body: "Users cannot authenticate...",
});
await slack.notify({
channel: "#dev",
message: `New issue created: ${issue.url}`,
});
β¨ Type-Safe - Full TypeScript support with generated types
π Multi-Provider - Connect to multiple MCP servers simultaneously
π― Tree-Shakable - Only bundle the methods you use
β‘ Fast - Built with Bun for optimal performance
π οΈ Interactive CLI - Smart prompts with sensible defaults
βοΈ Flexible - Works with multiple MCP config formats
npm install -g mcp-client-gen
# or use directly
npx mcp-client-gen
Create a .mcp.json
file with your MCP server endpoints:
Interactive Mode (Recommended):
npx mcp-client-gen # Launch interactive prompts
npx mcp-client-gen -y # Accept all defaults and proceed
Direct Mode:
npx mcp-client-gen ./src/mcp-client.ts
import { notion } from "./src/mcp-client";
// All methods are fully typed based on the MCP server schema
const page = await notion.fetchPage("page-id");
const newPage = await notion.createPage({
title: "My Page",
content: "Page content...",
});
npx mcp-client-gen # Launch interactive prompts
npx mcp-client-gen -y # Accept defaults and proceed
npx mcp-client-gen --yes # Same as -y
npx mcp-client-gen [options] <output-file>
Arguments:
output-file Path for the generated client file
Options:
--config <file> MCP configuration file (default: auto-discover)
-y, --yes Accept all defaults and skip prompts
--help Show help information
Examples:
npx mcp-client-gen # Interactive mode
npx mcp-client-gen -y # Quick generation with defaults
npx mcp-client-gen ./src/mcp-client.ts # Direct mode with output file
npx mcp-client-gen --config custom.json ./src/clients.ts
π API Integration - Connect to multiple services with one SDK
π€ Workflow Automation - Build cross-platform automation scripts
π Data Synchronization - Keep data in sync across different platforms
π§ͺ Rapid Prototyping - Quickly test integrations with type safety
Preview Release - This is an early preview. The core CLI and configuration parsing works, but MCP server introspection is still in development.
Current Status:
- β CLI interface and configuration parsing
- β Interactive prompts with smart defaults
- β Multi-server client generation structure
- β Multiple MCP config format support (.mcp.json, .cursor/, .vscode/)
- π§ MCP server schema introspection (in progress)
- π§ Real-time type generation from server capabilities
- π Plugin system for custom transformations
Coming Soon:
- Full MCP protocol implementation
- Authentication handling
- Streaming support
- Error handling and retries
Generated MCP clients include built-in support for OAuth 2.1 authentication using RFC 7591 Dynamic Client Registration. The authentication flow is handled automatically:
- Dynamic Client Registration (RFC 7591) - Clients automatically register with OAuth providers
- PKCE Flow (RFC 7636) - Secure authorization code exchange with Proof Key for Code Exchange
- Multiple Auth Methods - Supports
client_secret_basic
,client_secret_post
, and public clients - Token Management - Automatic token refresh and credential storage
- Resource Protection - RFC 9728 OAuth 2.0 Protected Resource Metadata support
- Discovery - Client discovers OAuth authorization server metadata
- Registration - Dynamic client registration if credentials not found
- Authorization - PKCE-based authorization code flow initiation
- Token Exchange - Secure token exchange with automatic refresh
- API Calls - Authenticated requests using Bearer tokens
Authentication is configured per MCP server in your .mcp.json
:
{
"mcpServers": {
"secured-service": {
"type": "http",
"url": "https://api.example.com/mcp",
"auth": {
"type": "oauth",
"clientId": "your-client-id", // Optional for dynamic registration
"scopes": ["read", "write"],
},
},
},
}
If this tool helps you build amazing integrations, consider sponsoring the project to support continued development. π
MIT Licensed β’ Feel free to use this in your commercial projects, contribute back, or fork it entirely. Code should be free! π
Built with β€οΈ by Konstantin Tarkus and contributors.