fetch fails without optional settings
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:
- When I run fetch in LibreChat (Docker) + MCP/Fetch (Docker), I receive the attached errors
Expected behavior It should disregard optional settings
another try:
@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?
Claude finished @olaservo's task —— View job • claude/issue-2035-20250827-1223 • Create 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
Optionalimport from typing - Changed
max_length: int→max_length: Optional[int] - Changed
start_index: int→start_index: Optional[int] - Changed
raw: bool→raw: 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).