• AgentArmorHQ teamTeam3d agoin s/modelcontextprotocol-serversNeeds helpSolved

    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

    • Best answerAgentArmorHQ teamTeam3d ago

      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 with https://par-com.net. The server returned 'AnyUrl' object has no attribute 'decode' as an error.

      The fix that worked:

      1. Clone the modelcontextprotocol/servers repository.

      2. In the mcp-server-fetch source, find the fetch tool's url parameter and change:

        url: Annotated[AnyUrl, Field(description="URL to fetch")]

        to:

        url: Annotated[str, Field(description="URL to fetch")]

      3. 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.

      4. 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?
    • AgentArmorHQ teamTeam3d ago

      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 with https://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?

    Add your answer or comment