feat: Add terminal management tools with output capture to mcp-server-vscode#659
Open
psh4607 wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: Add terminal management tools with output capture to mcp-server-vscode#659psh4607 wants to merge 1 commit intomicrosoft:mainfrom
psh4607 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Add five terminal management tools enabling AI assistants to create, control, and read output from VS Code integrated terminals via MCP. Tools: create_terminal, list_terminals, send_terminal_text, close_terminal, get_terminal_output Output capture uses the stable shell execution API (1.93+) instead of the proposed onDidWriteTerminalData, storing per-command results in memory with no disk persistence.
Author
If the output capture approach ( Happy to iterate on either PR based on your feedback! |
Author
|
@microsoft-github-policy-service agree |
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.
Summary
Add five terminal management tools to the VSCode MCP Server extension, enabling AI assistants to create, control, and read output from VS Code integrated terminals via MCP.
This builds on the existing tool patterns (debug_tools, focus_editor) and adds a frequently requested capability: programmatic terminal access for AI-powered development workflows.
New Tools
create_terminallist_terminalssend_terminal_textclose_terminalget_terminal_outputDesign Decisions & Trade-offs
Output Capture: Why Shell Execution Events (not file-based)
We explored three approaches for reading terminal output before settling on the current design:
Approach A: Passive capture via
onDidWriteTerminalData(rejected)onDidWriteTerminalDatais a proposed API, not available in stable@types/vscode. Also raises security concerns — terminal output (which may contain environment variables, API keys, passwords) would be persisted to disk files, creating a larger attack surface than xterm.js's in-memory scrollback buffer.Approach B: File-based storage (rejected)
os.tmpdir()withget_terminal_output(name, offset, limit, stripAnsi)pagination~/.zsh_historypersists commands to disk — so the threat model isn't dramatically different. Still, adding a new persistence vector seemed unnecessary when a better stable API exists.Approach C: Shell execution events (chosen) ✅
onDidStartTerminalShellExecution+TerminalShellExecution.read()(stable since VS Code 1.93)Architecture
Expected Impact
Files Changed
src/tools/terminal_tools.tssrc/utils/terminal_output_capture.tssrc/test/terminal_tools.test.tssrc/extension.tsTesting
tsc): passing