Skip to main content
Glama
sirlordt
by sirlordt

vscode-terminal-mcp

npm version

MCPサーバーで、表示中のVSCodeターミナルタブでコマンドを実行し、出力を完全にキャプチャします。インライン実行とは異なり、すべてのコマンドは実際のターミナルで実行されるため、表示・スクロール・操作が可能です。

主な機能

  • 表示可能なターミナル: コマンドは非表示のプロセスではなく、実際のVSCodeターミナルタブで実行されます。すべてをリアルタイムで確認できます。

  • セッション再利用: runツールはアイドル状態のセッションを自動的に再利用し、必要なときだけ新しいターミナルを作成します。

  • 長時間実行のサポート: waitForCompletion: false によるファイアアンドフォーゲット実行を行い、その後 read で出力を段階的にポーリングします。

  • サブエージェントの分離: セッションに agentId をタグ付けして、並行エージェントのワークロードを分離します。

Related MCP server: Terminal MCP

要件

  • VS Code 1.93+(Shell Integration API 用)

  • Node.js 20+

はじめに

Claude Code

claude mcp add BashTerm -- npx vscode-terminal-mcp@latest

VS Code / Copilot

.vscode/mcp.json に追加します:

{
  "servers": {
    "BashTerm": {
      "type": "stdio",
      "command": "npx",
      "args": ["vscode-terminal-mcp@latest"]
    }
  }
}

.cursor/mcp.json に追加します:

{
  "mcpServers": {
    "BashTerm": {
      "command": "npx",
      "args": ["-y", "vscode-terminal-mcp@latest"]
    }
  }
}

claude_desktop_config.json に追加します:

{
  "mcpServers": {
    "BashTerm": {
      "command": "npx",
      "args": ["-y", "vscode-terminal-mcp@latest"]
    }
  }
}

最初のプロンプト

インストール後、次のように試してみてください:

ターミナルで ls -la を実行

VSCode に新しいターミナルタブが開き、コマンド出力が表示されるはずです。

スクリーンショット

run でコマンドを実行

Run command output

exec の権限ダイアログ

Exec permission dialog

クリーンな出力の Exec 結果

Exec finished

ツール

クイック実行

ツール

説明

run

ターミナルを作成(または再利用)し、1ステップでコマンドを実行します。終了コード付きのクリーンな出力を返します。

セッション管理

ツール

説明

create

新しい表示可能なターミナルセッションを作成します。sessionId を返します。

exec

既存のセッションでコマンドを実行し、出力をキャプチャします。

read

セッションから出力をページング付きで読み取ります。インクリメンタル読み取りとテールモード(offset: -N)に対応しています。

input

インタラクティブターミナル(プロンプト、REPL、確認)にテキストを送信します。

list

アクティブなセッションを一覧表示します。オプションで agentId によるフィルタリングが可能です。

close

ターミナルセッションとそのVSCodeタブを閉じます。

使用パターン

シンプルなコマンド

run ツールがすべてを処理します。必要に応じてターミナルを作成し、実行して、クリーンな出力を返します:

> Run npm test
$ npm test
PASS src/utils.test.ts (3 tests)
PASS src/index.test.ts (5 tests)

[exit: 0 | 1243ms | session-abc123]

長時間実行プロセス

ビルド、デプロイ、または時間のかかるコマンドの場合:

> Start `npm run build` without waiting, then check progress

エージェントは次の手順を実行します:

  1. waitForCompletion: false を指定して run を呼び出します — 即座に戻ります

  2. offset: -10 を指定して read を呼び出し、最後の10行を確認します

  3. プロセスが完了するまで繰り返します

インタラクティブコマンド

ユーザー入力が必要なコマンドの場合:

> Run npm init and answer the prompts

エージェントは次の手順を実行します:

  1. npm initrun を呼び出します

  2. read を呼び出してプロンプトを確認します

  3. input を呼び出して回答を送信します

並行エージェント

サブエージェントは agentId を使用して分離されたターミナルで作業できます:

> Have one agent run tests while another runs the linter

各サブエージェントは、自身の agentId でタグ付けされた専用ターミナルを取得し、出力が混ざらないようにします。

設定

拡張機能は、VSCode の設定 terminalMcp.* から構成を読み取ります:

設定

デフォルト

説明

terminalMcp.maxSessions

number

10

同時に実行できるターミナルセッションの最大数

terminalMcp.commandTimeout

number

30000

デフォルトのコマンドタイムアウト(ms)

terminalMcp.maxOutputLines

number

5000

セッションごとに出力バッファに保持する最大行数

terminalMcp.idleTimeout

number

1800000

この時間(ms)が経過したアイドルセッションを閉じます(0 = 無効)

terminalMcp.blockedCommands

string[]

["rm -rf /"]

拒否されるコマンド

推奨: 優先ツールとして設定

Claude Code などの LLM エージェントには、チャット内でコマンドをインライン実行する組み込みの Bash ツールがあります。出力は会話に埋め込まれ、特に出力が多いコマンドでは読みにくくなります。この MCP を組み込みの Bash ツールよりも優先するようエージェントに指示することをお勧めします。

プロジェクトの CLAUDE.md(または同等の指示ファイル)に以下を追加してください:

## Terminal Execution

Prefer the BashTerm MCP tools (`run`, `exec`, `read`, etc.) over the built-in Bash tool for executing commands.
BashTerm runs commands in visible VSCode terminal tabs where the user can see output in real time.
Only fall back to the built-in Bash tool for simple, non-interactive operations like reading environment variables.

For commands that may take longer than 30 seconds or produce large amounts of output (builds, test suites,
deployments, installs), use the pull mode pattern:
1. Call `run` with `waitForCompletion: false` to launch the command without blocking.
2. Call `read` with `offset: -10` to check the last 10 lines of output.
3. Repeat step 2 until you see the command has finished (look for exit messages, prompts, or "Done").
4. Report the final result to the user.

This prevents conversation timeouts and lets the user watch progress in the terminal in real time.

これが重要な理由:

Built-in Bash

BashTerm MCP

出力の可視性

チャットに埋め込まれ、スクロールしにくい

VSCode ターミナルタブで表示可能

リアルタイムフィードバック

コマンドが完了するまでユーザーは何も見えない

ユーザーは出力をライブで確認できる

長時間実行コマンド

タイムアウトまで会話をブロック

ファイアアンドフォーゲット + ポーリング

セッション状態

各コマンドは分離されている

履歴付きの永続セッション

インタラクティブコマンド

非対応

プロンプト/REPL に入力を送信

開発: 拡張機能の更新

VSCode は拡張機能をメモリ内に積極的にキャッシュします。ローカルで開発する場合、code --install-extension や「Developer: Reload Window」でも変更がリロードされない場合があります。次のワークフローを使用してください:

クイック更新(再起動不要)

ソースファイルを変更した後、ビルドしてインストール済みの拡張機能ディレクトリに直接コピーします:

cd /path/to/vscode-terminal-mcp
npm run build
cp dist/extension.js ~/.vscode/extensions/sirlordt.vscode-terminal-mcp-<version>/dist/extension.js

次に、「Developer: Reload Window」Ctrl+Shift+P)を実行します。

完全再インストール(クイック更新が機能しない場合)

VSCode がまだ古いコードを使用している場合:

# 1. Uninstall and remove all copies
code --uninstall-extension sirlordt.vscode-terminal-mcp
rm -rf ~/.vscode/extensions/sirlordt.vscode-terminal-mcp-*

# 2. Check for ghost entries with old publisher names
# Look in ~/.vscode/extensions/extensions.json for stale entries
# Remove any entries with old publisher IDs (e.g., "terminal-mcp.vscode-terminal-mcp")

# 3. Close VSCode completely (not just reload)

# 4. Rebuild and install
npm run build
npx vsce package --allow-missing-repository
code --install-extension vscode-terminal-mcp-<version>.vsix --force

# 5. Open VSCode

正しいバージョンが読み込まれていることを確認

# Check which extension directories exist
ls ~/.vscode/extensions/ | grep terminal

# Verify your changes are in the installed extension
grep "YOUR_UNIQUE_STRING" ~/.vscode/extensions/sirlordt.vscode-terminal-mcp-*/dist/extension.js

# Compare checksums
md5sum dist/extension.js ~/.vscode/extensions/sirlordt.vscode-terminal-mcp-*/dist/extension.js

大量出力の処理

read が MCP クライアントのトークン制限を超える出力を返す場合、システムは自動的に完全な出力を一時的な JSON ファイルに保存し、エラーメッセージ内でファイルパスを返します。

関連するコンテンツを抽出するには:

# Get the last 50 lines (most relevant for status)
tail -50 /path/to/saved/file.txt

# Or parse the JSON to extract the text content
python3 -c "import json; data=json.load(open('/path/to/file.txt')); print(data[0]['text'][-2000:])"

ファイル形式は JSON です: [{"type": "text", "text": "..."}]

これは、大量の TUI 出力(プログレスバー、ANSI エスケープコード)を生成するコマンドでよく発生します。offset の値を小さくして(例: offset: -100 の代わりに offset: -20)、キャプチャされる出力サイズを減らしてください。

仕組み

  1. VSCode 拡張機能がアクティブになり、Unix ソケット上で IPC サーバーを起動します

  2. MCP エントリポイントmcp-entry.js)は MCP クライアントによって起動され、JSON-RPC stdio と IPC ソケットをブリッジします

  3. コマンドは実際の VSCode ターミナルで実行され、Shell Integration API を使用して出力キャプチャと終了コード検出を確実に行います

  4. 出力は循環バッファに保存され、効率的な読み取りのためのページングをサポートします

最新の変更(0.1.6)

  • マーケットプレイス用の README のスクリーンショット

  • すべてのツールでクリーンな出力形式 — 生の JSON はもうありません

  • waitForCompletion: false が機能しない問題を修正

  • アイドルリーパーを無効化 — ユーザーが手動でセッションを閉じます

  • ワークスペースごとに一意の IPC ソケット(マルチインスタンス対応)

  • 日付形式のカスタムターミナルタブ名

  • 大量出力処理のドキュメント

完全な履歴は CHANGELOG.md を参照してください。

ライセンス

MIT

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables management of visible, interactive terminal sessions across platforms (macOS, Windows, Linux, WSL). Supports creating, executing commands, capturing output, and managing multiple terminal windows simultaneously.
    5
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI assistants to execute shell commands and manage long-running processes within persistent tmux sessions across isolated workspaces. It features a dual-window architecture to separate raw command execution from interactive terminal output.
    8
    9
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables interactive terminal sessions within Claude Code and Desktop, allowing users and AI to execute commands and manage multiple tabs.
    2

View all related MCP servers

Related MCP Connectors

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Live browser debugging for AI assistants — DOM, console, network via MCP.

  • A paid remote MCP for AI agent browser DevTools MCP, built to return verdicts, receipts, usage logs,

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sirlordt/vscode-terminal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server