ComposioHQ/composio · error · ResponseTooLargeError
File size ({content_length} bytes) exceeds maximum allowed s
Error message
File size ({content_length} bytes) exceeds maximum allowed size ({max_size} bytes) What it means
MCPServer.create wraps any unexpected exception from the underlying MCP server creation API call into a generic ValidationError('Failed to create MCP server'). The original cause is chained via `from e`, so inspect __cause__ to find the real problem (auth, network, invalid toolkit slug, backend error).
Source
Thrown at python/composio/core/models/_files.py:444
f"Please provide a direct URL to the file."
)
# Check for successful response
if not response.ok:
response.close()
raise ErrorUploadingFile(
f"Failed to fetch file from URL: {_sanitize_url_for_logging(url)}. "
f"Status: {response.status_code}"
)
# Check Content-Length header first (early abort for oversized files).
# The header is a hint from the remote server: `parse_content_length`
# returns None for anything untrustworthy, and the streaming guard below
# is the authoritative limit.
content_length = parse_content_length(response.headers.get("Content-Length"))
if content_length is not None and content_length > max_size:
response.close()
raise ResponseTooLargeError(
f"File size ({content_length} bytes) exceeds maximum allowed "
f"size ({max_size} bytes)"
)
# Stream response with size tracking
chunks: t.List[bytes] = []
total_bytes = 0
chunk_size = 8192 # 8 KB chunks
try:
for chunk in response.iter_content(chunk_size=chunk_size):
if chunk:
total_bytes += len(chunk)
if total_bytes > max_size:
response.close()
raise ResponseTooLargeError(
f"Response size exceeds maximum allowed size ({max_size} bytes)"
)View on GitHub (pinned to 64b1b85502)
Solutions
- Inspect exc.__cause__ (or the full traceback) to identify the underlying error
- Verify COMPOSIO_API_KEY is set and valid
- Confirm each toolkit slug/config is correct and supported for MCP servers
- Retry after transient network/backend failures; check Composio status if it persists
Example fix
# before
mcp = server.create(toolkits=['github'])
# after
try:
mcp = server.create(toolkits=['github'])
except ValidationError as e:
cause = e.__cause__ or e
print(f'MCP create failed: {cause}')
raise Defensive patterns
Strategy: try-catch
Validate before calling
from composio import Composio client = Composio() # raises early if COMPOSIO_API_KEY missing/invalid valid = ['github', 'slack'] # confirm slugs exist before calling mcp = server.create(toolkits=valid)
Type guard
def is_supported_toolkit(slug: str, client) -> bool:
return any(tk.slug == slug or tk.name == slug for tk in client.tools.get_list()) Try / catch
from composio.core.errors import ValidationError
import time
for attempt in range(3):
try:
mcp = server.create(toolkits=['github'])
break
except ValidationError as e:
cause = str(e.__cause__ or e)
if attempt < 2 and ('timeout' in cause.lower() or 'connection' in cause.lower()):
time.sleep(2 ** attempt)
continue
raise RuntimeError(f'MCP server creation failed: {cause}') from e Prevention
- Always inspect __cause__ on this wrapped error before debugging blindly
- Validate API key and toolkit slugs up front
- Retry transient network/backend causes with backoff
When it happens
Trigger: Any exception raised inside MCPServer.create's try block: invalid API key, unknown toolkit slug, network failure to the Composio backend, malformed MCPToolkitConfig, or a 4xx/5xx response during server creation.
Common situations: Expired or missing COMPOSIO_API_KEY; typo'd toolkit string; transient backend outage; passing config fields the backend rejects.
Related errors
- Failed to fetch file from URL: {_sanitize_url_for_logging(ur
- Failed to list MCP servers
- Failed to retrieve MCP server {server_id}
- Failed to update MCP server {server_id}
- Failed to delete MCP server {server_id}
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/35ed2a53c9440e67.
Report an issue: GitHub.