Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fetch/src/mcp_server_fetch/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async def check_may_autonomously_fetch_url(url: str, user_agent: str, proxy_url:
robot_txt_url,
follow_redirects=True,
headers={"User-Agent": user_agent},
timeout=30,
)
except HTTPError:
raise McpError(ErrorData(
Expand All @@ -91,6 +92,11 @@ async def check_may_autonomously_fetch_url(url: str, user_agent: str, proxy_url:
))
elif 400 <= response.status_code < 500:
return
elif response.status_code >= 500:
raise McpError(ErrorData(
code=INTERNAL_ERROR,
message=f"Failed to fetch robots.txt {robot_txt_url} - server error (status {response.status_code})",
))
robot_txt = response.text
processed_robot_txt = "\n".join(
line for line in robot_txt.splitlines() if not line.strip().startswith("#")
Expand Down
Loading