All How-To Guides

3 Ways to Call REST APIs with Claude Code

How to call REST APIs with Claude Code?

3 MCP servers featured

Integrating with external APIs is fundamental to modern development. MCP servers can give Claude the ability to call any REST API, whether through OpenAPI specs or direct HTTP requests. Here are the best options for API integration.

Recommended MCP Servers

OpenAPI MCP Server

janwilmake/openapi-mcp-server

>800

A powerful server that allows AI to navigate complex OpenAPI specifications using simplified language.

Key Features

  • OpenAPI v3 support
  • Auto-generate tools from spec
  • Any REST API
  • Type-safe requests

Installation

npx openapi-mcp-server

OpenAPI MCP Server automatically generates tools from your API's OpenAPI specification. Just provide the spec URL and Claude can call any endpoint. Perfect for well-documented APIs.

Best for: APIs with OpenAPI specs View on GitHub

Fetch MCP (Anthropic)

anthropics/mcp-server-fetch

>2k

Official Anthropic server for making HTTP requests to any URL.

Key Features

  • Any HTTP request
  • GET, POST, PUT, DELETE
  • Custom headers
  • JSON and form data

Installation

npx @modelcontextprotocol/server-fetch

The official Fetch MCP handles any HTTP request. When you don't have an OpenAPI spec or need custom requests, Fetch provides the flexibility to call any endpoint with any method.

Best for: Any API without spec View on GitHub

OpenAPI-MCP Docker

ckanthony/openapi-mcp

>100

Dockerized MCP Server to allow your AI agent to access any API with existing API docs.

Key Features

  • Dockerized deployment
  • Any API with OpenAPI docs
  • Containerized security
  • Easy setup

Installation

See GitHub for Docker setup

A dockerized MCP Server that allows AI agents to access any API by providing the existing API documentation. Great for containerized environments and secure deployments.

Best for: Docker-based workflows View on GitHub

Quick Comparison

MCPStarsBest ForProsCons
OpenAPI MCP>500Documented APIsAuto-generates toolsNeeds spec
Fetch MCP>2kAny APIMaximum flexibilityManual requests
Composio>1kQuick integration2,500+ APIsThird-party dependency

Getting Started

To call REST APIs with Claude Code:

  1. For APIs with OpenAPI specs:

    npx openapi-mcp --spec https://api.example.com/openapi.json
    
  2. For any API, use the Fetch MCP:

    npx @modelcontextprotocol/server-fetch
    
  3. For quick integrations, explore Composio's 2,500+ pre-built APIs.

Example prompt: "Call the GitHub API to get my repositories and list the ones with the most stars."

Related Guides