APIs·
beginner
·9 min read·Apr 4, 2026

How to Use the Fetch MCP Server for API Integration

Enable your AI agent to fetch content from any URL or API endpoint. Perfect for reading documentation, consuming REST APIs, and gathering web content.

fetchAPIHTTPweb contentREST

Use the Fetch MCP Server for API Integration

The Fetch MCP server is the simplest yet most versatile tool you can give your AI agent. It provides the ability to retrieve content from any HTTP/HTTPS URL, bridging the gap between your agent's frozen training data and the live internet.

Configuration Setup

Add this configuration to your MCP client:

json
{
  "mcpServers": {
    "fetch": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-fetch"]
    }
  }
}

Available Tools

The server exposes a single, highly flexible tool:

ToolDescription
fetchRetrieve content from a URL via GET or POST

Supported Content Types

The server acts as a middleware, automatically transforming raw data into formats easily digestible by LLMs:

  • HTML pages → Converted to clean Markdown, stripping out ads, scripts, and CSS.
  • JSON responses → Returned as minified, structured data.
  • Plain text → Returned as-is.
  • XML/RSS → Parsed and formatted into readable hierarchies.

Example Workflows

  • Reading Documentation: "Fetch the React documentation page about hooks from their website and summarize the key concepts."
  • API Consumption: "Fetch the latest exchange rates from api.exchangerate-api.com/v4/latest/USD and calculate the conversion for 500 Euros."
  • Content Analysis: "Fetch the content from this blog post URL and create a bullet-point summary of the author's arguments."

Request Configuration

The fetch tool is not just for GET requests. Your agent can configure complex requests, including:

  • Custom Headers: Injecting Authorization: Bearer <token> to hit protected REST APIs.
  • Request Body: Sending JSON payloads for POST requests.

Limitations & Troubleshooting

  • Payload Too Large: If the agent fetches a massive webpage, the resulting Markdown may exceed the LLM's context window. The Fetch server attempts to truncate enormous responses, but targeted APIs are always better than full HTML scrapes.
  • 403 Forbidden / Cloudflare Blocks: Many modern websites employ Cloudflare or WAF bot-protection. Since the fetch tool uses a standard Node.js HTTP client, it will often be blocked by these firewalls. Use the Puppeteer MCP Server for scraping heavily protected sites.
  • Client-Side Rendering: If the agent fetches a React/Vue SPA URL, it will likely just return <div id="root"></div>. Fetch cannot execute JavaScript. Again, use Puppeteer if you need JS rendering.

Using with OpenAI Codex

To use this MCP server with the OpenAI Codex CLI, you can add it to your configuration using the codex mcp add command:

bash
codex mcp add --name fetch --command "npx @modelcontextprotocol/server-fetch"

(Note: Depending on the server, you may need to append arguments or use --env flags for environment variables as described in the configuration section above)

Related Guides