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.
Generate & Validate Multi-Client MCP Config
One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.
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:
{
"mcpServers": {
"fetch": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-fetch"]
}
}
}Available Tools
The server exposes a single, highly flexible tool:
| Tool | Description |
|---|---|
fetch | Retrieve 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/USDand 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
POSTrequests.
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
fetchtool 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:
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)
Build your full agent toolstack in the Visual Generator
Combine Fetch with databases, search APIs, and memory graphs in a single configuration file.
Related Guides
How to Use Stripe's Machine Payments Protocol (MPP) as an MCP Client
Learn how to configure your AI agent as an MCP client that can automatically pay per tool usage using Stripe's Machine Payments Protocol β enabling access to premium, monetized MCP servers.
APIsHow to Set Up the Brave Search MCP Server for Web Research
Enable your AI agent to search the web using Brave Search API through MCP. Perfect for research, fact-checking, and gathering real-time information.
APIsHow to Accept Stripe's Machine Payments Protocol (MPP) in Your MCP Server
Monetize your MCP server by accepting per-tool-call payments using Stripe's Machine Payments Protocol. This guide covers pricing schemas, payment verification, and webhook handling.