-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Fix fetch tool to only handle HTTP/HTTPS schemes for MCP resources #252683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This prevents MCP resource URIs (like test://static/resource/50) from being incorrectly processed by the fetch tool. MCP resources should be handled by VS Code's filesystem providers instead. - Modified FetchWebPageTool._parseUris() to filter out non-HTTP(S) schemes - Added comprehensive tests for the new scheme filtering behavior - Non-HTTP(S) URIs will now be treated as invalid and skipped Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
I'd rather the tests implemented a TestWebContentExtractorService which can be constructed with a map of like "Uris to fake page contents" and then have tests that test the actual API not private methods |
…ng private methods Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
I've refactored the tests to use a TestWebContentExtractorService that implements IWebContentExtractorService with configurable URI-to-content mapping. The tests now validate the public API behavior (via the Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
I think what would be nice here is actually to just serve the file data if it's something the IFileService can resolve. Sure it might not be 'correct' use of the fetch tool, but that would make usages of it not break :) |
…P schemes Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
I've implemented your suggestion to serve file data via IFileService for non-HTTP/HTTPS schemes. The fetch tool now:
This makes MCP resources work seamlessly - instead of rejecting Commit: 2df3c81 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
I like the strategy of:
However, let's not change the description of the tool as I don't want this fall back to be used too heavily over other read tools. And remember order matters in what you return back so maintain the same order in the response. |
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
I've reverted the tool description back to the original text that only mentions web pages, while keeping the file service fallback functionality intact. The tool maintains proper URL order in responses as requested. Commit: 9c36f75 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Can you use this FileService implementation as the implementation on the web? Right now that's using the Null one |
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
I've implemented a FileService-based WebContentExtractorService for the web platform. The web workbench now uses |
The fetch web page tool was incorrectly attempting to process MCP resource URIs (like
test://static/resource/50
), which would fail because these non-HTTP schemes cannot be loaded in Electron's BrowserWindow.Problem
When users tried to fetch MCP resource content, the fetch tool would:
FetchWebPageTool._parseUris()
NativeWebContentExtractorService.extract()
win.loadURL()
This resulted in the error shown in the issue where the tool couldn't retrieve MCP resource content.
Solution
Modified
FetchWebPageTool._parseUris()
to only accept HTTP and HTTPS schemes:Changes
FetchWebPageTool._parseUris()
to filter out non-HTTP(S) schemesfetchPageTool.test.ts
User Experience
test://static/resource/50
would cause errors or unexpected behaviorBenefits
Fixes #250495.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
electronjs.org
node-gyp
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.