feat: enable MCP sampling support - #380
Open
im-ashu wants to merge 2 commits into
Open
Conversation
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>
im-ashu
requested review from
duzitong,
ethanyhou,
jdneo and
xinyi-gong
as code owners
July 30, 2026 05:36
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
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
force-pushed
the
feat/enable-mcp-sampling-support
branch
from
July 31, 2026 09:27
57ee711 to
37d5e9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advertise MCP sampling, handle sampling configuration requests, and add a CLI-style inference approval dialog with prompt review and persistent server approval.