The MCP Fetch server provides versatile tools for web interaction and automation:
HTTP Requests: Full control over methods, headers, body, and fetch options
GraphQL Operations: Execute queries, mutations, and schema introspection to list operations or get type details
WebSocket Management: Connect to URLs, send/receive messages, list active connections, and close them
Browser Automation: Use Puppeteer to launch/close browsers (headless or non-headless), create/close pages, list active instances, and execute JavaScript code
Built-in Documentation: Access comprehensive documentation detailing all tools, parameters, and usage examples
Provides browser automation capabilities using Puppeteer, enabling control of browsers, page creation, and execution of arbitrary JavaScript for web scraping, testing, and development tasks.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Fetchscrape the latest headlines from the New York Times homepage"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Fetch
A Model Context Protocol server providing tools for HTTP requests, GraphQL queries, WebSocket connections, and browser automation using Puppeteer.
Configuration
Add this to your MCP settings configuration file:
{
"mcp-fetch": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-fetch"
]
}
}Related MCP server: MCP Selenium
Installation
If the puppeteer tool is not working, remember to install the chrome browser
npx puppeteer browsers install chromeFeatures
HTTP Requests: Perform HTTP requests with full control over method, headers, and body
GraphQL Client: Execute queries/mutations and introspect GraphQL schemas
WebSocket Management: Connect, send, receive messages, and manage WebSocket connections
Browser Automation: Launch browsers, create pages, and execute JavaScript using Puppeteer
Comprehensive Docs: AI-ready documentation via
get-rulestool
Available Tools
HTTP Requests
fetch
Perform HTTP requests with full control over method, headers, body, and other fetch options.
Parameters:
url(string, required): The URL to fetch frommethod(string, optional): HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS). Default: "GET"headers(object, optional): HTTP headers as key-value pairsbody(string, optional): Request body for POST, PUT, PATCH, DELETEmode(string, optional): Request mode (cors, no-cors, same-origin)credentials(string, optional): Credentials mode (omit, same-origin, include)cache(string, optional): Cache mode (default, no-store, reload, no-cache, force-cache, only-if-cached)redirect(string, optional): Redirect handling (follow, error, manual). Default: "follow"referrer(string, optional): Referrer URLreferrerPolicy(string, optional): Referrer policytimeout(number, optional): Request timeout in millisecondsfollowRedirects(boolean, optional): Whether to follow redirects. Default: true
Returns:
{
"status": 200,
"statusText": "OK",
"headers": { "content-type": "application/json" },
"body": "Response body as string",
"redirected": false,
"url": "https://api.example.com/data"
}Example Usage:
// Simple GET request
fetch({ url: "https://api.example.com/users" })
// POST request with JSON body
fetch({
url: "https://api.example.com/users",
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "John Doe", email: "john@example.com" })
})
// Request with authentication and timeout
fetch({
url: "https://api.example.com/protected",
headers: { "Authorization": "Bearer token123" },
timeout: 5000
})GraphQL
graphql
Execute GraphQL queries and mutations with support for variables and custom headers.
Parameters:
action(object, required): Action to perform with discriminated union:For execution:
type: "execute"endpoint(string): GraphQL endpoint URLquery(string): GraphQL query or mutation stringvariables(object, optional): Variables for the query/mutationheaders(object, optional): HTTP headers (e.g., authorization)operationName(string, optional): Operation name when query contains multiple operationstimeout(number, optional): Request timeout in milliseconds. Default: 30000
For introspection:
type: "introspect"endpoint(string): GraphQL endpoint URLheaders(object, optional): HTTP headersaction(string): What to fetch: "full-schema", "list-operations", or "get-type"typeName(string, optional): Type name (required when action is "get-type")useCache(boolean, optional): Use cached schema if available. Default: truecacheTTL(number, optional): Cache time-to-live in milliseconds. Default: 300000
Returns: For execution:
{
"data": { "user": { "id": "1", "name": "John Doe" } },
"errors": [],
"extensions": {}
}For introspection:
{
"operations": {
"queries": ["getUser", "listUsers"],
"mutations": ["createUser", "updateUser"],
"subscriptions": []
}
}Example Usage:
// Execute a query
graphql({
action: {
type: "execute",
endpoint: "https://api.example.com/graphql",
query: `
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
}
}
`,
variables: { id: "123" },
headers: { "Authorization": "Bearer token123" }
}
})
// Introspect schema
graphql({
action: {
type: "introspect",
endpoint: "https://api.example.com/graphql",
action: "list-operations"
}
})WebSocket
socket
Manage WebSocket connections - connect, send, receive messages, list connections, and close.
Parameters:
action(object, required): Action to perform with discriminated union:For listing connections:
type: "list"
For connecting:
type: "connect"url(string): WebSocket URL (ws:// or wss://)protocols(array, optional): WebSocket subprotocolsheaders(object, optional): HTTP headers for connectionautoReconnect(boolean, optional): Auto-reconnect on disconnection. Default: falsemaxReconnectAttempts(number, optional): Max reconnection attempts. Default: 5reconnectInterval(number, optional): Base reconnect interval in ms. Default: 1000messageHistoryLimit(number, optional): Max messages to keep. Default: 100
For sending:
type: "send"socketId(string): Socket connection IDmessage(string or object): Message to sendbinary(boolean, optional): Send as binary data. Default: false
For receiving:
type: "receive"socketId(string): Socket connection IDaction(string): "get-latest", "get-all", or "get-since"since(string, optional): ISO timestamp for get-sinceclearAfterRead(boolean, optional): Clear queue after reading. Default: false
For closing:
type: "close"socketId(string): Socket connection IDcode(number, optional): Close code. Default: 1000reason(string, optional): Close reason. Default: "Normal closure"
Returns: For connect:
{
"socketId": "ws_1234567890_abc123",
"url": "wss://example.com/socket",
"readyState": "OPEN",
"protocol": "",
"messageCount": 0
}Example Usage:
// Connect to WebSocket
socket({
action: {
type: "connect",
url: "wss://example.com/socket",
headers: { "Authorization": "Bearer token123" },
autoReconnect: true
}
})
// Send message
socket({
action: {
type: "send",
socketId: "ws_1234567890_abc123",
message: { type: "subscribe", channel: "updates" }
}
})
// Receive messages
socket({
action: {
type: "receive",
socketId: "ws_1234567890_abc123",
action: "get-latest"
}
})Browser Automation
puppeteer
Control browsers and pages with Puppeteer - launch/close browsers, open/close pages, execute JavaScript, and more.
Parameters:
action(object, required): Action to perform with discriminated union:For listing browsers:
type: "list-browsers"
For launching browser:
type: "launch-browser"headless(boolean, optional): Run in headless mode. Default: falsewidth(number, optional): Window width. Default: 1280height(number, optional): Window height. Default: 720url(string, optional): URL to navigate to after launch
For closing browser:
type: "close-browser"browserId(string): Browser instance ID
For listing pages:
type: "list-pages"
For opening page:
type: "open-page"browserId(string): Browser instance IDurl(string, optional): URL to navigate to
For closing page:
type: "close-page"pageId(string): Page ID
For executing code:
type: "exec-page"pageId(string): Page IDsource(string): JavaScript code to execute (has access topageobject)
Returns: For launch-browser:
{
"success": true,
"browserId": "browser_1234567890_abc123",
"message": "Browser launched successfully",
"config": {
"headless": false,
"width": 1280,
"height": 720
}
}Example Usage:
// Launch browser and navigate
puppeteer({
action: {
type: "launch-browser",
headless: false,
url: "https://example.com"
}
})
// Execute page automation
puppeteer({
action: {
type: "exec-page",
pageId: "page_id",
source: `
await page.goto('https://example.com');
await page.type('#search', 'hello world');
await page.click('#submit');
const title = await page.title();
return title;
`
}
})Documentation
get-rules
Get comprehensive documentation about this MCP server.
Parameters:
random_string(string): Dummy parameter for no-parameter tools
Returns: Complete documentation including schemas, use cases, and best practices.
Use Cases
API Integration
Use the fetch tool to integrate with REST APIs, webhooks, and external services.
// Fetch data from REST API
fetch({
url: "https://api.github.com/users/octocat",
headers: { "Accept": "application/vnd.github.v3+json" }
})
// Submit form data
fetch({
url: "https://api.example.com/submit",
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "name=John&email=john@example.com"
})GraphQL Operations
Use the graphql tool for type-safe API queries and schema exploration.
// Query user data
graphql({
action: {
type: "execute",
endpoint: "https://api.example.com/graphql",
query: `query { users { id name email } }`
}
})
// Explore available operations
graphql({
action: {
type: "introspect",
endpoint: "https://api.example.com/graphql",
action: "list-operations"
}
})Real-time Communication
Use the socket tool for WebSocket connections, chat applications, and live data feeds.
// Connect to chat server
socket({
action: {
type: "connect",
url: "wss://chat.example.com",
autoReconnect: true
}
})
// Subscribe to live updates
socket({
action: {
type: "send",
socketId: "socket_id",
message: { action: "subscribe", topics: ["news", "alerts"] }
}
})Web Automation
Use the puppeteer tool for web scraping, automated testing, and browser interactions.
// Automated form submission
puppeteer({
action: {
type: "exec-page",
pageId: "page_id",
source: `
await page.goto('https://forms.example.com');
await page.type('#name', 'John Doe');
await page.type('#email', 'john@example.com');
await page.click('#submit');
await page.waitForNavigation();
return page.url();
`
}
})
// Screenshot generation
puppeteer({
action: {
type: "exec-page",
pageId: "page_id",
source: `
await page.goto('https://example.com');
const screenshot = await page.screenshot({ encoding: 'base64' });
return screenshot;
`
}
})Best Practices
General
Always handle errors - Wrap operations in try-catch blocks
Use appropriate timeouts - Set reasonable timeouts for network operations
Clean up resources - Close connections when done (browsers, websockets)
Follow rate limits - Respect API rate limits and add delays if needed
HTTP & GraphQL
Use proper headers - Set Content-Type, Accept, and Authorization headers
Handle redirects appropriately - Consider security implications
Validate responses - Check status codes and response formats
Use HTTPS - Always prefer secure connections
WebSockets
Implement reconnection logic - Use autoReconnect for critical connections
Handle connection states - Check readyState before sending
Process messages efficiently - Clear message queues regularly
Use appropriate close codes - Follow WebSocket close code standards
Browser Automation
Use headless mode for automation - Better performance and resource usage
Wait for elements - Use waitForSelector before interacting
Handle navigation - Use waitForNavigation after clicks
Limit concurrent browsers - Avoid resource exhaustion
Clean up pages and browsers - Prevent memory leaks
Installation
Dependencies are automatically installed when running the server. If you encounter issues:
# For browser automation (Puppeteer)
npx puppeteer browsers install chrome
# For all dependencies
npm install mcp-fetchLimitations
Browser instances and WebSocket connections are stored in memory and lost on restart
Each browser instance consumes significant system resources
WebSocket message history is limited by messageHistoryLimit
GraphQL introspection cache is temporary and cleared on restart
File uploads are not directly supported (use base64 encoding in body)
License
MIT