{"record":{"id":"98ce1d327c2d9572","repo":"modelcontextprotocol/servers","slug":"32602","errorCode":"-32602","errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"src/fetch/src/mcp_server_fetch/server.py","lineNumber":228,"sourceCode":"    async def list_prompts() -> list[Prompt]:\n        return [\n            Prompt(\n                name=\"fetch\",\n                description=\"Fetch a URL and extract its contents as markdown\",\n                arguments=[\n                    PromptArgument(\n                        name=\"url\", description=\"URL to fetch\", required=True\n                    )\n                ],\n            )\n        ]\n\n    @server.call_tool()\n    async def call_tool(name, arguments: dict) -> list[TextContent]:\n        try:\n            args = Fetch(**arguments)\n        except ValueError as e:\n            raise McpError(ErrorData(code=INVALID_PARAMS, message=str(e)))\n\n        url = str(args.url)\n        if not url:\n            raise McpError(ErrorData(code=INVALID_PARAMS, message=\"URL is required\"))\n\n        if not ignore_robots_txt:\n            await check_may_autonomously_fetch_url(url, user_agent_autonomous, proxy_url)\n\n        content, prefix = await fetch_url(\n            url, user_agent_autonomous, force_raw=args.raw, proxy_url=proxy_url\n        )\n        original_length = len(content)\n        if args.start_index >= original_length:\n            content = \"<error>No more content available.</error>\"\n        else:\n            truncated_content = content[args.start_index : args.start_index + args.max_length]\n            if not truncated_content:\n                content = \"<error>No more content available.</error>\"","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/fetch/src/mcp_server_fetch/server.py#L210-L246","documentation":"In call_tool(), the tool arguments are parsed into the pydantic Fetch model; a ValueError (pydantic ValidationError) is wrapped as McpError INVALID_PARAMS (-32602). Validation rules: url must be a valid AnyUrl; max_length must be > 0 and < 1_000_000; start_index must be >= 0; raw must be a bool.","triggerScenarios":"Omitting required url; url is not a valid absolute URL; max_length <= 0 or >= 1_000_000; start_index < 0; raw is not boolean; wrong argument types.","commonSituations":"Client or LLM hallucinating the schema; stale tool definition; relative instead of absolute URL.","solutions":["Validate arguments against Fetch.model_json_schema() before invoking the tool.","Ensure url is an absolute, well-formed URL (scheme + host).","Keep max_length strictly within (0, 1_000_000) and start_index >= 0."],"exampleFix":"# before\nawait call_tool('fetch', {'url': 'not a url', 'max_length': 0})  # ValidationError -> INVALID_PARAMS\n\n# after: build through the model first\nfrom mcp_server_fetch.server import Fetch\nargs = Fetch(url='https://example.com', max_length=5000, start_index=0, raw=False)\nawait call_tool('fetch', args.model_dump())","handlingStrategy":"validation","validationCode":"from mcp_server_fetch.server import Fetch\nfrom pydantic import ValidationError\ntry:\n    args = Fetch(**arguments)\nexcept ValidationError as e:\n    raise ValueError(str(e))  # or return a user-facing error\n# safe to call tool with args.model_dump()","typeGuard":null,"tryCatchPattern":"try:\n    args = Fetch(**arguments)\nexcept ValueError as e:\n    # map to a client-facing INVALID_PARAMS-style message\n    raise ValueError(f'Invalid fetch arguments: {e}')","preventionTips":["Build arguments via the Fetch model (model_dump) rather than hand-rolling a dict.","Validate against Fetch.model_json_schema() on the client side before invoking.","Keep max_length in (0, 1_000_000), start_index >= 0, url absolute."],"tags":["fetch","python","invalid-params","validation","pydantic"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}