Fetch errors
MCP fetch error result: read isError, the message and the exit code
Tell a fetch tool's error result from a protocol error, read the message text, and check both from the terminal with MCP Inspector's exit codes.
By Lucian Dyer, FetchMCP team · Published
This article was drafted with AI assistance from the sources listed below and edited and published by the FetchMCP team. Disclosure: the FetchMCP API, which this article mentions, is this site's own product.
- Error object or result: a JSON-RPC error is a protocol error; isError true means the tool ran and failed.
- The message text: Read the text content. It names the URL and the reason, such as a status code or robots.txt.
- Error tags in normal output: An <error> tag inside a normal result is page output, not a failed call.
- Exit code: Inspector CLI exits 5 on a tool error, 4 if the server is unreachable, 3 on failed auth.
A fetch tool call failed, and your client shows a red line, a short message or nothing useful. Before you change the config or the prompt, find out which kind of failure you have. MCP has two, and they mean different things.
Checked against the MCP specification 2026-07-28, the reference fetch server's source and the MCP Inspector CLI guide on 2026-12-01.
Know the two error kinds
error in the response, with no result, is a protocol error. The spec uses standard JSON-RPC errors for an unknown tool, a request that does not match the tools/call schema, and server errors. The spec's own example:
{
"jsonrpc": "2.0",
"id": 3,
"error": {
"code": -32602,
"message": "Unknown tool: invalid_tool_name"
}
}
isError: true inside a result is a tool execution error. The call reached the tool, the tool ran, and the work failed: an API failure, an input validation error or a business logic error. The failure is described in the content array, like any other tool output.
The spec treats the two differently. Clients SHOULD pass tool execution errors to the model so it can correct itself. They MAY pass protocol errors, which the spec says are less likely to lead to a successful recovery.
For a fetch tool, that split is useful. A protocol error points at the request: a wrong tool name, a malformed call or a server fault. An isError result points at the work: the URL, the site or the network between the server and the site.
Read the message the reference server sends
mcp-server-fetch, the reference fetch server, raises its expected failures as ToolError. A comment in its source says the SDK returns these to the model as isError results. The message templates in the current source include:
Failed to fetch {url} - status code {response.status_code}for an HTTP status of 400 or higher.- A refusal that quotes the site's robots.txt URL and says autonomous fetching of the page is not allowed.
- A refusal for a host that resolves to a non-public address, which names the
--allow-private-ipsflag. Failed to fetch {url}: timed out after {timeout_ms} ms, followed by the exception, for a timeout.
An unknown tool name is different: the server raises it as a protocol error with code INVALID_PARAMS and the message Unknown tool: {name}.
So a URL that answers 404 comes back as a result like this, in the 2026-07-28 shape:
{
"resultType": "complete",
"content": [
{ "type": "text", "text": "Failed to fetch https://example.com/old-page - status code 404" }
],
"isError": true
}
Read the text before you retry. A status code tells you the site answered. A robots.txt refusal is the site's answer, not a bug. A private-address refusal means the server refuses non-public hosts by default; the localhost post covers that case. The MCP fetch errors guide maps each failure to a next step.
Do not mistake <error> tags for an error result
<error> inside a normal result is not a failed call. The reference server writes a few notices into ordinary page output:
<error>Content truncated. Call the fetch tool with a start_index of …</error>when more of the page is left.<error>No more content available.</error>whenstart_indexis at or past the end.<error>Page failed to be simplified from HTML</error>as the page content when extraction yields nothing.
None of these is raised as a ToolError. The truncation notice in particular means the fetch worked: call the tool again with the start_index it names.
Check it from the terminal
--format json makes MCP Inspector's CLI print one JSON object with no banners, so you see the raw result instead of your client's rendering of it. For the reference server over stdio:
npx @modelcontextprotocol/inspector --cli uvx mcp-server-fetch \
--method tools/call --tool-name fetch \
--tool-args-json '{"url":"https://example.com/old-page"}' \
--format json
echo "exit: $?"
Then read the exit code:
0: the call succeeded. Look at the content anyway, since a page can come back with an<error>notice.5: a tool error. The guide says a call whose result carriesisError:truestill prints its payload but exits 5. A tool that is not found exits 5 too.4: the server is unreachable: DNS, connection refused, a timeout orfetch failed. This is a connection problem, not a fetch problem.3: authentication failed or is required. Fix the key before you look at any fetch.
For a remote server, run the same check with the URL, transport and header your client uses. Start with a tool that does no real work, so an exit code of 3 or 4 is about the connection alone:
npx @modelcontextprotocol/inspector --cli \
--transport http --server-url https://fetchmcp.net/mcp \
--header "Authorization: Bearer $FETCHMCP_API_KEY" \
--method tools/call --tool-name get_account_status \
--format json
echo "exit: $?"
If you pipe the output into jq, capture the exit code first. The guide notes that with pipefail a tool error followed by a failed jq check shows up as 1. The Inspector CLI post covers the basic list and call commands.
Watch for long error text in Claude Code
isError results with long text can lose their middle in Claude Code. A bug report opened on 2026-09-27 against Claude Code 2.1.283 describes error text longer than about 11,000 characters being cut to its first and last 5,000 characters, with a … [N characters truncated] … marker in between. The reporter says nothing is saved to a file and that anthropic/maxResultSizeChars on the tool does not change it. The issue was still open when this post was checked.
In the reporter's tests, an 11,000-character error came through in full. If a server puts a whole error page or a long list into its error text, run the same call through Inspector to read the full message.
Try it with a real server
FetchMCP API's remote server is the https://fetchmcp.net/mcp above. Its get_account_status tool is free, and its error messages are written so the agent can act on them. Failed fetches cost 0 credits. The client configs are in the MCP docs.
Frequently asked questions
What does isError true mean in an MCP tool result?
The tool ran and reports a failure, such as an API failure or bad input. The MCP spec calls this a tool execution error and says clients should pass it to the model so it can correct itself.
What is the difference between a protocol error and a tool error in MCP?
A protocol error is a JSON-RPC error object, used for an unknown tool, a malformed request or a server error. A tool execution error is a normal result with isError set to true and the failure described in its content.
How do I see the raw error result of a fetch tool?
Call the tool with MCP Inspector in CLI mode and add --format json. A result with isError true still prints its payload, and the command exits with code 5.
Why is the middle of a long MCP error message missing in Claude Code?
A Claude Code bug report from September 2026 describes error results longer than about 11,000 characters being cut to their first and last 5,000 characters. In the reporter's tests, an 11,000-character error came through in full.
Sources
- Tools (MCP specification 2026-07-28) (Documentation)
- mcp-server-fetch server.py (modelcontextprotocol/servers) (Documentation)
- MCP Inspector CLI smoke testing guide (Documentation)
- Claude Code issue 97623: MCP error results truncated to first/last 5,000 characters (News)