[](https://github.com/productdevbook/sufetch) # SuFetch
> Type-safe OpenAPI clients with MCP server for AI-driven API exploration ## Table of Contents - [Features](#features) · [Installation](#installation) · [Quick Start](#quick-start) - [MCP Server Setup](#mcp-server-setup) · [Supported APIs](#supported-apis) - [Development](#development) · [Contributing](#contributing) --- ## What is SuFetch? SuFetch combines two powerful tools: 1. **Type-Safe API Clients** - Generate fully-typed TypeScript clients from OpenAPI specifications 2. **MCP Server** - Let AI assistants (like Claude) explore your APIs and generate code Built with [apiful](https://github.com/johannschopplich/apiful) for type-safe OpenAPI clients. ## Features - ✨ **Fully Type-Safe** - Autocomplete and type checking for all API calls - 🤖 **MCP Integration** - AI assistants can explore and generate code for your APIs - 🔄 **Auto-Discovery** - Automatic service detection and type generation - 🛠️ **Modern Stack** - TypeScript 5.7, ESNext, strict mode - 🧪 **Well-Tested** - 76+ tests with >60% coverage ## Installation ### For Using the API Client ```bash # npm npm install sufetch # pnpm pnpm add sufetch # yarn yarn add sufetch ``` ### For MCP Server (Global) ```bash # Install globally npm install -g sufetch # Verify installation sufetch-mcp --version ``` ### For Development ```bash git clone https://github.com/productdevbook/sufetch.git cd sufetch pnpm install pnpm build ``` ## Quick Start ### Using the Type-Safe API Client ```typescript import { createClient, cloud } from 'sufetch/hetzner' // Create a typed client const client = createClient({ baseURL: 'https://api.hetzner.cloud/v1', headers: { 'Authorization': 'Bearer your-api-token' } }).with(cloud) // Fully typed requests and responses const servers = await client('/servers', { method: 'GET' // ✅ Type-checked }) // TypeScript knows the response type console.log(servers.servers) // ✅ Autocomplete works ``` See [Supported APIs](#supported-apis) for all available services. ### Type Helpers for Advanced Type Safety Extract specific types from endpoints for maximum type safety: ```typescript import type { HetznerCloud } from 'sufetch/hetzner' // Extract request body type type CreateServerBody = HetznerCloud<'/servers', 'post'>['request'] // Extract response type type GetServerResponse = HetznerCloud<'/servers/{id}', 'get'>['response'] // Extract query parameters type ListServersQuery = HetznerCloud<'/servers', 'get'>['query'] // Extract path parameters type ServerPathParams = HetznerCloud<'/servers/{id}', 'get'>['path'] // Use in functions for type safety function processServer(server: GetServerResponse) { console.log(server.server.id) // ✅ Full autocomplete console.log(server.server.name) // ✅ Type-checked } function createServer(body: CreateServerBody) { // TypeScript enforces correct structure return client('/servers', { method: 'POST', body // ✅ Type-safe }) } ``` **Available properties:** - `['request']` - Request body type - `['response']` - Success response (200/201) - `['query']` - Query parameters - `['path']` - Path parameters - `['responses'][status]` - Specific status code response Works with all APIs: `HetznerCloud`, `DigitalOcean`, `OryKaratos`, `OryHydra`. ### Using with AI Assistants (MCP) See the [MCP Server Setup](#mcp-server-setup) section below. ## Supported APIs SuFetch currently includes: | API | Description | Endpoints | Import | |-----|-------------|-----------|--------| | **DigitalOcean** | Complete cloud platform API | 200+ | `sufetch/digitalocean` | | **Hetzner Cloud** | Cloud infrastructure management | 100+ | `sufetch/hetzner` | | **Ory Kratos** | Identity & user management | 50+ | `sufetch/ory` | | **Ory Hydra** | OAuth 2.0 & OpenID Connect | 40+ | `sufetch/ory` | **Want to add more?** See [Adding New APIs](#adding-new-apis). ## MCP Server Setup ### Quick Setup **1. Install (choose one):** ```bash npm install -g sufetch # Global npx sufetch-mcp # No install ``` **2. Configure:**