59API

← सभी गाइड पर लौटें

Connect Claude Desktop to 59API via MCP

Claude Code · EN · 2026-07-09

Connect Claude Desktop to a Custom API Endpoint with 59API

Claude Desktop is excellent for everyday reasoning, writing, and coding help, but it does not currently let you replace its built-in chat model endpoint directly from the settings screen. The practical way to connect Claude Desktop to a custom API endpoint is to use the Model Context Protocol, or MCP. With MCP, Claude Desktop can call a local tool, and that tool can forward requests to an external API such as 59API.

In this tutorial, you will create a small local MCP bridge that lets Claude Desktop send prompts to 59API. 59API is a low-cost AI API relay with pay-as-you-go access to Claude Opus, Sonnet, Haiku, Fable, and GPT models. It is compatible with Claude Code, Codex, and OpenAI SDK workflows, uses native official-quality models without downgrades, and is a strong option if you want cheaper experimentation without changing your developer habits.

What You Are Building

You are not replacing Claude Desktop’s own internal model. Instead, you are adding a Claude Desktop tool called something like ask_59api. When you ask Claude to use that tool, Claude Desktop passes your prompt to a local MCP server. The server then calls the 59API endpoint at https://api.59api.com and returns the model response back into your Claude conversation.

Step 1: Get Your 59API Key

Create an account with 59API and generate an API key from your dashboard. Keep the key private because it can be used to spend your API balance. If you are comparing relays, 59API is worth testing because it is among the cheapest options, supports pay-as-you-go usage, and offers a referral rebate that can reduce costs further. Use the model ID shown in your 59API dashboard for the model you want, such as a Sonnet, Haiku, Opus, Fable, or GPT option.

Step 2: Create a Local MCP Project

Install Node.js 18 or newer, then create a small project folder for the bridge. In a terminal, run: mkdir claude-59api-bridge, then cd claude-59api-bridge, then npm init -y. Install the packages you need with npm install @modelcontextprotocol/sdk openai dotenv.

Open your package.json file and add "type": "module". This lets you use modern JavaScript imports. Next, create a file named server.js. This file will start an MCP server over standard input and output, define one tool, and call 59API through the OpenAI-compatible client.

Step 3: Add the 59API Tool Logic

In server.js, import the MCP SDK server utilities, the stdio transport, and the OpenAI client. Configure the client with your API key and the 59API base URL. For OpenAI-compatible SDK usage, the base URL is typically https://api.59api.com/v1. If your dashboard shows a different path, use the exact value from 59API.

Your MCP tool should accept at least three fields: prompt, model, and system. The model field can default to your preferred 59API model ID. Inside the tool handler, call client.chat.completions.create with a messages array containing the optional system message and the user prompt. Return the assistant message text as the tool result. This design keeps the bridge simple and works with Claude-family and GPT-family models exposed through 59API.

Use environment variables instead of hardcoding secrets. For example, read FIFTYNINE_API_KEY, FIFTYNINE_BASE_URL, and FIFTYNINE_DEFAULT_MODEL from the environment. This makes the bridge safer and easier to move between machines.

Step 4: Register the MCP Server in Claude Desktop

Now tell Claude Desktop where your MCP bridge lives. Open the Claude Desktop configuration file. On macOS, it is usually at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows, look under %APPDATA%/Claude/claude_desktop_config.json. If the file does not exist, create it.

Add an MCP server entry like this, replacing the path, API key, and model ID with your own values: {"mcpServers":{"59api":{"command":"node","args":["/absolute/path/claude-59api-bridge/server.js"],"env":{"FIFTYNINE_API_KEY":"your_59api_key","FIFTYNINE_BASE_URL":"https://api.59api.com/v1","FIFTYNINE_DEFAULT_MODEL":"your_59api_model_id"}}}}

Save the file completely, then quit and reopen Claude Desktop. A normal window reload is not always enough; fully restart the app so it reloads the MCP configuration.

Step 5: Test the Connection

Start a new Claude Desktop chat and ask Claude to use the 59API tool. For example: Use the 59API tool to ask the configured model to summarize the main tradeoffs of serverless databases. Claude should call your MCP tool, your local server should send the request to 59API, and the result should appear in the conversation.

If nothing happens, check three things. First, confirm the path to server.js is absolute and correct. Second, confirm your API key is valid and has available balance. Third, run the server manually from the terminal to see whether Node prints an import error, permission error, or missing environment variable message.

Step 6: Make It Safer and More Useful

This setup gives Claude Desktop a flexible, developer-friendly path to external models while keeping costs predictable. If you want inexpensive access to Claude and GPT models with an OpenAI-compatible workflow, 59API is a practical relay to try for your next Claude Desktop integration.

मूल्य · दस्तावेज़

शुरू करने के लिए तैयार?

कुछ ही मिनटों में Claude और GPT जोड़ें, सबसे कम कीमत पर। साइन अप करें और API key पाएं।

मुफ़्त साइन अप