bashterm-mcp-server 0.2.0 → 0.2.1
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/CHANGELOG.md +6 -0
- package/CLAUDE.md +70 -36
- package/README.md +33 -161
- package/README.zh-CN.md +183 -236
- package/dist/extension.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -1,66 +1,109 @@
|
|
|
1
|
-
# Project:
|
|
1
|
+
# Project: BashTerm MCP
|
|
2
2
|
|
|
3
3
|
MCP server that runs commands in visible VSCode terminal tabs.
|
|
4
4
|
|
|
5
|
+
## Terminal Execution
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
For commands that may take longer than 30 seconds or produce large output, use pull mode:
|
|
10
|
+
1. Call `run` with `waitForCompletion: false`
|
|
11
|
+
2. Call `read` with `offset: -10` to check progress
|
|
12
|
+
3. Repeat until done
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
5
16
|
## Release Process
|
|
6
17
|
|
|
7
|
-
|
|
18
|
+
以下以发布 v0.2.1 为例,一步一步执行。
|
|
8
19
|
|
|
9
|
-
### 1.
|
|
20
|
+
### 1. 更新版本号(2 个文件,3 处)
|
|
10
21
|
|
|
11
22
|
```bash
|
|
12
|
-
#
|
|
13
|
-
#
|
|
23
|
+
# package.json "version": "0.2.0" → "0.2.1"
|
|
24
|
+
# server.json 顶层 "version": "0.2.0" → "0.2.1"
|
|
25
|
+
# server.json packages[0].version: "0.2.0" → "0.2.1"
|
|
14
26
|
```
|
|
15
27
|
|
|
16
|
-
### 2.
|
|
28
|
+
### 2. 更新 CHANGELOG.md
|
|
17
29
|
|
|
18
|
-
|
|
30
|
+
在文件顶部新增条目:
|
|
19
31
|
|
|
20
32
|
```markdown
|
|
21
|
-
## [0.1
|
|
33
|
+
## [0.2.1] - YYYY-MM-DD
|
|
22
34
|
|
|
23
35
|
### Added
|
|
24
|
-
-
|
|
36
|
+
- 新功能...
|
|
25
37
|
|
|
26
38
|
### Fixed
|
|
27
|
-
-
|
|
39
|
+
- 修复...
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- 变更...
|
|
28
43
|
```
|
|
29
44
|
|
|
30
|
-
### 3.
|
|
45
|
+
### 3. 更新 README.md 和 README.zh-CN.md
|
|
46
|
+
|
|
47
|
+
替换 **Latest Changes** 节为新版本改动,只列核心条目,完整历史指向 CHANGELOG.md。
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
> ⚠️ **不要用 `replace_all` 做模糊全局替换!** `bashterm-` 会匹配并误伤 `bashterm-mcp` 等 URL。只精确替换目标字符串。
|
|
33
50
|
|
|
34
|
-
### 4.
|
|
51
|
+
### 4. 构建和测试
|
|
35
52
|
|
|
36
53
|
```bash
|
|
37
|
-
#
|
|
38
|
-
npm
|
|
54
|
+
npm run build # esbuild 双产物:dist/extension.js + dist/mcp-entry.js
|
|
55
|
+
npm test # 45 tests must pass
|
|
56
|
+
```
|
|
39
57
|
|
|
40
|
-
|
|
41
|
-
npm publish --access public
|
|
58
|
+
### 5. 打包 VSIX
|
|
42
59
|
|
|
43
|
-
|
|
60
|
+
```bash
|
|
44
61
|
npx vsce package --allow-missing-repository
|
|
62
|
+
# 生成 bashterm-mcp-server-0.2.1.vsix
|
|
63
|
+
```
|
|
45
64
|
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
### 6. 发布 npm
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm whoami # 确认已登录
|
|
69
|
+
npm publish --access public
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 7. 创建 GitHub Release
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
gh release create v0.2.1 \
|
|
76
|
+
--title "v0.2.1 — BashTerm MCP" \
|
|
77
|
+
--notes "从 CHANGELOG.md 复制改动内容" \
|
|
78
|
+
bashterm-mcp-server-0.2.1.vsix
|
|
48
79
|
```
|
|
49
80
|
|
|
50
|
-
###
|
|
81
|
+
### 8. 上传 VSCode Marketplace
|
|
51
82
|
|
|
52
|
-
1.
|
|
53
|
-
2.
|
|
54
|
-
3.
|
|
83
|
+
1. 打开 https://marketplace.visualstudio.com/manage/publishers/hcdb
|
|
84
|
+
2. 找到 BashTerm MCP → `...` → **Update**
|
|
85
|
+
3. 上传 `.vsix`
|
|
55
86
|
|
|
56
|
-
|
|
87
|
+
> 备选:配置 Azure DevOps PAT 后可用 `npx vsce publish` 一键发布。
|
|
88
|
+
|
|
89
|
+
### 9. 提交和推送
|
|
57
90
|
|
|
58
91
|
```bash
|
|
59
92
|
git add -A
|
|
60
|
-
git commit -m "v0.1
|
|
93
|
+
git commit -m "v0.2.1:<变更摘要>"
|
|
61
94
|
git push
|
|
62
95
|
```
|
|
63
96
|
|
|
97
|
+
### 10. 验证
|
|
98
|
+
|
|
99
|
+
- [ ] `npx bashterm-mcp-server@latest` 正常启动
|
|
100
|
+
- [ ] VSCode 扩展商店搜索 "BashTerm MCP" 显示新版本
|
|
101
|
+
- [ ] https://www.npmjs.com/package/bashterm-mcp-server 显示新版本
|
|
102
|
+
- [ ] GitHub Release 徽章显示新版本号
|
|
103
|
+
- [ ] README.md 和 README.zh-CN.md 的徽章链接全部正常
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
64
107
|
## Extension Cache Workaround
|
|
65
108
|
|
|
66
109
|
VSCode aggressively caches extensions. When developing locally:
|
|
@@ -68,17 +111,8 @@ VSCode aggressively caches extensions. When developing locally:
|
|
|
68
111
|
```bash
|
|
69
112
|
# Quick update (after modifying source)
|
|
70
113
|
npm run build
|
|
71
|
-
cp dist/extension.js ~/.vscode/extensions/hcdb.bashterm-<version>/dist/extension.js
|
|
114
|
+
cp dist/extension.js ~/.vscode/extensions/hcdb.bashterm-mcp-server-<version>/dist/extension.js
|
|
72
115
|
# Then "Developer: Reload Window"
|
|
73
116
|
|
|
74
117
|
# If reload doesn't pick up changes, close and reopen VSCode completely
|
|
75
118
|
```
|
|
76
|
-
|
|
77
|
-
## Terminal Execution
|
|
78
|
-
|
|
79
|
-
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.
|
|
80
|
-
|
|
81
|
-
For commands that may take longer than 30 seconds or produce large output, use pull mode:
|
|
82
|
-
1. Call `run` with `waitForCompletion: false`
|
|
83
|
-
2. Call `read` with `offset: -10` to check progress
|
|
84
|
-
3. Repeat until done
|
package/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
# BashTerm
|
|
2
2
|
|
|
3
|
-
[](README.zh-CN.md) [](README.zh-CN.md) [](https://github.com/1170953489/bashterm-mcp/releases) [](https://www.npmjs.com/package/bashterm-mcp-server)
|
|
4
4
|
|
|
5
|
-
MCP server that
|
|
5
|
+
MCP server that runs shell commands in **visible VSCode terminal tabs** — watch output live, scroll history, interact when needed.
|
|
6
6
|
|
|
7
7
|
## Key Features
|
|
8
8
|
|
|
9
|
-
- **Visible Terminals**: Commands run in real VSCode terminal tabs
|
|
10
|
-
- **Session Reuse**:
|
|
11
|
-
- **
|
|
12
|
-
- **Subagent Isolation**: Tag sessions with `agentId` to keep parallel agent workloads
|
|
13
|
-
|
|
14
|
-
> **Windows Compatible** — This fork fully supports Windows, including Chinese output without garbled text.
|
|
9
|
+
- **Visible Terminals**: Commands run in real VSCode terminal tabs — watch output live, scroll history, interact when needed.
|
|
10
|
+
- **Session Reuse**: `run` automatically reuses idle sessions, creating new terminals only when necessary.
|
|
11
|
+
- **Non-Blocking Execution**: Fire-and-forget with `waitForCompletion: false`, then poll with `read`.
|
|
12
|
+
- **Subagent Isolation**: Tag sessions with `agentId` to keep parallel agent workloads in separate terminals.
|
|
15
13
|
|
|
16
14
|
## Requirements
|
|
17
15
|
|
|
@@ -23,7 +21,7 @@ MCP server that executes commands in **visible VSCode terminal tabs** with full
|
|
|
23
21
|
### Claude Code
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
|
-
claude mcp add BashTerm -- npx bashterm-mcp-server
|
|
24
|
+
claude mcp add BashTerm -- npx bashterm-mcp-server@latest
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
### VS Code / Copilot
|
|
@@ -36,7 +34,7 @@ Add to your `.vscode/mcp.json`:
|
|
|
36
34
|
"BashTerm": {
|
|
37
35
|
"type": "stdio",
|
|
38
36
|
"command": "npx",
|
|
39
|
-
"args": ["bashterm-mcp-server
|
|
37
|
+
"args": ["bashterm-mcp-server@latest"]
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
}
|
|
@@ -52,7 +50,7 @@ Add to your `.cursor/mcp.json`:
|
|
|
52
50
|
"mcpServers": {
|
|
53
51
|
"BashTerm": {
|
|
54
52
|
"command": "npx",
|
|
55
|
-
"args": ["-y", "bashterm-mcp-server
|
|
53
|
+
"args": ["-y", "bashterm-mcp-server@latest"]
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
}
|
|
@@ -70,7 +68,7 @@ Add to your `claude_desktop_config.json`:
|
|
|
70
68
|
"mcpServers": {
|
|
71
69
|
"BashTerm": {
|
|
72
70
|
"command": "npx",
|
|
73
|
-
"args": ["-y", "bashterm-mcp-server
|
|
71
|
+
"args": ["-y", "bashterm-mcp-server@latest"]
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
}
|
|
@@ -78,26 +76,10 @@ Add to your `claude_desktop_config.json`:
|
|
|
78
76
|
|
|
79
77
|
</details>
|
|
80
78
|
|
|
81
|
-
### Your First Prompt
|
|
82
|
-
|
|
83
|
-
After installation, try asking:
|
|
84
|
-
|
|
85
|
-
> Run `ls -la` in the terminal
|
|
86
|
-
|
|
87
|
-
You should see a new terminal tab open in VSCode with the command output.
|
|
88
|
-
|
|
89
79
|
## Screenshots
|
|
90
80
|
|
|
91
|
-
### Running a command with `run`
|
|
92
|
-
|
|
93
81
|

|
|
94
|
-
|
|
95
|
-
### Permission dialog for `exec`
|
|
96
|
-
|
|
97
82
|

|
|
98
|
-
|
|
99
|
-
### Exec result with clean output
|
|
100
|
-
|
|
101
83
|

|
|
102
84
|
|
|
103
85
|
## Tools
|
|
@@ -112,12 +94,12 @@ You should see a new terminal tab open in VSCode with the command output.
|
|
|
112
94
|
|
|
113
95
|
| Tool | Description |
|
|
114
96
|
|------|-------------|
|
|
115
|
-
| `create` |
|
|
116
|
-
| `exec` |
|
|
117
|
-
| `read` | Read output
|
|
118
|
-
| `input` | Send text to an interactive
|
|
119
|
-
| `list` | List active sessions
|
|
120
|
-
| `close` | Close a
|
|
97
|
+
| `create` | Open a new visible terminal tab and return a `sessionId`. |
|
|
98
|
+
| `exec` | Run a command in an existing session and capture its output. |
|
|
99
|
+
| `read` | Read session output with offset-based pagination. Use `offset: -N` for tail mode. |
|
|
100
|
+
| `input` | Send text to an interactive process (answer prompts, drive REPLs, confirm actions). |
|
|
101
|
+
| `list` | List active sessions, optionally filtered by `agentId`. |
|
|
102
|
+
| `close` | Close a session and its terminal tab. |
|
|
121
103
|
|
|
122
104
|
## Usage Patterns
|
|
123
105
|
|
|
@@ -145,10 +127,7 @@ For builds, deployments, or any command that takes a while:
|
|
|
145
127
|
> Start `npm run build` without waiting, then check progress
|
|
146
128
|
```
|
|
147
129
|
|
|
148
|
-
The agent
|
|
149
|
-
1. Call `run` with `waitForCompletion: false` — returns immediately
|
|
150
|
-
2. Call `read` with `offset: -10` to check the last 10 lines
|
|
151
|
-
3. Repeat until the process completes
|
|
130
|
+
The agent launches the command with `waitForCompletion: false` (returns immediately), then polls with `read` (`offset: -10`) until the process finishes.
|
|
152
131
|
|
|
153
132
|
### Interactive Commands
|
|
154
133
|
|
|
@@ -158,10 +137,7 @@ For commands that need user input:
|
|
|
158
137
|
> Run npm init and answer the prompts
|
|
159
138
|
```
|
|
160
139
|
|
|
161
|
-
The agent
|
|
162
|
-
1. Call `run` with `npm init`
|
|
163
|
-
2. Call `read` to see the prompt
|
|
164
|
-
3. Call `input` to send the answer
|
|
140
|
+
The agent uses `run` to start the command, `read` to check the prompt, and `input` to send responses — driving the interactive process step by step.
|
|
165
141
|
|
|
166
142
|
### Parallel Agents
|
|
167
143
|
|
|
@@ -171,139 +147,35 @@ Subagents can work in isolated terminals using `agentId`:
|
|
|
171
147
|
> Have one agent run tests while another runs the linter
|
|
172
148
|
```
|
|
173
149
|
|
|
174
|
-
Each subagent gets its own terminal tagged with its `agentId`,
|
|
150
|
+
Each subagent gets its own terminal tagged with its `agentId`, keeping output separate and readable.
|
|
175
151
|
|
|
176
152
|
## Configuration
|
|
177
153
|
|
|
178
|
-
The extension reads configuration from VSCode settings under `bashterm-mcp-server
|
|
154
|
+
The extension reads configuration from VSCode settings under `bashterm-mcp-server.*`:
|
|
179
155
|
|
|
180
156
|
| Setting | Type | Default | Description |
|
|
181
157
|
|---------|------|---------|-------------|
|
|
182
|
-
| `bashterm-mcp-server
|
|
183
|
-
| `bashterm-mcp-server
|
|
184
|
-
| `bashterm-mcp-server
|
|
185
|
-
| `bashterm-mcp-server
|
|
186
|
-
| `bashterm-mcp-server
|
|
158
|
+
| `bashterm-mcp-server.maxSessions` | number | 10 | Maximum concurrent terminal sessions |
|
|
159
|
+
| `bashterm-mcp-server.commandTimeout` | number | 30000 | Default command timeout in ms |
|
|
160
|
+
| `bashterm-mcp-server.maxOutputLines` | number | 5000 | Max lines kept in output buffer per session |
|
|
161
|
+
| `bashterm-mcp-server.idleTimeout` | number | 1800000 | Close idle sessions after this many ms (0 = disabled) |
|
|
162
|
+
| `bashterm-mcp-server.blockedCommands` | string[] | `["rm -rf /"]` | Commands that will be rejected |
|
|
187
163
|
|
|
188
|
-
## Recommended
|
|
164
|
+
## Recommended
|
|
189
165
|
|
|
190
|
-
LLM agents
|
|
191
|
-
|
|
192
|
-
Add the following to your project's `CLAUDE.md` (or equivalent instructions file):
|
|
166
|
+
LLM agents include a built-in `Bash` tool that runs commands inline, embedding output in the conversation. Prefer BashTerm MCP for visible, scrollable terminal output. Add this to your project's `CLAUDE.md`:
|
|
193
167
|
|
|
194
168
|
```markdown
|
|
195
169
|
## Terminal Execution
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
Only fall back to the built-in Bash tool for simple, non-interactive operations like reading environment variables.
|
|
200
|
-
|
|
201
|
-
For commands that may take longer than 30 seconds or produce large amounts of output (builds, test suites,
|
|
202
|
-
deployments, installs), use the pull mode pattern:
|
|
203
|
-
1. Call `run` with `waitForCompletion: false` to launch the command without blocking.
|
|
204
|
-
2. Call `read` with `offset: -10` to check the last 10 lines of output.
|
|
205
|
-
3. Repeat step 2 until you see the command has finished (look for exit messages, prompts, or "Done").
|
|
206
|
-
4. Report the final result to the user.
|
|
207
|
-
|
|
208
|
-
This prevents conversation timeouts and lets the user watch progress in the terminal in real time.
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**Why this matters:**
|
|
212
|
-
|
|
213
|
-
| | Built-in Bash | BashTerm MCP |
|
|
214
|
-
|---|---|---|
|
|
215
|
-
| Output visibility | Embedded in chat, hard to scroll | Visible in VSCode terminal tab |
|
|
216
|
-
| Real-time feedback | User sees nothing until command finishes | User watches output live |
|
|
217
|
-
| Long-running commands | Blocks the conversation until timeout | Fire-and-forget + polling |
|
|
218
|
-
| Session state | Each command is isolated | Persistent sessions with history |
|
|
219
|
-
| Interactive commands | Not supported | Send input to prompts/REPLs |
|
|
220
|
-
|
|
221
|
-
## Development: Updating the Extension
|
|
222
|
-
|
|
223
|
-
VSCode aggressively caches extensions in memory. When developing locally, `code --install-extension` and even "Developer: Reload Window" may **not** reload your changes. Use this workflow:
|
|
224
|
-
|
|
225
|
-
### Quick update (no restart needed)
|
|
226
|
-
|
|
227
|
-
After modifying source files, build and copy directly into the installed extension directory:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
cd /path/to/bashterm-mcp-server-mcp
|
|
231
|
-
npm run build
|
|
232
|
-
cp dist/extension.js ~/.vscode/extensions/hcdb.bashterm-mcp-server-<version>/dist/extension.js
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
Then run **"Developer: Reload Window"** (`Ctrl+Shift+P`).
|
|
236
|
-
|
|
237
|
-
### Full reinstall (when quick update doesn't work)
|
|
238
|
-
|
|
239
|
-
If VSCode still uses old code:
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
# 1. Uninstall and remove all copies
|
|
243
|
-
code --uninstall-extension hcdb.bashterm
|
|
244
|
-
rm -rf ~/.vscode/extensions/hcdb.bashterm-mcp-server-*
|
|
245
|
-
|
|
246
|
-
# 2. Check for ghost entries with old publisher names
|
|
247
|
-
# Look in ~/.vscode/extensions/extensions.json for stale entries
|
|
248
|
-
# Remove any entries with old publisher IDs
|
|
249
|
-
|
|
250
|
-
# 3. Close VSCode completely (not just reload)
|
|
251
|
-
|
|
252
|
-
# 4. Rebuild and install
|
|
253
|
-
npm run build
|
|
254
|
-
npx vsce package --allow-missing-repository
|
|
255
|
-
code --install-extension bashterm-mcp-server-<version>.vsix --force
|
|
256
|
-
|
|
257
|
-
# 5. Open VSCode
|
|
170
|
+
Prefer the BashTerm MCP tools (`run`, `exec`, `read`, etc.) over the built-in Bash tool.
|
|
171
|
+
BashTerm runs commands in visible VSCode terminal tabs where you can see output in real time.
|
|
172
|
+
For commands over 30 seconds, use pull mode: `run` with `waitForCompletion: false`, then poll with `read` (`offset: -10`).
|
|
258
173
|
```
|
|
259
174
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
# Check which extension directories exist
|
|
264
|
-
ls ~/.vscode/extensions/ | grep terminal
|
|
265
|
-
|
|
266
|
-
# Verify your changes are in the installed extension
|
|
267
|
-
grep "YOUR_UNIQUE_STRING" ~/.vscode/extensions/hcdb.bashterm-mcp-server-*/dist/extension.js
|
|
268
|
-
|
|
269
|
-
# Compare checksums
|
|
270
|
-
md5sum dist/extension.js ~/.vscode/extensions/hcdb.bashterm-mcp-server-*/dist/extension.js
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Large Output Handling
|
|
274
|
-
|
|
275
|
-
When `read` returns output that exceeds the MCP client's token limit, the system automatically saves the full output to a temporary JSON file and returns the file path in the error message.
|
|
276
|
-
|
|
277
|
-
To extract the relevant content:
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
# Get the last 50 lines (most relevant for status)
|
|
281
|
-
tail -50 /path/to/saved/file.txt
|
|
282
|
-
|
|
283
|
-
# Or parse the JSON to extract the text content
|
|
284
|
-
python3 -c "import json; data=json.load(open('/path/to/file.txt')); print(data[0]['text'][-2000:])"
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
The file format is JSON: `[{"type": "text", "text": "..."}]`
|
|
288
|
-
|
|
289
|
-
This commonly happens with commands that produce heavy TUI output (progress bars, ANSI escape codes). Use smaller `offset` values (e.g., `offset: -20` instead of `offset: -100`) to reduce the captured output size.
|
|
290
|
-
|
|
291
|
-
## How It Works
|
|
292
|
-
|
|
293
|
-
1. The **VSCode extension** activates and starts an IPC server (Named Pipe on Windows, Unix socket on macOS/Linux)
|
|
294
|
-
2. The **MCP entry point** (`mcp-entry.js`) is spawned by the MCP client and bridges JSON-RPC stdio with the IPC socket
|
|
295
|
-
3. Commands execute via `child_process.exec()` for reliable cross-platform output capture and exit code detection
|
|
296
|
-
4. Output is stored in circular buffers with pagination support for efficient reading
|
|
297
|
-
|
|
298
|
-
## Latest Changes (0.2.0)
|
|
175
|
+
## Latest Changes (0.2.1)
|
|
299
176
|
|
|
300
|
-
- **
|
|
301
|
-
- **
|
|
302
|
-
- **Bug fixes**: Fixed duplicate output from Shell Integration + exec, negative buffer index, notification memory leak
|
|
303
|
-
- **Performance**: Batch buffer eviction replaces per-line shift (O(n×m) → O(n+m))
|
|
304
|
-
- **Better session reuse**: Now matches `env` and `shell` config when reusing terminals
|
|
305
|
-
- **Shell-ready detection**: Replaces hardcoded 500ms delay with proper detection + 2s fallback
|
|
306
|
-
- **Code cleanup**: Enabled CommandGuard, extracted shared formatting, dynamic version reading from package.json
|
|
177
|
+
- **Rename cleanup**: Unified all code, docs, and config references to BashTerm MCP — no more legacy names
|
|
178
|
+
- **Tag fix**: Corrected v0.2.0 tag to point to the proper release commit
|
|
307
179
|
|
|
308
180
|
See [CHANGELOG.md](CHANGELOG.md) for full history.
|
|
309
181
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,236 +1,183 @@
|
|
|
1
|
-
# BashTerm
|
|
2
|
-
|
|
3
|
-
[](README.md) [![
|
|
4
|
-
|
|
5
|
-
在 **VSCode 可见的终端标签页**中执行命令的 MCP
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
###
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
>
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
##
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
| `bashterm-mcp-server.blockedCommands` | string[] | `["rm -rf /"]` | 禁止执行的命令列表 |
|
|
185
|
-
|
|
186
|
-
## 推荐:设为优先工具
|
|
187
|
-
|
|
188
|
-
像 Claude Code 这样的 LLM 代理内置了 `Bash` 工具,会在聊天中内联执行命令。输出嵌入在对话中,难以阅读,尤其是输出冗长的命令。**建议告诉代理优先使用本 MCP 工具,而非内置 Bash 工具。**
|
|
189
|
-
|
|
190
|
-
将以下内容添加到项目的 `CLAUDE.md`(或等效指令文件)中:
|
|
191
|
-
|
|
192
|
-
```markdown
|
|
193
|
-
## 终端执行
|
|
194
|
-
|
|
195
|
-
优先使用 BashTerm MCP 工具(`run`、`exec`、`read` 等)来执行命令,而不是使用内置的 Bash 工具。
|
|
196
|
-
BashTerm 在可见的 VSCode 终端标签页中运行命令,用户可以实时查看输出。
|
|
197
|
-
仅在简单、非交互式操作(如读取环境变量)时回退到内置 Bash 工具。
|
|
198
|
-
|
|
199
|
-
对于可能超过 30 秒或产生大量输出的命令(构建、测试套件、部署、安装),使用 pull 模式:
|
|
200
|
-
1. 调用 `run` 设置 `waitForCompletion: false` 启动命令但不阻塞。
|
|
201
|
-
2. 调用 `read` 设置 `offset: -10` 查看最后 10 行输出。
|
|
202
|
-
3. 重复步骤 2 直到看到命令完成(查找退出消息、提示或 "Done")。
|
|
203
|
-
4. 向用户报告最终结果。
|
|
204
|
-
|
|
205
|
-
这样可以防止对话超时,并让用户实时观察终端进度。
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**为什么重要:**
|
|
209
|
-
|
|
210
|
-
| | 内置 Bash | BashTerm MCP |
|
|
211
|
-
|---|---|---|
|
|
212
|
-
| 输出可见性 | 嵌入聊天,难以滚动 | 在 VSCode 终端标签页中可见 |
|
|
213
|
-
| 实时反馈 | 用户看不到任何输出直到命令完成 | 用户实时观看输出 |
|
|
214
|
-
| 长时间命令 | 阻塞对话直到超时 | 发射后不管 + 轮询 |
|
|
215
|
-
| 会话状态 | 每个命令隔离 | 持久化会话,带历史 |
|
|
216
|
-
| 交互式命令 | 不支持 | 可向提示/REPL 发送输入 |
|
|
217
|
-
|
|
218
|
-
## 工作方式
|
|
219
|
-
|
|
220
|
-
1. **VSCode 扩展**激活并启动 IPC 服务器(Windows 上使用 Named Pipe,其他平台使用 Unix Socket)
|
|
221
|
-
2. **MCP 入口**(`mcp-entry.js`)由 MCP 客户端启动,在 JSON-RPC stdio 和 IPC socket 之间建立桥接
|
|
222
|
-
3. 命令通过 `child_process.exec()` 执行,输出直接捕获,不再依赖 Shell Integration API
|
|
223
|
-
4. 输出存储在循环缓冲区中,支持分页高效读取
|
|
224
|
-
|
|
225
|
-
## 最新更新 (0.1.8)
|
|
226
|
-
|
|
227
|
-
- **项目改名 bashterm-mcp**:全面清理旧名称 vscode-terminal-mcp 引用
|
|
228
|
-
- **修复 bin 路径**:更正 npm 二进制入口路径
|
|
229
|
-
- **动态版本图标**:badge 徽章现在反映实际版本号
|
|
230
|
-
- 中文 README 补充版本徽章
|
|
231
|
-
|
|
232
|
-
详见 [CHANGELOG.md](CHANGELOG.md) 查看完整历史。
|
|
233
|
-
|
|
234
|
-
## 许可证
|
|
235
|
-
|
|
236
|
-
MIT
|
|
1
|
+
# BashTerm
|
|
2
|
+
|
|
3
|
+
[](README.md) [](https://github.com/1170953489/bashterm-mcp/releases) [](https://www.npmjs.com/package/bashterm-mcp-server)
|
|
4
|
+
|
|
5
|
+
在 **VSCode 可见的终端标签页**中执行命令的 MCP 服务器——实时观看输出、滚动历史、按需交互。
|
|
6
|
+
|
|
7
|
+
## 核心功能
|
|
8
|
+
|
|
9
|
+
- **可见终端**:命令在真实的 VSCode 终端标签页中运行——实时观看输出、滚动历史、按需交互。
|
|
10
|
+
- **会话复用**:`run` 自动复用空闲会话,仅在必要时创建新终端。
|
|
11
|
+
- **非阻塞执行**:`waitForCompletion: false` 发射后不管,随后用 `read` 轮询。
|
|
12
|
+
- **子代理隔离**:通过 `agentId` 标记会话,将并行代理的工作负载隔离在独立终端中。
|
|
13
|
+
|
|
14
|
+
## 环境要求
|
|
15
|
+
|
|
16
|
+
- VS Code 1.93+
|
|
17
|
+
- Node.js 20+
|
|
18
|
+
|
|
19
|
+
## 快速开始
|
|
20
|
+
|
|
21
|
+
### Claude Code
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add BashTerm -- npx bashterm-mcp-server@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### VS Code / Copilot
|
|
28
|
+
|
|
29
|
+
在 `.vscode/mcp.json` 中添加:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"servers": {
|
|
34
|
+
"BashTerm": {
|
|
35
|
+
"type": "stdio",
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["bashterm-mcp-server@latest"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary>Cursor</summary>
|
|
45
|
+
|
|
46
|
+
在 `.cursor/mcp.json` 中添加:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"BashTerm": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "bashterm-mcp-server@latest"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
</details>
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>Claude Desktop</summary>
|
|
63
|
+
|
|
64
|
+
在 `claude_desktop_config.json` 中添加:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"BashTerm": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "bashterm-mcp-server@latest"]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
## 截图
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+

|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
## 工具
|
|
86
|
+
|
|
87
|
+
### 快速执行
|
|
88
|
+
|
|
89
|
+
| 工具 | 说明 |
|
|
90
|
+
|------|------|
|
|
91
|
+
| `run` | 一步创建(或复用)终端并执行命令,返回清洁输出和退出码。 |
|
|
92
|
+
|
|
93
|
+
### 会话管理
|
|
94
|
+
|
|
95
|
+
| 工具 | 说明 |
|
|
96
|
+
|------|------|
|
|
97
|
+
| `create` | 打开新的可见终端标签页,返回 `sessionId`。 |
|
|
98
|
+
| `exec` | 在已有会话中执行命令并捕获输出。 |
|
|
99
|
+
| `read` | 基于偏移量分页读取会话输出。使用 `offset: -N` 进入 tail 模式。 |
|
|
100
|
+
| `input` | 向交互式进程发送文本(回答提示、驱动 REPL、确认操作)。 |
|
|
101
|
+
| `list` | 列出活动会话,可按 `agentId` 过滤。 |
|
|
102
|
+
| `close` | 关闭会话及其终端标签页。 |
|
|
103
|
+
|
|
104
|
+
## 使用模式
|
|
105
|
+
|
|
106
|
+
### 简单命令
|
|
107
|
+
|
|
108
|
+
`run` 工具处理一切——按需创建终端、执行命令、返回清洁输出:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
> 运行 npm test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
$ npm test
|
|
116
|
+
PASS src/utils.test.ts (3 tests)
|
|
117
|
+
PASS src/index.test.ts (5 tests)
|
|
118
|
+
|
|
119
|
+
[exit: 0 | 1243ms | session-abc123]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 长时间运行
|
|
123
|
+
|
|
124
|
+
对于构建、部署或其他耗时命令:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
> 启动 npm run build 不等待,然后检查进度
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
代理使用 `waitForCompletion: false` 启动命令(立即返回),然后通过 `read`(`offset: -10`)轮询直到进程完成。
|
|
131
|
+
|
|
132
|
+
### 交互式命令
|
|
133
|
+
|
|
134
|
+
对于需要用户输入的命令:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
> 运行 npm init 并回答提示
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
代理使用 `run` 启动命令、`read` 查看提示、`input` 发送响应——逐步驱动交互式进程。
|
|
141
|
+
|
|
142
|
+
### 并行代理
|
|
143
|
+
|
|
144
|
+
子代理可以使用 `agentId` 在隔离的终端中工作:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
> 让一个代理运行测试,另一个运行代码检查
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
每个子代理获得独立的终端,标记其 `agentId`,保持输出分离且可读。
|
|
151
|
+
|
|
152
|
+
## 配置
|
|
153
|
+
|
|
154
|
+
扩展从 VSCode 设置中读取 `bashterm-mcp-server.*` 配置:
|
|
155
|
+
|
|
156
|
+
| 设置项 | 类型 | 默认值 | 说明 |
|
|
157
|
+
|--------|------|--------|------|
|
|
158
|
+
| `bashterm-mcp-server.maxSessions` | number | 10 | 最大并发终端会话数 |
|
|
159
|
+
| `bashterm-mcp-server.commandTimeout` | number | 30000 | 默认命令超时(毫秒) |
|
|
160
|
+
| `bashterm-mcp-server.maxOutputLines` | number | 5000 | 每个会话最大缓冲输出行数 |
|
|
161
|
+
| `bashterm-mcp-server.idleTimeout` | number | 1800000 | 空闲会话自动关闭时间(毫秒,0=禁用) |
|
|
162
|
+
| `bashterm-mcp-server.blockedCommands` | string[] | `["rm -rf /"]` | 禁止执行的命令列表 |
|
|
163
|
+
|
|
164
|
+
## 推荐
|
|
165
|
+
|
|
166
|
+
LLM 代理内置的 `Bash` 工具将输出内联在对话中,难以翻阅。建议优先使用 BashTerm MCP 在可见终端中执行命令。将以下内容添加到项目的 `CLAUDE.md`:
|
|
167
|
+
|
|
168
|
+
```markdown
|
|
169
|
+
## 终端执行
|
|
170
|
+
优先使用 BashTerm MCP 工具(`run`、`exec`、`read` 等),而非内置 Bash 工具。
|
|
171
|
+
对于超过 30 秒的命令,使用 pull 模式:`run` 设置 `waitForCompletion: false`,随后用 `read`(`offset: -10`)轮询。
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 最新更新 (0.2.1)
|
|
175
|
+
|
|
176
|
+
- **重命名清理**:统一所有代码、文档和配置中的项目名称为 BashTerm MCP,无遗留旧名
|
|
177
|
+
- **标签修复**:更正 v0.2.0 标签指向正确的发布 commit
|
|
178
|
+
|
|
179
|
+
完整历史见 [CHANGELOG.md](CHANGELOG.md)。
|
|
180
|
+
|
|
181
|
+
## 许可证
|
|
182
|
+
|
|
183
|
+
MIT
|
package/dist/extension.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "bashterm-mcp-server",
|
|
3
3
|
"displayName": "BashTerm MCP",
|
|
4
4
|
"description": "MCP server that executes commands in visible VSCode terminal tabs. Supports Windows, macOS and Linux.",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"publisher": "hcdb",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "hcdb",
|
package/server.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "io.github.hcdb/bashterm-mcp-server",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"description": "BashTerm MCP — execute commands in visible VSCode terminal tabs with output capture and session reuse.",
|
|
6
6
|
"author": "hcdb",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{
|
|
15
15
|
"registryType": "npm",
|
|
16
16
|
"identifier": "bashterm-mcp-server",
|
|
17
|
-
"version": "0.2.
|
|
17
|
+
"version": "0.2.1",
|
|
18
18
|
"transport": {
|
|
19
19
|
"type": "stdio"
|
|
20
20
|
}
|