Skip to content

feat(mcp): offer the deployment's MCP server to chat and the Agents window - #1214

Draft
EhabY wants to merge 1 commit into
feat/agents-window-supportfrom
feat/mcp-server
Draft

EhabY wants to merge 1 commit into
feat/agents-window-supportfrom
feat/mcp-server

Conversation

@EhabY

@EhabY EhabY commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1218, closes VSC-62

Stacked on #1213; review only the last commit.

Offers the deployment's hosted MCP server (/api/experimental/mcp/http) to chat and the Agents window. VS Code signs in to it with its own OAuth flow, so the definition carries no credentials. The server is offered only when the deployment enables the mcp-server-http experiment and the OAuth2 provider (checked through /api/v2/experiments and the OAuth protected resource metadata), and is re-checked on sign-in, sign-out and deployment switch. coder.mcpServer.enabled turns it off; editors without the MCP API skip it.

The extension now activates onStartupFinished: the Agents window never activates onMcpCollection, so without it the server never shows up there. Because of that, the "Remote SSH extension not found" warning is shown once per install instead of on every activation.

Verified live on dogfood with VS Code Insiders 1.148: in the Agents window the server went from needs-auth to connected after the OAuth consent. Not verified: pnpm test:scopes for the new getExperiments probe (needs a scope test deployment).

Generated by Coder Agents on behalf of @EhabY.

Plan and decision log

MCP server (phase 3 of the Agents window plan; the rest is in #1213)

Phase 3: MCP server (commit 0f162b1, stacked PR)

  • MCP server definition provider for the deployment's hosted MCP endpoint, signed in with VS Code's OAuth (decisions 12 to 16). Wrapping coder exp mcp server over stdio was dropped: the Agents window runs extension stdio servers on the workspace (see MCP findings).
  • Later: optional chatSkills for common Coder workflows.

Decisions

  1. MCP transport: hosted HTTP endpoint (<url>/api/experimental/mcp/http) with VS Code's own OAuth; no credentials in the definition. A stdio CLI definition fails because the Agents window runs it on the workspace.
  2. MCP detection: offer the server only when GET /api/v2/experiments lists mcp-server-http and GET /.well-known/oauth-protected-resource/api/experimental/mcp/http returns 200. An unauthenticated probe of the endpoint can't tell, because coderd authenticates before checking the gates. Re-checked on sign-in, sign-out and deployment switch.
  3. MCP scope: every window; coder.mcpServer.enabled (default on, application scope); sign-in hint only in docs (CHANGELOG, setting description). Forks without the MCP API skip registration.
  4. MCP activation: add onStartupFinished. VS Code activates onMcpCollection:coder only when a server from the collection starts, and the Agents window never asks, so without it the server never appears there (verified live both ways). Also added to the Microsoft issue draft in feat: support the VS Code Agents window #1213.
  5. Missing Remote SSH warning: shown once per install (globalState coder.remoteSshMissingShown), logged on later activations. Showing it only on the open path was rejected because the Remote SSH-provided API (vscodeProposed) is also used by login dialogs, workspace actions, the Tasks panel, CLI prompts, the URI handler and env.remoteAuthority reads.

MCP findings (verified live, dogfood, Insiders 1.148)

  • Extension MCP definitions in the Agents window are forwarded to the agent host and run on the workspace (stdio spawned in ~/.vscode-server-insiders, cwd = workspace folder). env is not applied and resolveMcpServerDefinition is not called. A stdio coder exp mcp server definition therefore cannot use the extension's local CLI or session.
  • Hosted endpoint POST <url>/api/experimental/mcp/http with an McpHttpServerDefinition and no token: agent host reports needs-auth; MCP Servers view shows "Sign in"; clicking it runs VS Code's OAuth (DCR client "Visual Studio Code - Insiders", PKCE, loopback redirect); after the Coder consent page the server reports connected. Tokens are held in memory by the agent host.
  • Server gating (coderd/coderd.go): the route requires the mcp-server-http experiment and the OAuth2 provider (RequireOAuth2Provider). Without them it is not available, so most deployments do not serve it today.
  • Packaged VSIX, editor window: Coder MCP server available. Agents window without onStartupFinished: extension never activates, "Coder" not listed. With it: activates, agent host reports MCP server 'Coder' needs-auth.

@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

VSC-62

This branch has not been deployed

No deployments
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 the VS Code Agents window

1 participant