vscode-terminal-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/dist/extension.js +6436 -0
- package/dist/mcp-entry.js +203 -0
- package/icon.png +0 -0
- package/icon.svg +65 -0
- package/package.json +124 -0
- package/research/01-mcp-sdk-patterns.md +54 -0
- package/research/02-vscode-terminal-api.md +36 -0
- package/research/03-vscode-mcp-integration.md +43 -0
- package/research/04-desktop-commander-referencia.md +45 -0
- package/server.json +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sirlordt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# vscode-terminal-mcp
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/vscode-terminal-mcp)
|
|
4
|
+
|
|
5
|
+
MCP server that executes commands in **visible VSCode terminal tabs** with full output capture. Unlike inline execution, every command runs in a real terminal you can see, scroll, and interact with.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **Visible Terminals**: Commands run in real VSCode terminal tabs, not hidden processes. You see everything in real time.
|
|
10
|
+
- **Session Reuse**: The `run` tool automatically reuses idle sessions, creating new terminals only when needed.
|
|
11
|
+
- **Long-Running Support**: Fire-and-forget execution with `waitForCompletion: false`, then poll output incrementally with `read`.
|
|
12
|
+
- **Subagent Isolation**: Tag sessions with `agentId` to keep parallel agent workloads separated.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- VS Code 1.93+ (for Shell Integration API)
|
|
17
|
+
- Node.js 20+
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
### Claude Code
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add BashTerm -- npx vscode-terminal-mcp@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### VS Code / Copilot
|
|
28
|
+
|
|
29
|
+
Add to your `.vscode/mcp.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"servers": {
|
|
34
|
+
"BashTerm": {
|
|
35
|
+
"type": "stdio",
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["vscode-terminal-mcp@latest"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary>Cursor</summary>
|
|
45
|
+
|
|
46
|
+
Add to your `.cursor/mcp.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"BashTerm": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "vscode-terminal-mcp@latest"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
</details>
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>Claude Desktop</summary>
|
|
63
|
+
|
|
64
|
+
Add to your `claude_desktop_config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"BashTerm": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "vscode-terminal-mcp@latest"]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
### Your First Prompt
|
|
80
|
+
|
|
81
|
+
After installation, try asking:
|
|
82
|
+
|
|
83
|
+
> Run `ls -la` in the terminal
|
|
84
|
+
|
|
85
|
+
You should see a new terminal tab open in VSCode with the command output.
|
|
86
|
+
|
|
87
|
+
## Tools
|
|
88
|
+
|
|
89
|
+
### Quick Execution
|
|
90
|
+
|
|
91
|
+
| Tool | Description |
|
|
92
|
+
|------|-------------|
|
|
93
|
+
| `run` | Create (or reuse) a terminal and execute a command in one step. Returns clean output with exit code. |
|
|
94
|
+
|
|
95
|
+
### Session Management
|
|
96
|
+
|
|
97
|
+
| Tool | Description |
|
|
98
|
+
|------|-------------|
|
|
99
|
+
| `create` | Create a new visible terminal session. Returns a `sessionId`. |
|
|
100
|
+
| `exec` | Execute a command in an existing session and capture output. |
|
|
101
|
+
| `read` | Read output from a session with pagination. Supports incremental reads and tail mode (`offset: -N`). |
|
|
102
|
+
| `input` | Send text to an interactive terminal (prompts, REPLs, confirmations). |
|
|
103
|
+
| `list` | List active sessions. Optionally filter by `agentId`. |
|
|
104
|
+
| `close` | Close a terminal session and its VSCode tab. |
|
|
105
|
+
|
|
106
|
+
## Usage Patterns
|
|
107
|
+
|
|
108
|
+
### Simple Command
|
|
109
|
+
|
|
110
|
+
The `run` tool handles everything — creates a terminal if needed, executes, and returns clean output:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
> Run npm test
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
$ npm test
|
|
118
|
+
PASS src/utils.test.ts (3 tests)
|
|
119
|
+
PASS src/index.test.ts (5 tests)
|
|
120
|
+
|
|
121
|
+
[exit: 0 | 1243ms | session-abc123]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Long-Running Process
|
|
125
|
+
|
|
126
|
+
For builds, deployments, or any command that takes a while:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
> Start `npm run build` without waiting, then check progress
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The agent will:
|
|
133
|
+
1. Call `run` with `waitForCompletion: false` — returns immediately
|
|
134
|
+
2. Call `read` with `offset: -10` to check the last 10 lines
|
|
135
|
+
3. Repeat until the process completes
|
|
136
|
+
|
|
137
|
+
### Interactive Commands
|
|
138
|
+
|
|
139
|
+
For commands that need user input:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
> Run npm init and answer the prompts
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The agent will:
|
|
146
|
+
1. Call `run` with `npm init`
|
|
147
|
+
2. Call `read` to see the prompt
|
|
148
|
+
3. Call `input` to send the answer
|
|
149
|
+
|
|
150
|
+
### Parallel Agents
|
|
151
|
+
|
|
152
|
+
Subagents can work in isolated terminals using `agentId`:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
> Have one agent run tests while another runs the linter
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Each subagent gets its own terminal tagged with its `agentId`, preventing output from mixing.
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
The extension reads configuration from VSCode settings under `terminalMcp.*`:
|
|
163
|
+
|
|
164
|
+
| Setting | Type | Default | Description |
|
|
165
|
+
|---------|------|---------|-------------|
|
|
166
|
+
| `terminalMcp.maxSessions` | number | 10 | Maximum concurrent terminal sessions |
|
|
167
|
+
| `terminalMcp.commandTimeout` | number | 30000 | Default command timeout in ms |
|
|
168
|
+
| `terminalMcp.maxOutputLines` | number | 5000 | Max lines kept in output buffer per session |
|
|
169
|
+
| `terminalMcp.idleTimeout` | number | 1800000 | Close idle sessions after this many ms (0 = disabled) |
|
|
170
|
+
| `terminalMcp.blockedCommands` | string[] | `["rm -rf /"]` | Commands that will be rejected |
|
|
171
|
+
|
|
172
|
+
## Recommended: Set as Preferred Tool
|
|
173
|
+
|
|
174
|
+
LLM agents like Claude Code have a built-in `Bash` tool that executes commands inline within the chat. The output is embedded in the conversation and hard to read, especially for commands with verbose output. **We recommend telling the agent to prefer this MCP over its built-in Bash tool.**
|
|
175
|
+
|
|
176
|
+
Add the following to your project's `CLAUDE.md` (or equivalent instructions file):
|
|
177
|
+
|
|
178
|
+
```markdown
|
|
179
|
+
## Terminal Execution
|
|
180
|
+
|
|
181
|
+
Prefer the BashTerm MCP tools (`run`, `exec`, `read`, etc.) over the built-in Bash tool for executing commands.
|
|
182
|
+
BashTerm runs commands in visible VSCode terminal tabs where the user can see output in real time.
|
|
183
|
+
Only fall back to the built-in Bash tool for simple, non-interactive operations like reading environment variables.
|
|
184
|
+
|
|
185
|
+
For commands that may take longer than 30 seconds or produce large amounts of output (builds, test suites,
|
|
186
|
+
deployments, installs), use the pull mode pattern:
|
|
187
|
+
1. Call `run` with `waitForCompletion: false` to launch the command without blocking.
|
|
188
|
+
2. Call `read` with `offset: -10` to check the last 10 lines of output.
|
|
189
|
+
3. Repeat step 2 until you see the command has finished (look for exit messages, prompts, or "Done").
|
|
190
|
+
4. Report the final result to the user.
|
|
191
|
+
|
|
192
|
+
This prevents conversation timeouts and lets the user watch progress in the terminal in real time.
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Why this matters:**
|
|
196
|
+
|
|
197
|
+
| | Built-in Bash | BashTerm MCP |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| Output visibility | Embedded in chat, hard to scroll | Visible in VSCode terminal tab |
|
|
200
|
+
| Real-time feedback | User sees nothing until command finishes | User watches output live |
|
|
201
|
+
| Long-running commands | Blocks the conversation until timeout | Fire-and-forget + polling |
|
|
202
|
+
| Session state | Each command is isolated | Persistent sessions with history |
|
|
203
|
+
| Interactive commands | Not supported | Send input to prompts/REPLs |
|
|
204
|
+
|
|
205
|
+
## How It Works
|
|
206
|
+
|
|
207
|
+
1. The **VSCode extension** activates and starts an IPC server on a Unix socket
|
|
208
|
+
2. The **MCP entry point** (`mcp-entry.js`) is spawned by the MCP client and bridges JSON-RPC stdio with the IPC socket
|
|
209
|
+
3. Commands execute in real VSCode terminals using the **Shell Integration API** for reliable output capture and exit code detection
|
|
210
|
+
4. Output is stored in circular buffers with pagination support for efficient reading
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT
|