Skip to content

Conversation

@dileepyavan
Copy link
Member

@dileepyavan dileepyavan commented Nov 10, 2025

fixes #259253

Screen.Recording.2025-11-10.123107.mp4

Copilot AI review requested due to automatic review settings November 10, 2025 19:43
Copy link
Contributor

Copilot AI left a 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 ValidateHttpResources function to validate HTTP/HTTPS resource requests against MCP server configurations
  • Modifies McpResourceFilesystem to 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';
Copy link

Copilot AI Nov 10, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines 99 to 115
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;
Copy link

Copilot AI Nov 10, 2025

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
Comment on lines 295 to 300
contents: result.map(r => {
if (r.status === 'ok') {
return { uri: resourceURI.toString(), text: r.result };
} else {
return { uri: resourceURI.toString(), text: '' };
}
Copy link

Copilot AI Nov 10, 2025

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.

Copilot uses AI. Check for mistakes.
@dileepyavan dileepyavan marked this pull request as ready for review November 10, 2025 20:16
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 10, 2025
@dileepyavan dileepyavan force-pushed the DileepY/MCP_httpResources branch from b8901da to d83fbb2 Compare November 10, 2025 21:38
@dileepyavan dileepyavan force-pushed the DileepY/MCP_httpResources branch from d83fbb2 to d3eec1a Compare November 10, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for MCP resources with https:// scheme

4 participants