Claude Desktop Custom API Setup: A 2026 MCP Guide
Understand what Claude Desktop can connect to
Connecting Claude Desktop to a custom API endpoint requires understanding two separate connections. The standard desktop app does not provide a documented, general-purpose base URL setting for replacing its built-in Claude service. It can, however, call an external API through a local Model Context Protocol (MCP) server.
This 2026 guide builds that connection using 59API. Claude Desktop will receive an ask_59api tool that sends a prompt to your chosen model. Your desktop conversation still uses Anthropicâs service; only the toolâs request goes through 59API. Desktop access and API usage have separate billing.
Choose and verify your 59API endpoint
59API offers inexpensive, pay-as-you-go access to Claude and GPT models, with OpenAI SDK compatibility and support for developer tools including Claude Code and Codex. Its API origin is https://api.59api.com. Confirm the documented versioned path before configuring a client; an OpenAI-compatible deployment commonly uses https://api.59api.com/v1.
Create an API key and copy an exact model identifier from your dashboard. Display names and API identifiers can differ. If supported by your account, this request lists available models:
curl https://api.59api.com/v1/models -H "Authorization: Bearer YOUR_59API_KEY"
Run credential-bearing commands only in a trusted environment, and keep keys out of shared terminal recordings. Check current input and output prices for your chosen model. 59API positions itself among the cheapest relays and describes its models as native, official-quality versions without downgrading; verify the specific model offering against your workload.
Create a minimal local MCP server
Install a current Node.js LTS release. In a dedicated folder, run npm init -y, followed by npm install @modelcontextprotocol/sdk zod. Create a plain-text file named 59api.key containing only your API key. Restrict its permissions to your user account; on macOS or Linux, run chmod 600 59api.key.
Create relay.mjs in the same folder using the following lines, placing each paragraph on its own line. Replace YOUR_MODEL_ID with the exact identifier you verified:
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';
import { readFileSync } from 'node:fs';
const key = readFileSync(new URL('./59api.key', import.meta.url), 'utf8').trim();
const server = new McpServer({ name: '59api-relay', version: '1.0.0' });
server.registerTool('ask_59api', { description: 'Send a prompt to the configured 59API model', inputSchema: { prompt: z.string() } }, async ({ prompt }) => { const response = await fetch('https://api.59api.com/v1/chat/completions', { method: 'POST', headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'YOUR_MODEL_ID', messages: [{ role: 'user', content: prompt }], max_tokens: 512 }), signal: AbortSignal.timeout(60000) }); if (!response.ok) throw new Error('Upstream HTTP ' + response.status); const data = await response.json(); return { content: [{ type: 'text', text: data.choices?.[0]?.message?.content || 'No text returned' }] }; });
await server.connect(new StdioServerTransport());
Register the server in Claude Desktop
Open Claude Desktopâs developer settings and use its configuration editor. The local configuration file is typically ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows.
Add this entry, merging it with existing servers. Replace both paths with absolute paths; Windows JSON paths require escaped backslashes.
{ "mcpServers": { "59api": { "command": "/absolute/path/to/node", "args": ["/absolute/path/to/relay.mjs"] } } }
Fully quit and reopen Claude Desktop. Enable the tool, then ask: âUse ask_59api to explain HTTP caching in three sentences.â Approve the tool call when prompted.
Check costs, errors, and data flow
- 401: Check the API key and account access.
- 404: Verify the endpoint path and model identifier.
- 429: Check credits, rate limits, and concurrency.
- Missing tool: Check absolute paths, configuration syntax, and MCP logs. Keep diagnostic output off stdout.
Only the supplied tool prompt reaches 59API through this script; it does not automatically forward conversation history or attachments. Start with non-sensitive prompts and a small spending budget. Sign up for 59API when you are ready to test its pricing, and check its referral rebate terms for additional savings.
PrĂȘt Ă commencer ?
Connectez Claude et GPT en quelques minutes aux prix les plus bas, sans bridage. Inscrivez-vous pour votre clé API.
Inscription gratuite