servers icon indicating copy to clipboard operation
servers copied to clipboard

fetch fails without optional settings

Open jhmonroe opened this issue 8 months ago • 2 comments

Describe the bug The docs clearly say:

fetch - Fetches a URL from the internet and extracts its contents as markdown. url (string, required): URL to fetch max_length (integer, optional): Maximum number of characters to return (default: 5000) start_index (integer, optional): Start content from this character index (default: 0) raw (boolean, optional): Get raw content without markdown conversion (default: false)

To Reproduce Steps to reproduce the behavior:

  1. When I run fetch in LibreChat (Docker) + MCP/Fetch (Docker), I receive the attached errors

Expected behavior It should disregard optional settings

Image

another try:

Image

jhmonroe avatar Jun 06 '25 20:06 jhmonroe

@claude it looks like the fetch server fails when null is passed to the start_index and max_length arguments. These should be optional parameters. Is this behavior expected?

olaservo avatar Aug 27 '25 12:08 olaservo

Claude finished @olaservo's task —— View jobclaude/issue-2035-20250827-1223Create PR ➔


Issue Analysis & Fix

The behavior you observed is not expected. The fetch server was incorrectly failing when null values were passed for optional parameters.

Root Cause & Solution

Problem: The Pydantic model defined optional parameters as int and bool types with default values, but didn't handle explicit null values from clients like LibreChat. When null was passed, Pydantic tried to validate null as an integer or boolean, causing validation failures.

Fix: Updated the parameter types to Optional[int] and Optional[bool] and added proper null-coalescing logic to use default values when None is received.

Changes made in src/fetch/src/mcp_server_fetch/server.py:

  • Added Optional import from typing
  • Changed max_length: intmax_length: Optional[int]
  • Changed start_index: intstart_index: Optional[int]
  • Changed raw: boolraw: Optional[bool]
  • Added null-safe handling: args.max_length or 5000, args.start_index or 0, args.raw or False

Todo List

  • [x] Examine repository structure and locate fetch server code
  • [x] Check for CLAUDE.md repository guidelines
  • [x] Analyze the fetch server's parameter validation logic
  • [x] Determine if null handling for optional parameters is correct
  • [x] Implement fix for null parameter handling
  • [x] Test the changes

Status: Fixed! The fetch server now properly handles null values for optional parameters by using their documented default values (max_length: 5000, start_index: 0, raw: false).

claude[bot] avatar Aug 27 '25 12:08 claude[bot]