🐛 Bug Fix Release
This release fixes a critical bug in the MCP resource handler that affected users calling fetch_mcp_resource with URI parameters.
Fixed
MCP Resource Handler AttributeError (Issue #254)
- Fixed
AttributeError: 'AnyUrl' object has no attribute 'startswith'inhandle_read_resourcefunction - Added automatic URI string conversion at function start to handle both plain strings and Pydantic AnyUrl objects
- MCP SDK may pass AnyUrl objects instead of strings, causing AttributeError when using
.startswith()method - Fix converts AnyUrl to string using
str()before processing, maintaining backward compatibility
Technical Details
The MCP SDK sometimes passes Pydantic AnyUrl objects instead of plain strings when deserializing tool call arguments. This caused failures when the code tried to use string methods like .startswith() or perform equality comparisons.
Fix Implementation:
# Convert AnyUrl to string if necessary (fix for issue #254)
# MCP SDK may pass Pydantic AnyUrl objects instead of plain strings
if hasattr(uri, '__str__'):
uri = str(uri)This ensures compatibility with both input types while maintaining backward compatibility with existing code.
Impact
- ✅ Users can now use
fetch_mcp_resourcewithout errors - ✅ Works with both string and AnyUrl URI parameters
- ✅ No breaking changes - fully backward compatible
- ✅ Fixes reported issue #254
Installation
# Update to v8.42.1
pip install --upgrade mcp-memory-service
# Or with uv
uv pip install --upgrade mcp-memory-service
# Verify version
python -c "import mcp_memory_service; print(mcp_memory_service.__version__)"Related Links
- Issue: #254
- Pull Request: #255
- Changelog: https://github.com/doobidoo/mcp-memory-service/blob/main/CHANGELOG.md#8421---2025-11-29
🙏 Thanks to @bivex for reporting this issue with detailed reproduction steps and proposed solution.