Skip to content

agentHost: show MCP server traffic in agent host output channels - #348947

Merged
Connor Peet (connor4312) merged 5 commits into
mainfrom
connor4312/ahp-mcp-server-logs
Nov 17, 2026
Merged

Connor Peet (connor4312) merged 5 commits into
mainfrom
connor4312/ahp-mcp-server-logs

Conversation

@connor4312

Copy link
Copy Markdown
Member

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)

How to test

  1. Launch Code OSS with the log level at Debug or Trace, and open a Copilot agent host session that uses an MCP server.
  2. Open the server output channel (MCP server actions > Show Output). It shows the JSON-RPC frames, stderr and HTTP metadata in addition to the server status lines.
  3. At the Info log level, the channel subscribes only when you reveal it.

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>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 22:50
@vs-code-engineering

This comment has been minimized.

@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/workbench/contrib/sessions/browser/agentHostCustomizationService.ts
  • src/vs/workbench/contrib/sessions/common/agentHostSessionsProvider.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/workbench/contrib/sessions/browser/agentHostCustomizationService.ts
  • src/vs/workbench/contrib/sessions/common/agentHostSessionsProvider.ts

Main now declares the same getter on EditorRemoteAgentHostServiceClient.

(Commit message generated by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Base: e9b88f68 Current: a0d0bac3

No screenshot changes.

@vs-code-engineering

This comment has been minimized.

@vs-code-engineering

This comment has been minimized.

@vs-code-engineering vs-code-engineering Bot added the pr-demo A PR demo was recorded for this pull request label Nov 17, 2026

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.

🟡 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>
@vs-code-engineering

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>
@vs-code-engineering

vs-code-engineering Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

No demo for cb5754c. Requires Copilot SDK MCP diagnostics, unavailable through the fake Custom Endpoint model. Workflow run

@connor4312
Connor Peet (connor4312) added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 23159ab Nov 17, 2026
37 of 38 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/ahp-mcp-server-logs branch November 17, 2026 23:38
@vs-code-engineering vs-code-engineering Bot added this to the 1.148.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-demo A PR demo was recorded for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants