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
{{ message }}
Repository navigation
Commit 315ad50
Browse filesBrowse the repository at this point in the historyBrowse files
fetch followed redirects with no egress check, so a model-supplied URL, or
any redirect hop from a public one, could reach loopback, RFC 1918,
link-local and cloud metadata addresses from the host running the server.
An httpx request hook now resolves each request's host and refuses it when
any address is not globally routable. httpx runs request hooks before every
request it sends, so the robots.txt fetch, the page fetch and every redirect
hop are all checked. --allow-private-ips turns the guard off for local
development; the README documents it next to the existing CAUTION.
The KNOWN BUG modelcontextprotocol#4838 pinning test now asserts the redirect is refused, and the
test harness gains a fake DNS so no test resolves a real name.
Ported from modelcontextprotocol#4890 by Mustafa Kemal Çıngıl, adapted: a CLI flag in place of
the FETCH_ALLOW_PRIVATE_IPS environment variable, is_global in place of an
explicit range list (which also covers 100.64.0.0/10), a non-blocking
resolver, and one hook in place of a separate pre-check.
Co-authored-by: Mustafa Kemal Çıngıl <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
Copy file name to clipboardExpand all lines: src/fetch/README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ Requires MCP Python SDK 1.x (`mcp>=1.29.0,<2`). SDK 2.0 renamed APIs this server
10
10
11
11
> [!CAUTION]
12
12
> This server can access local/internal IP addresses and may represent a security risk. Exercise caution when using this MCP server to ensure this does not expose any sensitive data.
13
+
>
14
+
> By default the server refuses to fetch private, loopback, link-local and other non-public addresses, including cloud metadata endpoints such as `169.254.169.254`, and checks every redirect hop the same way. The `--allow-private-ips` argument turns this guard off; see [Customization - Private addresses](#customization---private-addresses). The guard checks the addresses a hostname resolves to before each request, so it does not protect against DNS rebinding between that check and the connection, and a hostname the server cannot resolve itself (one only a proxy can resolve) is not checked.
13
15
14
16
The fetch tool will truncate the response, but by using the `start_index` argument, you can specify where to start the content extraction. This lets models read a webpage in chunks, until they find the information they need.
15
17
@@ -156,6 +158,17 @@ By default, the server will obey a websites robots.txt file if the request came
156
158
the request was user initiated (via a prompt). This can be disabled by adding the argument `--ignore-robots-txt` to the
157
159
`args` list in the configuration.
158
160
161
+
### Customization - Private addresses
162
+
163
+
By default, the server refuses any request, including a redirect hop or a robots.txt fetch, whose host resolves to an
164
+
address that is not globally routable: loopback (`127.0.0.0/8`, `::1`), private (`10.0.0.0/8`, `172.16.0.0/12`,
165
+
`192.168.0.0/16`, `fc00::/7`), link-local (`169.254.0.0/16`, `fe80::/10`), shared address space (`100.64.0.0/10`),
166
+
multicast, unspecified and reserved ranges. A hostname is refused if any one of its addresses is in those ranges.
167
+
The client receives an error naming the refused address.
168
+
169
+
To fetch from local or internal hosts (a development server, an intranet page), add the argument
170
+
`--allow-private-ips` to the `args` list in the configuration.
171
+
159
172
### Customization - User-agent
160
173
161
174
By default, depending on if the request came from the model (via a tool), or was user initiated (via a prompt), the
0 commit comments