Repository navigation
agentHost: show MCP server traffic in agent host output channels - #348947
Conversation
Adds per-server MCP diagnostic logs for agent host sessions. The Copilot provider captures MCP traffic with the Copilot SDK session diagnostics API. VS Code shows the traffic in the existing per-server output channel. The protocol schema does not change. - Advertise a per-server log channel template in `_meta['vscode.agentHost/mcpServerLogs']` on MCP server customizations. The session and server name segments use base64url, so that client URI normalization does not change them. - Route subscriptions for these channels through the protocol server, the agent service and the Copilot provider. Records go only to the subscribed client, with `otlp/exportLogs`. They do not go to the host log, the host OTLP log stream, telemetry or OTel exporters. - In the Copilot provider, set the SDK capture level to the most verbose of the host log level (Debug or Trace) and the active subscriptions. Each subscriber reads the retained history with its own cursor, and gets a warning when entries are dropped. - In the workbench, subscribe a server's output channel when its log level is Debug or Trace, or when the user reveals the channel. Follow the channel log level and the connection state. - Pass the agent host connection to the Agents window customization service, so that its MCP output channels can subscribe. - Make the remote agent host log forwarder accept only batches for the channel it subscribed to. - Make observable debug logging tolerate values that throw when they are read, such as cross-origin windows. Before, this prevented MCP Apps from rendering when `VSCODE_DEV_DEBUG_OBSERVABLES` was set. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Sandeep Somavarapu (@sandy081)Matched files:
Ladislau Szomoru (@lszomoru)Matched files:
|
Main now declares the same getter on EditorRemoteAgentHostServiceClient. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Base:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved diagnostics defects can stop MCP log delivery after duplicate-entry removal or transient refreshes, miss cold-resume startup output, and misrepresent replayed event times.
4 open issues
What changed in this PR
Adds per-server MCP diagnostics to existing Agent Host output channels without changing the protocol schema. Traffic is captured through the Copilot SDK and delivered only to subscribed clients, separately from host logs and telemetry.
Changes:
- Advertises diagnostic channels and routes subscriptions through the protocol, provider, and client layers.
- Connects output visibility, log levels, and connection state to diagnostic capture and subscriptions.
- Adds regression tests, documents logging boundaries, and makes observable debug formatting tolerate inaccessible objects.
| File | Description |
|---|---|
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts |
Exposes diagnostic subscriptions and connection state. |
src/vs/workbench/contrib/sessions/test/browser/agentHostCustomizationService.test.ts |
Tests provider-connection subscriptions. |
src/vs/workbench/contrib/sessions/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Exposes the current provider connection. |
src/vs/workbench/contrib/sessions/common/agentHostSessionsProvider.ts |
Adds optional connection access. |
src/vs/workbench/contrib/sessions/browser/agentHostCustomizationService.ts |
Passes the connection to customization targets. |
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/remoteAgentHostLogForwarder.test.ts |
Tests channel filtering and reconnect behavior. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostCustomizationService.test.ts |
Tests diagnostic routing, levels, and teardown. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts |
Updates the mock unsubscribe override. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostLogForwarder.ts |
Filters batches to the subscribed host channel. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts |
Manages per-server output subscriptions and records. |
src/vs/platform/agentHost/test/node/testAgentHostProviderService.ts |
Adds a diagnostic subscription stub. |
src/vs/platform/agentHost/test/node/shared/mcpCustomizationController.test.ts |
Tests diagnostic metadata advertisement. |
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts |
Tests subscriber isolation and subscription restoration. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests capture thresholds, formatting, and history replay. |
src/vs/platform/agentHost/test/electron-browser/localAgentHostService.test.ts |
Tests forwarding and disposal of log events. |
src/vs/platform/agentHost/OTEL.md |
Documents diagnostic capture and delivery boundaries. |
src/vs/platform/agentHost/node/shared/mcpCustomizationController.ts |
Advertises optional per-server log channels. |
src/vs/platform/agentHost/node/protocolServerHandler.ts |
Routes and authorizes diagnostic subscriptions. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Enables eager capture when creating SDK sessions. |
src/vs/platform/agentHost/node/copilot/copilotMcpServerLogs.ts |
Implements capture levels, independent readers, and formatting. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Connects diagnostic capture to SDK session lifecycle. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Routes subscriptions to live sessions and publishes metadata. |
src/vs/platform/agentHost/node/agentService.ts |
Delegates diagnostic subscriptions to providers. |
src/vs/platform/agentHost/node/agentHostProviderService.ts |
Routes subscriptions to the owning provider. |
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts |
Relays diagnostic events and subscription calls. |
src/vs/platform/agentHost/common/otlp/mcpServerLogsChannel.ts |
Defines channel encoding, parsing, and metadata reading. |
src/vs/platform/agentHost/common/agentService.ts |
Extends service and connection diagnostic contracts. |
src/vs/platform/agentHost/common/agent.ts |
Adds optional provider diagnostic subscriptions. |
src/vs/base/test/common/observables/debug.test.ts |
Tests formatting of inaccessible objects. |
src/vs/base/common/observableInternal/logging/consoleObservableLogger.ts |
Handles objects that throw during debug formatting. |
Review effort: Balanced
The Copilot provider now advertises the MCP server logs channel in the MCP server customization metadata. Update the full customization assertions to include it. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
- Capture MCP diagnostics at the eager level when the Copilot provider resumes a session, not only when it creates one. - Keep MCP server log entries while a customization container is loading or has not published its children, so that a revealed channel keeps its subscription. - Share log channel subscriptions between entries for the same server, so that removing one entry does not unsubscribe the other. - Show the original time of replayed diagnostic records. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No demo for |

Adds per-server MCP diagnostic logs for agent host sessions. The Copilot provider captures MCP
traffic with the Copilot SDK session diagnostics API. VS Code shows the traffic in the existing
per-server output channel. The protocol schema does not change.
_meta['vscode.agentHost/mcpServerLogs']on MCPserver customizations. The session and server name segments use base64url, so that client URI
normalization does not change them.
Copilot provider. Records go only to the subscribed client, with
otlp/exportLogs. They do notgo to the host log, the host OTLP log stream, telemetry or OTel exporters.
(Debug or Trace) and the active subscriptions. Each subscriber reads the retained history with
its own cursor, and gets a warning when entries are dropped.
when the user reveals the channel. Follow the channel log level and the connection state.
output channels can subscribe.
cross-origin windows. Before, this prevented MCP Apps from rendering when
VSCODE_DEV_DEBUG_OBSERVABLESwas set.(Commit message generated by Copilot)
How to test