The MCP Node Fetch server enables fetching web content using the Node.js undici library. It provides tools for retrieving content from URLs, extracting HTML fragments using CSS selectors, and checking website status—all accessible to Claude through the Model Context Protocol.
To use the MCP Node Fetch server with Claude for Desktop, add the server configuration to your claude_desktop_config.json
file:
{
"mcpServers": {
"node-fetch": {
"command": "node",
"args": ["dist/index.js"]
}
}
}
The server provides three main tools for interacting with web content.
The fetch-url
tool retrieves content from any URL and returns it in various formats.
Parameters:
url
(string, required): The URL to fetchmethod
(string, optional): HTTP method (default: "GET")headers
(object, optional): HTTP headers to includebody
(string, optional): Request body for POST/PUT requeststimeout
(number, optional): Request timeout in millisecondsresponseType
(string, optional): How to parse the response ("text", "json", "binary", "html-fragment")fragmentSelector
(string, optional): CSS selector to extract specific HTML fragments (when responseType is "html-fragment")followRedirects
(boolean, optional): Whether to follow redirects (default: true)Example usage:
// Basic GET request
const response = await fetch-url({
url: "https://example.com"
});
// POST request with JSON body
const postResponse = await fetch-url({
url: "https://api.example.com/data",
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ key: "value" }),
responseType: "json"
});
The extract-html-fragment
tool extracts specific content from a webpage using CSS selectors.
Parameters:
url
(string, required): The URL to fetchselector
(string, required): CSS selector for the HTML fragment to extractanchorId
(string, optional): Optional anchor ID to locate a specific fragmentmethod
(string, optional): HTTP method (default: "GET")headers
(object, optional): HTTP headers to includebody
(string, optional): Request body for POST requeststimeout
(number, optional): Request timeout in millisecondsfollowRedirects
(boolean, optional): Whether to follow redirects (default: true)Example usage:
// Extract main content section
const mainContent = await extract-html-fragment({
url: "https://example.com",
selector: "main"
});
// Extract content and navigate to specific anchor
const specificSection = await extract-html-fragment({
url: "https://example.com",
selector: ".content-section",
anchorId: "section-3"
});
The check-status
tool verifies if a URL is accessible without downloading the full content.
Parameters:
url
(string, required): The URL to checktimeout
(number, optional): Request timeout in millisecondsExample usage:
// Check if a website is accessible
const status = await check-status({
url: "https://example.com",
timeout: 5000
});
const htmlContent = await fetch-url({
url: "https://news-site.com/article/12345",
responseType: "text"
});
const apiResponse = await fetch-url({
url: "https://api.service.com/data",
headers: {
"Authorization": "Bearer YOUR_TOKEN"
},
responseType: "json"
});
const articleHeadlines = await extract-html-fragment({
url: "https://news-site.com",
selector: "h2.headline"
});
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.