AI Tools

How to Connect Claude to Any API Using MCP

By UlexAI • Published on Jun 3, 2026

The Model Context Protocol has become the default way to connect AI assistants to external tools in 2026. MCP SDK downloads recently surpassed 300 million per month, up from 100 million at the start of the year, with millions of people using MCP with Claude every day. The protocol underpins much of what Anthropic has shipped recently, including Claude Cowork, Claude Managed Agents, and channels in Claude Code.

This guide shows you exactly how to connect Claude to any API using MCP. You will learn the universal server pattern that works with dozens of APIs using minimal tooling, how to set up remote MCP servers, and real working examples using the FastMCP Python SDK.

The Bottom Line

MCP lets Claude discover and call any REST API without LangChain, prompt hacks, or model-specific function-calling glue. One server works with Claude Desktop, Claude Code, Cursor, ChatGPT, and any other MCP-compatible client.

What Is MCP and Why It Matters in 2026

The Model Context Protocol is an open spec from Anthropic that defines how a language model discovers and calls external tools over a standard transport. When Claude connects to an MCP server, it automatically gets a list of callable tools, each with a name, description, and JSON input schema. No client-side tool registration, no custom function definitions in every prompt.

Before MCP, if you wanted Claude to call your REST API, you had limited options. You could write function-calling glue against each model provider's SDK and maintain it as their schemas drifted. You could wrap the API in a framework like LangChain, which added latency and pinned you to a specific agent pattern. Or you could prompt-inject API docs into the system prompt and hope the model produced valid output.

MCP replaces all three. The server is the contract, and every MCP-compatible client—Claude Desktop, Claude Code, Cursor, ChatGPT desktop, and others—can use the same server without modification. Tool discovery happens at connection time, so adding a new endpoint is a redeploy of the server, not a change to every client that uses it.

The Universal MCP Server Pattern

Instead of building separate MCP servers for each API, you can create a single universal adapter that normalizes authentication, request formatting, and response handling. This pattern, demonstrated by developers building servers that connect to dozens of APIs using just two core tools, solves three critical problems: one claude_desktop_config.json entry instead of many, all APIs appear in Claude's tool palette with uniform naming, and API keys and authentication managed in one place.

The universal pattern relies on two components: a protocol translator that converts between MCP's standardized tool calls and each API's unique REST interface, and an API schema registry—a declarative configuration that maps API endpoints to MCP tools, authentication methods to secure credential storage, and response formats to Claude-readable structures.

MCP Transport Options

MCP servers can communicate over two transports: stdio runs the server as a local subprocess through standard input/output, ideal for local tools; Streamable HTTP runs the server as a remote service, suitable for shared team servers and cloud deployments. Claude Desktop supports both.

Step-by-Step: Building an MCP Server for Any REST API

Step 1: Install the MCP Python SDK

The official Python SDK has the most mature tooling in 2026, so this guide uses it. A TypeScript SDK is also available if you prefer Node.js.

# Create a project and install the SDK + HTTP client
  mkdir my-mcp-server
  cd my-mcp-server
  python -m venv venv
  source venv/bin/activate  # On Windows: venv\Scripts\activate
  pip install "mcp[cli]" httpx

Step 2: Write the MCP Server

Create a Python file for your server. The FastMCP helper reads your type hints and docstrings to auto-generate the input schema Claude uses to select tools. Here is a complete working example:

"""Universal MCP Server for any API"""
  import os
  from typing import Any
  import httpx
  from mcp.server.fastmcp import FastMCP
  
  mcp = FastMCP("my-api-server")
  
  # Read API configuration from environment variables
  API_BASE_URL = os.environ.get("API_BASE_URL", "https://api.example.com/v1")
  API_KEY = os.environ.get("API_KEY")
  
  async def api_request(endpoint: str, params: dict[str, Any] = None) -> dict[str, Any]:
      """Shared helper: call API with proper auth and error handling."""
      if not API_KEY:
          return {"error": "API_KEY environment variable is not set."}
  
      headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
      url = f"{API_BASE_URL}/{endpoint}"
  
      async with httpx.AsyncClient(timeout=30.0) as client:
          try:
              response = await client.get(url, headers=headers, params=params)
              response.raise_for_status()
              return response.json()
          except httpx.HTTPStatusError as exc:
              return {"error": f"HTTP {exc.response.status_code}", "detail": exc.response.text[:500]}
          except httpx.HTTPError as exc:
              return {"error": "Network error", "detail": str(exc)}
  
  @mcp.tool()
  async def search_items(query: str, limit: int = 10) -> dict[str, Any]:
      """Search for items in the API.
  
      Use this when the user asks to find specific items, products,
      or data by keyword.
  
      Args:
          query: The search term to look for.
          limit: Maximum number of results to return (1-50). Defaults to 10.
      """
      params = {"q": query, "limit": max(1, min(limit, 50))}
      return await api_request("items/search", params)
  
  @mcp.tool()
  async def get_item_details(item_id: str) -> dict[str, Any]:
      """Get detailed information about a specific item.
  
      Use this when the user asks about a particular item by ID.
  
      Args:
          item_id: The unique identifier of the item.
      """
      return await api_request(f"items/{item_id}")
  
  if __name__ == "__main__":
      mcp.run(transport="stdio")

Never print() to stdout in a stdio-transport server, because it corrupts the JSON-RPC messages and silently breaks the connection. Store API keys in environment variables, never hardcoded in the server file.

Step 3: Configure Claude Desktop

To connect your MCP server to Claude Desktop, you need to add it to the configuration file. Navigate to Settings > Developer on Claude Desktop to find and edit your claude_desktop_config.json file.

{
    "mcpServers": {
      "my-api-server": {
        "command": "python",
        "args": ["/path/to/your/script.py"],
        "env": {
          "API_BASE_URL": "https://api.example.com/v1",
          "API_KEY": "your-api-key-here"
        }
      }
    }
  }

After saving the configuration, restart Claude Desktop. You can verify your server is connected by clicking the "+" button in the chat box, then selecting "Connectors." This shows you connected MCP servers and their available tools.

Remote MCP Servers: Connecting to Cloud-Hosted APIs

Starting in early 2026, developers can build and host remote MCP servers that interact with AI applications over the internet. This is the only configuration that runs across web, mobile, and cloud-hosted agents, and it's what every major client is optimized to consume. Remote MCP servers provide models access to hosted tools and data, transforming Claude into an informed colleague that can independently handle complex multi-step projects tailored to your needs.

Custom connectors using remote MCP are available on Claude for Free, Pro, Max, Team, and Enterprise users. Free users are limited to one custom connector.

Adding a Remote MCP Connector

On individual Pro or Max plans, adding a remote connector is straightforward. Click "+" then "Add Custom Connector" in the connectors panel, add the URL of your remote MCP server, optionally specify OAuth Client ID and Client Secret, then complete setup and enable the connector for individual conversations.

When you add a custom connector, Claude connects to your remote MCP server from Anthropic's cloud infrastructure, not from your local device. This is true for all Claude clients, including claude.ai, Claude Desktop, Cowork, and mobile apps.

Network Requirements

Your MCP server must be accessible through the public internet from Anthropic's IP address ranges. Servers hosted in private corporate networks, behind VPNs, or blocked by firewalls will not connect, even if you can access them from your machine.

Using MCP Servers in Claude Code

Claude Code has robust MCP support. You can set up MCPs in Claude Code in minutes. The process varies across different tools, but using a skill markdown file as an SOP helps Claude Code successfully set up MCP connections regardless of the tool.

The key insight: always research on Google for the specific API's MCP setup guide. Most tools have documentation you can copy and paste directly into Claude Code.

Best Practices for Building MCP Servers

Based on real-world experience building MCP servers that reach millions of users, here are key design patterns that determine how reliably agents can use a server.

Group Tools Around Intent, Not Endpoints

Fewer, well-described tools consistently outperform exhaustive API mirrors. Don't wrap your API one-to-one. Group tools around intent so the agent can accomplish a task in a couple of calls instead of stitching many primitives together. A single create_issue_from_thread tool beats get_thread + parse_messages + create_issue + link_attachment.

Design for Code Orchestration with Large Surfaces

If your service requires hundreds of distinct operations, an intent-grouped toolset likely won't cover it. Instead, expose a thin tool surface that accepts code. The agent writes a short script, your server runs it in a sandbox against your API, and only the result returns. Cloudflare's MCP server is the reference example, covering around 2,500 endpoints with just two tools.

Lean on Standardized Authentication

Standardized auth makes MCP practical for cloud-hosted agents. If your server requires OAuth, the latest MCP spec supports CIMD (Client ID Metadata Documents) for client registration, giving users a fast first-time auth flow and far fewer surprise re-auth prompts.

Comparing MCP to Direct API Calls and CLI

Teams generally converge on three paths for connecting agents to external systems. Each has its place.

Approach Best For Limitation
Direct API Calls One agent talking to one service M×N integration problem at scale
Command-line Interface (CLI) Local environments, sandboxed containers Cannot reach mobile, web, or cloud-hosted platforms
MCP Production agents in the cloud, any deployment Requires upfront investment, but pays off in portability

Troubleshooting Common MCP Issues

Extension Won't Install

Ensure you are running the latest version of Claude Desktop. Check that the extension file isn't corrupted by re-downloading it. Verify you have sufficient disk space for the installation.

Extension Installed But Tools Not Available

Restart Claude Desktop to refresh the extension registry. Check the extension's configuration settings for missing required fields. Verify any API keys or authentication credentials are entered correctly.

Server Doesn't Connect in Private Network

Add Anthropic's IP addresses to your firewall allowlist. The connection to your MCP server originates from Anthropic's servers, not your local machine, even when using Claude Desktop.

Frequently Asked Questions

Do I need to pay for MCP?

MCP is an open protocol and free to use. The MCP SDKs are open source. However, using MCP with Claude may require a Claude plan depending on your usage. Free users are limited to one custom connector. Pro at $20/month gives you higher limits and full access to features like Claude Code and Cowork.

What programming languages can I use to build MCP servers?

MCP supports any language. The official SDKs are available for Python and TypeScript. Desktop extensions also support Node.js, Python, and binary MCP servers. Claude Desktop includes a built-in Node.js environment, so Node.js installation isn't required.

Can I connect Claude to my internal corporate API?

Yes, but the server must be publicly accessible or your firewall must allow inbound connections from Anthropic's IP ranges. Remote MCP servers cannot connect to servers in private corporate networks behind VPNs.

How do I handle API keys securely in MCP?

Store API keys in environment variables passed through the env block of your claude_desktop_config.json. Never hardcode them. For desktop extensions, mark configuration fields as "sensitive": true in your manifest.json, and Claude Desktop will automatically encrypt these values using your OS secure storage (Keychain on macOS, Credential Manager on Windows).

How popular is MCP in 2026?

MCP adoption has grown significantly. The MCP SDKs recently surpassed 300 million downloads per month, up from 100 million at the start of the year. Millions of people use MCP with Claude every day. Forrester predicts that 30% of enterprise app vendors will launch MCP servers in 2026.

Start Connecting Claude to Any API Today

MCP has become the standard for connecting AI assistants to external tools in 2026. The protocol is mature, well-documented, and supported by every major AI client. Whether you choose to build a local stdio server for development tools or a remote HTTP server for production APIs, the same patterns apply.

Start small. Build a local MCP server for one API you use frequently. Test it in Claude Desktop. Once it works, extend the pattern to additional APIs or deploy it as a remote server for team-wide access. The universal pattern described here scales from one API to dozens with minimal additional configuration.

The MCP ecosystem continues to grow rapidly. With over 200 MCP servers in the official directory and millions of daily users, now is the time to build your own integrations.