Skip to content

feat: Add terminal management tools to mcp-server-vscode#658

Open
psh4607 wants to merge 1 commit into
microsoft:mainfrom
psh4607:feat/terminal-tools
Open

feat: Add terminal management tools to mcp-server-vscode#658
psh4607 wants to merge 1 commit into
microsoft:mainfrom
psh4607:feat/terminal-tools

Conversation

@psh4607
Copy link
Copy Markdown

@psh4607 psh4607 commented Mar 27, 2026

Summary

Add four terminal management tools to the VSCode MCP Server extension, enabling AI assistants to create and manage VS Code integrated terminals via MCP.

New Tools

Tool Description
create_terminal Create a new terminal with optional name, working directory, and initial command
list_terminals List all active terminals in the workspace
send_terminal_text Send text/commands to an existing terminal by name
close_terminal Close a terminal by name

Design

  • Follows the existing debug_tools.ts pattern (list/start/stop CRUD)
  • Each tool uses Zod schema validation for parameters
  • Uses vscode.window.createTerminal(), terminal.sendText(), terminal.show(), terminal.dispose() APIs
  • Includes unit tests for schema validation

Files Changed

  • src/tools/terminal_tools.ts — Tool implementations
  • src/test/terminal_tools.test.ts — Zod schema validation tests
  • src/extension.ts — Tool registrations

Testing

  • TypeScript compilation (tsc): passing
  • Webpack build: passing
  • Schema validation tests: passing

VS Code 터미널을 MCP 도구로 제어할 수 있도록 4개 도구를 추가:
- create_terminal: 새 터미널 생성 (이름, cwd, 초기 명령어 지원)
- list_terminals: 활성 터미널 목록 조회
- send_terminal_text: 기존 터미널에 텍스트 전송
- close_terminal: 터미널 닫기

debug_tools의 list/start/stop 패턴을 따르며,
Zod 스키마 검증 유닛 테스트 포함.
@psh4607
Copy link
Copy Markdown
Author

psh4607 commented Mar 27, 2026

@microsoft-github-policy-service agree

@psh4607
Copy link
Copy Markdown
Author

psh4607 commented May 23, 2026

dev-agents review: Completed

Attempt: #107
Result: COMMENT
Review: #658 (review)
Head: d306221
Submitted: 2026-05-23T12:48:38Z
Findings: 2

Copy link
Copy Markdown
Author

@psh4607 psh4607 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment 남깁니다.

P1

  • processId가 Thenable이라 JSON 직렬화 시 올바른 값이 반환되지 않음 [critical] (mcp-servers/mcp-server-vscode/src/tools/terminal_tools.ts:42)
    vscode.Terminal.processIdThenable<number | undefined> 타입입니다(terminal_tools.d.ts:33에서 확인). 이를 직접 객체에 할당하면 extension.ts:233JSON.stringify{}로 직렬화되어 MCP 클라이언트가 실제 PID를 받지 못합니다.

    // 현재 (버그)
    const terminals = vscode.window.terminals.map((terminal, index) => ({
        index,
        name: terminal.name,
        processId: terminal.processId, // Thenable → JSON.stringify 시 {}
    }));
    
    // 수정 제안
    const terminals = await Promise.all(
        vscode.window.terminals.map(async (terminal, index) => ({
            index,
            name: terminal.name,
            processId: await terminal.processId,
        }))
    );

    함수 시그니처도 async로 변경해야 하며, extension.ts:230의 핸들러에서도 await을 추가해야 합니다.

P3

  • send_terminal_text에서 항상 터미널 포커스됨 (mcp-servers/mcp-server-vscode/src/tools/terminal_tools.ts:71)
    sendTerminalText에서 terminal.show()를 항상 호출하여, 텍스트를 보낼 때마다 터미널이 포커스됩니다. create_terminal에는 show 파라미터가 있어 선택적으로 제어할 수 있는 반면, send_terminal_text에는 해당 옵션이 없습니다.

    백그라운드에서 명령을 실행하고 싶은 경우(예: 여러 터미널에 연속으로 명령 전송) 매번 포커스가 전환되어 UX가 좋지 않을 수 있습니다. create_terminal과 동일하게 show 파라미터(기본값 true)를 추가하는 것을 고려해 주세요.


ℹ️ Read-only 리뷰 모드

이 repo owner는 UNWATCHED_REVIEW_TRUSTED_OWNERS에 포함되어 있지 않아 dependency install/build/test를 실행하지 않았습니다. diff 기반 코드 리뷰만 진행했습니다.


🔄 수동 재리뷰: PR 우측 사이드바 Reviewers 섹션의 Re-request review 버튼(아래 빨간 박스)을 누르면 이 봇이 다시 리뷰합니다.

Re-request review 버튼

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.

1 participant