Files
vscode/test/mcp
4b5f3abeb4 Move the scenario runner out of the MCP server (#331862)
* Move the scenario runner out of the MCP server

The validate-ui-scenario skill runs `runScenario`, which drives VS Code through
`test/automation` and writes an evidence bundle. None of that is MCP: the runner
loads no MCP module at runtime, and the SDK import it inherited was type-only, so
TypeScript already elided it. It only lived under `test/mcp` because that is where
the evidence pipeline was first written.

That matters now: deleting the MCP server would take the skill with it.

Move the six files that have nothing to do with MCP into a new `test/scenario`
package, and leave `test/mcp` as one of its consumers alongside the skill. The MCP
evidence tools move to `test/mcp/src/evidenceTools.ts`, where the server-specific
schemas belong. Deleting `test/mcp` now removes only MCP code.

Drop the step banner along with it. `showOverlay` appended a banner to the DOM of
the product under test, which can shift layout and influence focus, so the runner
always opted out via VSCODE_EVIDENCE_CLEAN_CAPTURE. With the runner as the only
caller that opinion is unanimous, so the overlay and its opt-out both go and the
capture is unconditionally faithful. Step titles are still rendered onto the
finished recording by renderEvidenceChapters.

The new package emits declarations, matching `test/automation`, so the MCP server
keeps real types rather than silently degrading to `any`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: adb443eb-11e5-40a1-8608-7f593fa79485

* Add the lockfile for the new scenario package

Registering `test/scenario` in `build/npm/dirs.ts` makes the root install run npm
in that directory, and CI uses `npm ci`, which requires a lockfile. Every other
package registered there has one, so a clean CI install failed immediately with
ENOENT on `test/scenario/package-lock.json` before anything compiled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: adb443eb-11e5-40a1-8608-7f593fa79485

* Notify on the extracted scenario package

`test/mcp/**` notifies @TylerLeonhardt, so moving the runner to `test/scenario`
silently dropped notifications for it. Point the new path at the owner of the
validate-ui-scenario skill.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: adb443eb-11e5-40a1-8608-7f593fa79485

* Do not re-declare @types/node in the scenario package

The root package already declares `@types/node` as a devDependency, so the
extracted package inherits it through normal ancestor resolution; declaring it
again added a dependency that the OSS license check cannot cover, because
`@types/node` ships no LICENSE file and is not in ClearlyDefined or
cglicenses.json.

Verified against the state CI produces: `npm ci` in `test/scenario` installs no
`@types/node`, and both packages still compile, so the types resolve from the
repository root as intended.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: adb443eb-11e5-40a1-8608-7f593fa79485

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: adb443eb-11e5-40a1-8608-7f593fa79485
2026-08-20 14:47:55 -07:00
..

Code - OSS Development MCP Server

This directory contains a Model Context Protocol (MCP) server that provides VS Code automation capabilities for Code - OSS development and testing. The MCP server exposes Code - OSS's testing infrastructure through a standardized interface, allowing AI assistants and other tools to interact with VS Code programmatically.

What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to external data sources and tools. This MCP server specifically provides VS Code automation capabilities, making it possible for AI assistants to:

  • Start and stop VS Code instances
  • Interact with editors, terminals, and UI elements
  • Run commands and keybindings
  • Navigate the explorer, search, debug, and other viewlets
  • Manage extensions, settings, and keybindings
  • Work with notebooks and chat features

Quick Start - Stdio

Firstly, make sure you install all dependencies (npm i) at the root of the repo.

Then, open the Command Palette and run:

MCP: List Servers → vscode-automation-mcp → Start Server

or open mcp.json and start it from there.

That's it! It should automatically compile everything needed.

Arguments

Open the mcp.json and modify the args:

  • ["run", "start-stdio"]: opens Electron window
  • ["run", "start-stdio", "--", "--web"]: opens a Chromium window
  • ["run", "start-stdio", "--", "--web", "--headless"]: opens a headless window

NOTE: --web requires running npm run install-playwright from root

Debugging the server

You can modify the mcp.json to debug the server:

"vscode-automation-mcp": {
	"type": "stdio",
	"command": "node",
	"args": ["./out/stdio.js"],
	"cwd": "${workspaceFolder}/test/mcp",
	"dev": {
		"watch": "test/mcp/**/*.ts",
		"debug": {
			"type": "node"
		}
	}
}

What the Server Provides

The MCP server exposes a comprehensive set of VS Code automation tools through the MCP protocol:

Application Management

  • Start, stop, and restart VS Code instances
  • Open workspaces and folders
  • Record scenario evidence with step overlays, screenshots, video, traces, and an HTML report

Editor Tools

  • Open, close, and navigate files
  • Get and set editor content
  • Manage selections and cursors

Terminal Tools

  • Create and manage terminal instances
  • Send commands to terminals
  • Read terminal output

Debug Tools

  • Start and stop debug sessions
  • Manage breakpoints
  • Step through code

Search Tools

  • Search for files and text
  • Navigate search results

Extension Tools

  • Install and manage extensions
  • View extension information

UI Interaction

  • Quick access and command palette
  • Explorer and activity bar
  • Source control management
  • Status bar interactions
  • Problems panel
  • Settings and keybindings editors
  • Notebook support
  • Chat features

Scenario evidence

Start evidence capture before starting VS Code so Playwright enables video recording:

  1. Call vscode_automation_evidence_start, including any required pre-launch userSettings.
  2. Call vscode_automation_evidence_step with started before each action.
  3. Perform and validate the action with the relevant automation tools.
  4. Call vscode_automation_evidence_step with passed, failed, or skipped.
  5. Call vscode_automation_evidence_finish.

Artifacts are written to .build/vscode-playwright-mcp/evidence/<run-id>/. Each evidence run uses an isolated user profile with in-memory secret storage and records every visited Playwright page as a separate video.

Development

Manual Setup (Advanced)

If you prefer to run the server manually:

# Navigate to the MCP directory
cd test/mcp

# Install dependencies
npm install

# Compile TypeScript
npm run compile # or watch

# Start the server
npm start

Project Structure

test/mcp/
├── src/
│   ├── stdio.ts             # Entry point for stdio transport
│   ├── automation.ts        # MCP server with automation tools
│   ├── application.ts       # VS Code application lifecycle management
│   ├── options.ts           # Command-line options parsing
│   ├── utils.ts             # Utility functions
│   └── automationTools/     # Tool implementations organized by feature
│       ├── index.ts         # Tool registration
│       ├── core.ts          # Core application tools
│       ├── editor.ts        # Editor tools
│       ├── terminal.ts      # Terminal tools
│       ├── debug.ts         # Debug tools
│       └── ...              # Other feature-specific tools
├── package.json             # Dependencies and scripts
├── tsconfig.json            # TypeScript configuration
└── README.md                # This file

Architecture

The server uses a simple architecture:

  • stdio.ts - Entry point that creates the MCP server and connects via stdio transport
  • automation.ts - Creates the MCP server and registers all automation tools
  • application.ts - Manages VS Code application lifecycle (start, stop, restart)
  • automationTools/ - Modular tool implementations organized by VS Code feature area

Troubleshooting

Server Won't Start

  • Ensure Code - OSS has been built and run at least once (via F5 or code.sh)
  • Verify all dependencies are installed with npm install

Automation Issues

  • Ensure Code - OSS has been built and run at least once (via F5 or code.sh)
  • Check the server logs for errors
  • Verify the workspace path is correct

Contributing

This MCP server is part of the Code - OSS development infrastructure. When making changes:

  1. Follow the existing TypeScript and coding conventions
  2. Test with multiple MCP clients if possible
  3. Update this README if adding new capabilities
  4. Ensure proper error handling and logging

License

This project is licensed under the MIT License - see the top-level project's license file for details.