You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In src/mcp/server/lowlevel/server.py, binary data is encoded using base64.urlsafe_b64encode(), which replaces + with - and / with _ to make it URL-safe.
However, when the client tries to validate this data with BlobResourceContents, the validator expects standard base64 encoding (with + and /).
This causes validation failures with "Invalid base64" errors when processing larger binary files that contain these special characters.
Before Fix:
# Create server
server = FastMCP("Base64 Test")
# Add resource directly
binary_resource = FileResource(
uri=AnyUrl("resource://test/simple.bin"),
path=Path("sample.pdf").absolute(),
name="Test PDF",
mime_type="application/pdf",
)
server.add_resource(binary_resource)
if __name__ == "__main__":
server.run()
Use FastMCP to return a binary resource (e.g. a PDF file), and inspect the contents.
After Fix:
Expected behavior
That binary content is returned as correctly base64 content rather than an error message.
Additional context
PR incoming with automated test.
The text was updated successfully, but these errors were encountered:
Describe the bug
In src/mcp/server/lowlevel/server.py, binary data is encoded using base64.urlsafe_b64encode(), which replaces + with - and / with _ to make it URL-safe.
However, when the client tries to validate this data with BlobResourceContents, the validator expects standard base64 encoding (with + and /).
This causes validation failures with "Invalid base64" errors when processing larger binary files that contain these special characters.
Before Fix:
Use FastMCP to return a binary resource (e.g. a PDF file), and inspect the contents.
After Fix:
Expected behavior
That binary content is returned as correctly base64 content rather than an error message.
Additional context
PR incoming with automated test.
The text was updated successfully, but these errors were encountered: