mcp-server-fetch 2025.1.17__py3-none-any.whl → 2025.4.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_server_fetch/__init__.py +2 -1
- mcp_server_fetch/server.py +12 -9
- {mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/METADATA +6 -1
- mcp_server_fetch-2025.4.7.dist-info/RECORD +8 -0
- mcp_server_fetch-2025.1.17.dist-info/RECORD +0 -8
- {mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/WHEEL +0 -0
- {mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/entry_points.txt +0 -0
- {mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/licenses/LICENSE +0 -0
mcp_server_fetch/__init__.py
CHANGED
@@ -15,9 +15,10 @@ def main():
|
|
15
15
|
action="store_true",
|
16
16
|
help="Ignore robots.txt restrictions",
|
17
17
|
)
|
18
|
+
parser.add_argument("--proxy-url", type=str, help="Proxy URL to use for requests")
|
18
19
|
|
19
20
|
args = parser.parse_args()
|
20
|
-
asyncio.run(serve(args.user_agent, args.ignore_robots_txt))
|
21
|
+
asyncio.run(serve(args.user_agent, args.ignore_robots_txt, args.proxy_url))
|
21
22
|
|
22
23
|
|
23
24
|
if __name__ == "__main__":
|
mcp_server_fetch/server.py
CHANGED
@@ -63,7 +63,7 @@ def get_robots_txt_url(url: str) -> str:
|
|
63
63
|
return robots_url
|
64
64
|
|
65
65
|
|
66
|
-
async def check_may_autonomously_fetch_url(url: str, user_agent: str) -> None:
|
66
|
+
async def check_may_autonomously_fetch_url(url: str, user_agent: str, proxy_url: str | None = None) -> None:
|
67
67
|
"""
|
68
68
|
Check if the URL can be fetched by the user agent according to the robots.txt file.
|
69
69
|
Raises a McpError if not.
|
@@ -72,7 +72,7 @@ async def check_may_autonomously_fetch_url(url: str, user_agent: str) -> None:
|
|
72
72
|
|
73
73
|
robot_txt_url = get_robots_txt_url(url)
|
74
74
|
|
75
|
-
async with AsyncClient() as client:
|
75
|
+
async with AsyncClient(proxies=proxy_url) as client:
|
76
76
|
try:
|
77
77
|
response = await client.get(
|
78
78
|
robot_txt_url,
|
@@ -109,14 +109,14 @@ async def check_may_autonomously_fetch_url(url: str, user_agent: str) -> None:
|
|
109
109
|
|
110
110
|
|
111
111
|
async def fetch_url(
|
112
|
-
url: str, user_agent: str, force_raw: bool = False
|
112
|
+
url: str, user_agent: str, force_raw: bool = False, proxy_url: str | None = None
|
113
113
|
) -> Tuple[str, str]:
|
114
114
|
"""
|
115
115
|
Fetch the URL and return the content in a form ready for the LLM, as well as a prefix string with status information.
|
116
116
|
"""
|
117
117
|
from httpx import AsyncClient, HTTPError
|
118
118
|
|
119
|
-
async with AsyncClient() as client:
|
119
|
+
async with AsyncClient(proxies=proxy_url) as client:
|
120
120
|
try:
|
121
121
|
response = await client.get(
|
122
122
|
url,
|
@@ -173,19 +173,22 @@ class Fetch(BaseModel):
|
|
173
173
|
bool,
|
174
174
|
Field(
|
175
175
|
default=False,
|
176
|
-
description="Get the actual HTML content
|
176
|
+
description="Get the actual HTML content of the requested page, without simplification.",
|
177
177
|
),
|
178
178
|
]
|
179
179
|
|
180
180
|
|
181
181
|
async def serve(
|
182
|
-
custom_user_agent: str | None = None,
|
182
|
+
custom_user_agent: str | None = None,
|
183
|
+
ignore_robots_txt: bool = False,
|
184
|
+
proxy_url: str | None = None,
|
183
185
|
) -> None:
|
184
186
|
"""Run the fetch MCP server.
|
185
187
|
|
186
188
|
Args:
|
187
189
|
custom_user_agent: Optional custom User-Agent string to use for requests
|
188
190
|
ignore_robots_txt: Whether to ignore robots.txt restrictions
|
191
|
+
proxy_url: Optional proxy URL to use for requests
|
189
192
|
"""
|
190
193
|
server = Server("mcp-fetch")
|
191
194
|
user_agent_autonomous = custom_user_agent or DEFAULT_USER_AGENT_AUTONOMOUS
|
@@ -229,10 +232,10 @@ Although originally you did not have internet access, and were advised to refuse
|
|
229
232
|
raise McpError(ErrorData(code=INVALID_PARAMS, message="URL is required"))
|
230
233
|
|
231
234
|
if not ignore_robots_txt:
|
232
|
-
await check_may_autonomously_fetch_url(url, user_agent_autonomous)
|
235
|
+
await check_may_autonomously_fetch_url(url, user_agent_autonomous, proxy_url)
|
233
236
|
|
234
237
|
content, prefix = await fetch_url(
|
235
|
-
url, user_agent_autonomous, force_raw=args.raw
|
238
|
+
url, user_agent_autonomous, force_raw=args.raw, proxy_url=proxy_url
|
236
239
|
)
|
237
240
|
original_length = len(content)
|
238
241
|
if args.start_index >= original_length:
|
@@ -259,7 +262,7 @@ Although originally you did not have internet access, and were advised to refuse
|
|
259
262
|
url = arguments["url"]
|
260
263
|
|
261
264
|
try:
|
262
|
-
content, prefix = await fetch_url(url, user_agent_manual)
|
265
|
+
content, prefix = await fetch_url(url, user_agent_manual, proxy_url=proxy_url)
|
263
266
|
# TODO: after SDK bug is addressed, don't catch the exception
|
264
267
|
except McpError as e:
|
265
268
|
return GetPromptResult(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-server-fetch
|
3
|
-
Version: 2025.
|
3
|
+
Version: 2025.4.7
|
4
4
|
Summary: A Model Context Protocol server providing tools to fetch and convert web content for usage by LLMs
|
5
5
|
Author: Anthropic, PBC.
|
6
6
|
Maintainer-email: Jack Adamson <jadamson@anthropic.com>
|
@@ -13,6 +13,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
15
15
|
Requires-Python: >=3.10
|
16
|
+
Requires-Dist: httpx<0.28
|
16
17
|
Requires-Dist: markdownify>=0.13.1
|
17
18
|
Requires-Dist: mcp>=1.1.3
|
18
19
|
Requires-Dist: protego>=0.3.1
|
@@ -130,6 +131,10 @@ ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotoc
|
|
130
131
|
|
131
132
|
This can be customized by adding the argument `--user-agent=YourUserAgent` to the `args` list in the configuration.
|
132
133
|
|
134
|
+
### Customization - Proxy
|
135
|
+
|
136
|
+
The server can be configured to use a proxy by using the `--proxy-url` argument.
|
137
|
+
|
133
138
|
## Debugging
|
134
139
|
|
135
140
|
You can use the MCP inspector to debug the server. For uvx installations:
|
@@ -0,0 +1,8 @@
|
|
1
|
+
mcp_server_fetch/__init__.py,sha256=IXF5r1H974ZjlTlrkL3WiGq0cKSj5JlXZibIGQjU2E0,717
|
2
|
+
mcp_server_fetch/__main__.py,sha256=P5j_W1F3QvOrY7x2YIQ0KlY1Y9eO_vS6rrOo1mL1fvk,57
|
3
|
+
mcp_server_fetch/server.py,sha256=BaS0gTgeh8Ffvbegw9p-4_1132ZQelWojAxEh2pjmlQ,10646
|
4
|
+
mcp_server_fetch-2025.4.7.dist-info/METADATA,sha256=FkqwNKmC1bJ6G8sQO9dNScPtAqIkVndfbtc3qhACLcs,4979
|
5
|
+
mcp_server_fetch-2025.4.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
+
mcp_server_fetch-2025.4.7.dist-info/entry_points.txt,sha256=tYA4AQfADMVk6YWCfuPe7TjGGmPmk7gLosHt_ewL48c,59
|
7
|
+
mcp_server_fetch-2025.4.7.dist-info/licenses/LICENSE,sha256=jMfG4zsk7U7o_MzDPszxAlSdBPpMuXN87Ml3Da0QgP8,1059
|
8
|
+
mcp_server_fetch-2025.4.7.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
mcp_server_fetch/__init__.py,sha256=6mqCwMSe8NtUcwXsmZTGjln83bc1vE31CL5yInKZd0s,614
|
2
|
-
mcp_server_fetch/__main__.py,sha256=P5j_W1F3QvOrY7x2YIQ0KlY1Y9eO_vS6rrOo1mL1fvk,57
|
3
|
-
mcp_server_fetch/server.py,sha256=iiB6aXXG30bNdPZlngM5rj67Y4iaNxZ09o8fBgSm3sU,10402
|
4
|
-
mcp_server_fetch-2025.1.17.dist-info/METADATA,sha256=aPezgZZtmwNmeKV839Vk9XLHwalZbjLzzrGT2rlkB7g,4845
|
5
|
-
mcp_server_fetch-2025.1.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
mcp_server_fetch-2025.1.17.dist-info/entry_points.txt,sha256=tYA4AQfADMVk6YWCfuPe7TjGGmPmk7gLosHt_ewL48c,59
|
7
|
-
mcp_server_fetch-2025.1.17.dist-info/licenses/LICENSE,sha256=jMfG4zsk7U7o_MzDPszxAlSdBPpMuXN87Ml3Da0QgP8,1059
|
8
|
-
mcp_server_fetch-2025.1.17.dist-info/RECORD,,
|
File without changes
|
{mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/entry_points.txt
RENAMED
File without changes
|
{mcp_server_fetch-2025.1.17.dist-info → mcp_server_fetch-2025.4.7.dist-info}/licenses/LICENSE
RENAMED
File without changes
|