BashTerm
vscode-terminal-mcp
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@latestVS 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 でコマンドを実行

exec の権限ダイアログ

クリーンな出力の Exec 結果

ツール
クイック実行
ツール | 説明 |
| ターミナルを作成(または再利用)し、1ステップでコマンドを実行します。終了コード付きのクリーンな出力を返します。 |
セッション管理
ツール | 説明 |
| 新しい表示可能なターミナルセッションを作成します。 |
| 既存のセッションでコマンドを実行し、出力をキャプチャします。 |
| セッションから出力をページング付きで読み取ります。インクリメンタル読み取りとテールモード( |
| インタラクティブターミナル(プロンプト、REPL、確認)にテキストを送信します。 |
| アクティブなセッションを一覧表示します。オプションで |
| ターミナルセッションとその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エージェントは次の手順を実行します:
waitForCompletion: falseを指定してrunを呼び出します — 即座に戻りますoffset: -10を指定してreadを呼び出し、最後の10行を確認しますプロセスが完了するまで繰り返します
インタラクティブコマンド
ユーザー入力が必要なコマンドの場合:
> Run npm init and answer the promptsエージェントは次の手順を実行します:
npm initでrunを呼び出しますreadを呼び出してプロンプトを確認しますinputを呼び出して回答を送信します
並行エージェント
サブエージェントは agentId を使用して分離されたターミナルで作業できます:
> Have one agent run tests while another runs the linter各サブエージェントは、自身の agentId でタグ付けされた専用ターミナルを取得し、出力が混ざらないようにします。
設定
拡張機能は、VSCode の設定 terminalMcp.* から構成を読み取ります:
設定 | 型 | デフォルト | 説明 |
| number | 10 | 同時に実行できるターミナルセッションの最大数 |
| number | 30000 | デフォルトのコマンドタイムアウト(ms) |
| number | 5000 | セッションごとに出力バッファに保持する最大行数 |
| number | 1800000 | この時間(ms)が経過したアイドルセッションを閉じます(0 = 無効) |
| string[] |
| 拒否されるコマンド |
推奨: 優先ツールとして設定
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)、キャプチャされる出力サイズを減らしてください。
仕組み
VSCode 拡張機能がアクティブになり、Unix ソケット上で IPC サーバーを起動します
MCP エントリポイント(
mcp-entry.js)は MCP クライアントによって起動され、JSON-RPC stdio と IPC ソケットをブリッジしますコマンドは実際の VSCode ターミナルで実行され、Shell Integration API を使用して出力キャプチャと終了コード検出を確実に行います
出力は循環バッファに保存され、効率的な読み取りのためのページングをサポートします
最新の変更(0.1.6)
マーケットプレイス用の README のスクリーンショット
すべてのツールでクリーンな出力形式 — 生の JSON はもうありません
waitForCompletion: falseが機能しない問題を修正アイドルリーパーを無効化 — ユーザーが手動でセッションを閉じます
ワークスペースごとに一意の IPC ソケット(マルチインスタンス対応)
日付形式のカスタムターミナルタブ名
大量出力処理のドキュメント
完全な履歴は CHANGELOG.md を参照してください。
ライセンス
MIT
This server cannot be installed
Maintenance
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
- FlicenseNot gradedqualityDmaintenanceProvides stateful, interactive terminal access for LLMs to spawn and maintain persistent processes like SSH sessions, debuggers, and REPLs with continuous input/output interaction across commands.7
- AlicenseAqualityDmaintenanceEnables management of visible, interactive terminal sessions across platforms (macOS, Windows, Linux, WSL). Supports creating, executing commands, capturing output, and managing multiple terminal windows simultaneously.51MIT
- AlicenseAqualityDmaintenanceEnables 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.891MIT
- FlicenseNot gradedqualityDmaintenanceEnables interactive terminal sessions within Claude Code and Desktop, allowing users and AI to execute commands and manage multiple tabs.2
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,
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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