Skip to content

feat: enable MCP sampling support - #380

Open
im-ashu wants to merge 2 commits into
microsoft:mainfrom
im-ashu:feat/enable-mcp-sampling-support
Open

feat: enable MCP sampling support#380
im-ashu wants to merge 2 commits into
microsoft:mainfrom
im-ashu:feat/enable-mcp-sampling-support

Conversation

@im-ashu

@im-ashu im-ashu commented Jul 30, 2026

Copy link
Copy Markdown

Advertise MCP sampling, handle sampling configuration requests, and add a CLI-style inference approval dialog with prompt review and persistent server approval.

Advertise MCP sampling, handle sampling configuration requests, and add a CLI-style inference approval dialog with prompt review and persistent server approval.

Signed-off-by: Ashu Bansal <ashubansal79@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 05:36
@im-ashu

im-ashu commented Jul 30, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MCP “sampling” (inference) support to the Eclipse client by advertising the capability to the language server, introducing an inference-approval confirmation UX (including prompt review), and adding protocol/types + request handler scaffolding for sampling configuration.

Changes:

  • Advertise MCP sampling support via CopilotCapabilities.
  • Add a dedicated sampling/inference confirmation flow with “Review Prompt” UI action and persistent per-server approval option.
  • Introduce protocol records for sampling config and a client request handler for copilot/readMcpSamplingConfig, plus unit tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/messages.properties Adds i18n strings for sampling/inference approval dialog actions and messaging.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/Messages.java Exposes new sampling-related message keys via NLS.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/InvokeToolConfirmationDialog.java Renders sampling prompt text and adds a “Review Prompt” button to toggle visibility.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/McpConfirmationHandler.java Detects sampling requests and builds a dedicated confirmation content/actions set.
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/McpConfirmationHandlerTests.java Adds coverage validating sampling confirmation actions and persistent-action gating.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/ReadMcpSamplingConfigParams.java Adds protocol params record for sampling-config reads.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/McpSamplingConfig.java Adds protocol record representing sampling preferences returned to the server.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotCapabilities.java Advertises the new mcpSampling capability.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageClient.java Adds JSON-RPC handler for copilot/readMcpSamplingConfig (currently default response).
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationAction.java Introduces UI-only confirmation actions via metadata (reviewPrompt).
com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/lsp/LsStreamConnectionProviderTests.java Asserts mcpSampling capability is enabled in initialization options.
com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageClientTests.java Adds a test for readMcpSamplingConfig response shape/content.

}
});

if (reviewAction != null) {
Comment on lines +160 to +164
// 6. Needs confirmation
if (isSamplingRequest(params)) {
return ConfirmationResult.needsConfirmation(
buildSamplingContent(serverName, false));
}
Comment on lines +186 to +193
/**
* Read the sampling preferences for an MCP server.
*/
@JsonRequest("copilot/readMcpSamplingConfig")
public CompletableFuture<Object[]> readMcpSamplingConfig(ReadMcpSamplingConfigParams params) {
McpSamplingConfig config = new McpSamplingConfig(false, false, List.of());
return CompletableFuture.completedFuture(new Object[] { config, null });
}
… from tool approval

- CopilotLanguageClient.readMcpSamplingConfig now delegates to a new
  McpSamplingConfigProvider (registered by AgentToolService) instead of
  always returning a hardcoded no-preference stub, so a user's 'don't ask
  again' decision for MCP sampling is actually reflected back to CLS.
- McpConfirmationHandler now evaluates sampling requests against their own
  dedicated approval list (AUTO_APPROVE_MCP_SAMPLING_SERVERS /
  ACCEPT_SAMPLING_SERVER_GLOBAL action) instead of reusing the regular MCP
  tool auto-approve list. Previously, approving 'always allow tools from
  server X' would silently also auto-approve future sampling/inference
  requests from that server (and vice versa), bypassing the sampling
  consent dialog that discloses billing implications.
- Minor: documented the always-true mcpSampling capability flag, and
  replaced a layout(true, true) call with requestLayout() in
  InvokeToolConfirmationDialog per project convention.
- Added/updated unit tests covering the new isolation behavior and the
  readMcpSamplingConfig delegation.
@im-ashu
im-ashu force-pushed the feat/enable-mcp-sampling-support branch from 57ee711 to 37d5e9f Compare July 31, 2026 09:27
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.

2 participants