mcp-server-fetch: 'AnyUrl' object has no attribute 'decode' error
I'm running mcp-server-fetch on macOS (Python 3.11) via
npx @modelcontextprotocol/inspector uvx mcp-server-fetch. When I call the fetch tool with any URL, the server returns the error'AnyUrl' object has no attribute 'decode'. The same error happens in Claude Desktop. How do I fix this?Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/163
2 answers
Status: the issue is closed as completed in the thread; the reporter's local source change fixed the error in both the MCP Inspector and Claude Desktop.
The error occurs when calling the fetch tool. The reporter reproduced it by running
npx @modelcontextprotocol/inspector uvx mcp-server-fetch, listing the tools, then running the fetch tool withhttps://par-com.net. The server returned'AnyUrl' object has no attribute 'decode'as an error.The fix that worked:
-
Clone the
modelcontextprotocol/serversrepository. -
In the mcp-server-fetch source, find the fetch tool's
urlparameter and change:url: Annotated[AnyUrl, Field(description="URL to fetch")]to:
url: Annotated[str, Field(description="URL to fetch")] -
Run the inspector using your local repo checkout so it uses the modified code, then call the fetch tool again. It then returned the page's markdown content.
-
The reporter also verified the same change resolves the error in Claude Desktop.
The thread does not say whether a released version of mcp-server-fetch includes this fix, so check the installed version before relying on the source edit.
General advice: this tool fetches whatever URL it is given, so only expose it to inputs you trust.
Did this work for you?-
What @paulrobello tried on GitHub (Didn't work)
Reproduced the error by running
npx @modelcontextprotocol/inspector uvx mcp-server-fetch, listing tools, and calling the fetch tool withhttps://par-com.net. The server returned'AnyUrl' object has no attribute 'decode'.Source: https://github.com/modelcontextprotocol/servers/issues/163 (opens external site)
Did this work for you?
Related questions
- Does the official MCP Postgres example validate SQL before executing it?
- How to fix UTF-8 Japanese text corruption/crash in mcp-server-sqlite with Claude Desktop on Windows?
- MCP Knowledge Graph Memory Server fails with ${workspaceFolder} in MEMORY_FILE_PATH
- npx @modelcontextprotocol/server-filesystem: ERR_MODULE_NOT_FOUND for zod-to-json-schema
- Claude Desktop MCP servers using npx fail to connect on Windows; fix by using absolute node.exe path after global install