-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Enable support for Http based MCP resources #276580
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables support for HTTP-based MCP (Model Context Protocol) resources by adding validation and web content extraction capabilities. The changes allow VS Code to fetch and display HTTP/HTTPS resources from MCP servers through the web content extractor service.
Key Changes
- Adds
ValidateHttpResourcesfunction to validate HTTP/HTTPS resource requests against MCP server configurations - Modifies
McpResourceFilesystemto use web content extraction for HTTP-based resources instead of MCP server calls - Updates directory detection logic to use path-based checking instead of content-based checking
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/mcp/common/mcpTypesUtils.ts |
Adds new ValidateHttpResources function to validate HTTP resource URIs against MCP server transport type and authority |
src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.ts |
Implements HTTP resource extraction via IWebContentExtractorService, updates directory detection logic, and adds helper function for path checking |
src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.ts |
Adds trailing newline (whitespace-only change) |
src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts |
Changes attachment handling to return early instead of adding context (unrelated to MCP HTTP resources) |
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { Uri } from 'vscode'; |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect import: should use URI from '../../../../base/common/uri.js' instead of Uri from 'vscode'. The VS Code extension API (vscode) should not be imported in workbench code. All other files in the mcp module use URI from base/common/uri.js.
| let isResourceRequestValid = false; | ||
| if (resource.path.indexOf('/http/') === 0) { | ||
| const launch = server?.connection.get()?.launchDefinition; | ||
| if (launch && launch.type === McpServerTransportType.HTTP && launch.uri.authority.toLowerCase() === resource.authority.toLowerCase()) { | ||
| isResourceRequestValid = true; | ||
| } | ||
| } else if (resource.path.indexOf('/https/') === 0) { | ||
| isResourceRequestValid = true; | ||
| } | ||
| return isResourceRequestValid; |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable isResourceRequestValid can be simplified. Instead of initializing to false and conditionally setting to true, consider using a direct return statement. This reduces unnecessary state and improves readability.
| let isResourceRequestValid = false; | |
| if (resource.path.indexOf('/http/') === 0) { | |
| const launch = server?.connection.get()?.launchDefinition; | |
| if (launch && launch.type === McpServerTransportType.HTTP && launch.uri.authority.toLowerCase() === resource.authority.toLowerCase()) { | |
| isResourceRequestValid = true; | |
| } | |
| } else if (resource.path.indexOf('/https/') === 0) { | |
| isResourceRequestValid = true; | |
| } | |
| return isResourceRequestValid; | |
| if (resource.path.indexOf('/http/') === 0) { | |
| const launch = server?.connection.get()?.launchDefinition; | |
| return !!(launch && launch.type === McpServerTransportType.HTTP && launch.uri.authority.toLowerCase() === resource.authority.toLowerCase()); | |
| } else if (resource.path.indexOf('/https/') === 0) { | |
| return true; | |
| } | |
| return false; |
| contents: result.map(r => { | ||
| if (r.status === 'ok') { | ||
| return { uri: resourceURI.toString(), text: r.result }; | ||
| } else { | ||
| return { uri: resourceURI.toString(), text: '' }; | ||
| } |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug: when web content extraction returns errors or redirects, the code creates empty text content (text: ''). This masks extraction failures from the caller. Consider propagating errors appropriately or handling non-ok results differently - for example, checking if all results failed and throwing an appropriate error.
b8901da to
d83fbb2
Compare
d83fbb2 to
d3eec1a
Compare
fixes #259253
Screen.Recording.2025-11-10.123107.mp4