@@ -44,7 +44,7 @@ def extract_content_from_html(html: str) -> str:
44
44
return content
45
45
46
46
47
- def get_robots_txt_url (url : AnyUrl | str ) -> str :
47
+ def get_robots_txt_url (url : str ) -> str :
48
48
"""Get the robots.txt URL for a given website URL.
49
49
50
50
Args:
@@ -54,15 +54,15 @@ def get_robots_txt_url(url: AnyUrl | str) -> str:
54
54
URL of the robots.txt file
55
55
"""
56
56
# Parse the URL into components
57
- parsed = urlparse (str ( url ) )
57
+ parsed = urlparse (url )
58
58
59
59
# Reconstruct the base URL with just scheme, netloc, and /robots.txt path
60
60
robots_url = urlunparse ((parsed .scheme , parsed .netloc , "/robots.txt" , "" , "" , "" ))
61
61
62
62
return robots_url
63
63
64
64
65
- async def check_may_autonomously_fetch_url (url : AnyUrl | str , user_agent : str ) -> None :
65
+ async def check_may_autonomously_fetch_url (url : str , user_agent : str ) -> None :
66
66
"""
67
67
Check if the URL can be fetched by the user agent according to the robots.txt file.
68
68
Raises a McpError if not.
@@ -106,7 +106,7 @@ async def check_may_autonomously_fetch_url(url: AnyUrl | str, user_agent: str) -
106
106
107
107
108
108
async def fetch_url (
109
- url : AnyUrl | str , user_agent : str , force_raw : bool = False
109
+ url : str , user_agent : str , force_raw : bool = False
110
110
) -> Tuple [str , str ]:
111
111
"""
112
112
Fetch the URL and return the content in a form ready for the LLM, as well as a prefix string with status information.
@@ -116,7 +116,7 @@ async def fetch_url(
116
116
async with AsyncClient () as client :
117
117
try :
118
118
response = await client .get (
119
- str ( url ) ,
119
+ url ,
120
120
follow_redirects = True ,
121
121
headers = {"User-Agent" : user_agent },
122
122
timeout = 30 ,
@@ -221,7 +221,7 @@ async def call_tool(name, arguments: dict) -> list[TextContent]:
221
221
except ValueError as e :
222
222
raise McpError (INVALID_PARAMS , str (e ))
223
223
224
- url = args .url
224
+ url = str ( args .url )
225
225
if not url :
226
226
raise McpError (INVALID_PARAMS , "URL is required" )
227
227
0 commit comments