just-bash-mcp 1.0.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 ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 dalist1
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # just-bash-mcp
2
+
3
+ [![npm version](https://badge.fury.io/js/just-bash-mcp.svg)](https://www.npmjs.com/package/just-bash-mcp)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+
6
+ An MCP (Model Context Protocol) server that provides a sandboxed bash environment using [just-bash](https://github.com/vercel-labs/just-bash).
7
+
8
+ This server allows AI agents to execute bash commands in a secure, isolated environment with an in-memory virtual filesystem.
9
+
10
+ ## Features
11
+
12
+ - **Sandboxed Execution**: Commands run in an isolated virtual filesystem
13
+ - **Stateless & Stateful Modes**: Choose between isolated executions or persistent filesystem
14
+ - **Network Access Control**: Optional network access with URL allow-lists
15
+ - **Execution Limits**: Protection against infinite loops and deep recursion
16
+ - **OverlayFS Support**: Mount real directories as read-only with copy-on-write
17
+
18
+ ## Installation
19
+
20
+ ### From npm (recommended)
21
+
22
+ ```bash
23
+ # Using npm
24
+ npm install -g just-bash-mcp
25
+
26
+ # Using pnpm
27
+ pnpm add -g just-bash-mcp
28
+
29
+ # Using yarn
30
+ yarn global add just-bash-mcp
31
+ ```
32
+
33
+ ### From source
34
+
35
+ ```bash
36
+ git clone https://github.com/dalist1/just-bash-mcp.git
37
+ cd just-bash-mcp
38
+ npm install
39
+ npm run build
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Running the Server
45
+
46
+ ```bash
47
+ # If installed globally
48
+ just-bash-mcp
49
+
50
+ # From source with npm
51
+ npm start
52
+
53
+ # From source with npm (development)
54
+ npm run dev
55
+ ```
56
+
57
+ ## MCP Client Configuration
58
+
59
+ ### Using npx (no installation required)
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "just-bash": {
65
+ "command": "npx",
66
+ "args": ["-y", "just-bash-mcp"],
67
+ "env": {
68
+ "JUST_BASH_ALLOW_NETWORK": "false"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ### Claude Desktop
76
+
77
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "just-bash": {
83
+ "command": "npx",
84
+ "args": ["-y", "just-bash-mcp"],
85
+ "env": {
86
+ "JUST_BASH_ALLOW_NETWORK": "false"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Cursor
94
+
95
+ Add to your Cursor MCP settings (Settings → MCP Servers):
96
+
97
+ ```json
98
+ {
99
+ "mcpServers": {
100
+ "just-bash": {
101
+ "command": "npx",
102
+ "args": ["-y", "just-bash-mcp"],
103
+ "env": {
104
+ "JUST_BASH_ALLOW_NETWORK": "false"
105
+ }
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### VS Code (Roo Code / Cline)
112
+
113
+ Add to your MCP settings file:
114
+ - **Roo Code**: `~/.config/Code/User/globalStorage/rooveterinaryinc.roo-code/settings/mcp_settings.json`
115
+ - **Cline**: `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
116
+
117
+ ```json
118
+ {
119
+ "mcpServers": {
120
+ "just-bash": {
121
+ "command": "npx",
122
+ "args": ["-y", "just-bash-mcp"],
123
+ "env": {
124
+ "JUST_BASH_ALLOW_NETWORK": "false"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Windsurf
132
+
133
+ Add to your Windsurf MCP configuration:
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "just-bash": {
139
+ "command": "npx",
140
+ "args": ["-y", "just-bash-mcp"],
141
+ "env": {
142
+ "JUST_BASH_ALLOW_NETWORK": "false"
143
+ }
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ ### Using Global Installation
150
+
151
+ If you've installed globally, you can use the binary directly:
152
+
153
+ ```json
154
+ {
155
+ "mcpServers": {
156
+ "just-bash": {
157
+ "command": "just-bash-mcp",
158
+ "env": {
159
+ "JUST_BASH_ALLOW_NETWORK": "false"
160
+ }
161
+ }
162
+ }
163
+ }
164
+ ```
165
+
166
+ ### Using Local Installation
167
+
168
+ For development or local installations:
169
+
170
+ ```json
171
+ {
172
+ "mcpServers": {
173
+ "just-bash": {
174
+ "command": "node",
175
+ "args": ["/path/to/just-bash-mcp/build/index.js"],
176
+ "env": {
177
+ "JUST_BASH_ALLOW_NETWORK": "false"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ ## Environment Variables
185
+
186
+ | Variable | Description | Default |
187
+ |----------|-------------|---------|
188
+ | `JUST_BASH_CWD` | Initial working directory | `/home/user` |
189
+ | `JUST_BASH_OVERLAY_ROOT` | Real directory to mount as overlay (read-only) | - |
190
+ | `JUST_BASH_ALLOW_NETWORK` | Enable network access (`true`/`false`) | `false` |
191
+ | `JUST_BASH_ALLOWED_URLS` | Comma-separated URL prefixes to allow | - |
192
+ | `JUST_BASH_ALLOWED_METHODS` | Comma-separated HTTP methods to allow | `GET,HEAD` |
193
+ | `JUST_BASH_MAX_CALL_DEPTH` | Maximum function recursion depth | `100` |
194
+ | `JUST_BASH_MAX_COMMAND_COUNT` | Maximum total commands per execution | `10000` |
195
+ | `JUST_BASH_MAX_LOOP_ITERATIONS` | Maximum iterations per loop | `10000` |
196
+
197
+ ## Tools
198
+
199
+ ### `bash_exec`
200
+
201
+ Execute a bash command in a sandboxed environment. Each execution is isolated.
202
+
203
+ **Parameters:**
204
+ - `command` (required): The bash command to execute
205
+ - `cwd` (optional): Working directory for the command
206
+ - `env` (optional): Environment variables to set
207
+ - `files` (optional): Files to create before execution (path → content)
208
+
209
+ **Example:**
210
+ ```json
211
+ {
212
+ "name": "bash_exec",
213
+ "arguments": {
214
+ "command": "echo 'Hello World' && ls -la",
215
+ "files": {
216
+ "/tmp/data.json": "{\"key\": \"value\"}"
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ ### `bash_exec_persistent`
223
+
224
+ Execute a bash command in a persistent sandboxed environment. The filesystem persists across calls.
225
+
226
+ **Parameters:**
227
+ - `command` (required): The bash command to execute
228
+ - `cwd` (optional): Working directory for the command
229
+ - `env` (optional): Environment variables to set
230
+
231
+ ### `bash_reset`
232
+
233
+ Reset the persistent bash environment, clearing all files and state.
234
+
235
+ ### `bash_write_file`
236
+
237
+ Write content to a file in the persistent bash environment.
238
+
239
+ **Parameters:**
240
+ - `path` (required): The file path to write to
241
+ - `content` (required): The content to write
242
+
243
+ ### `bash_read_file`
244
+
245
+ Read content from a file in the persistent bash environment.
246
+
247
+ **Parameters:**
248
+ - `path` (required): The file path to read
249
+
250
+ ### `bash_list_files`
251
+
252
+ List files and directories in the persistent bash environment.
253
+
254
+ **Parameters:**
255
+ - `path` (optional): Directory path to list (defaults to `.`)
256
+ - `recursive` (optional): Whether to list recursively
257
+ - `showHidden` (optional): Whether to show hidden files
258
+
259
+ ### `bash_info`
260
+
261
+ Get information about the bash environment configuration.
262
+
263
+ ## Supported Commands
264
+
265
+ ### File Operations
266
+ `cat`, `cp`, `ln`, `ls`, `mkdir`, `mv`, `readlink`, `rm`, `stat`, `touch`, `tree`
267
+
268
+ ### Text Processing
269
+ `awk`, `base64`, `cut`, `diff`, `grep`, `head`, `jq`, `printf`, `sed`, `sort`, `tail`, `tr`, `uniq`, `wc`, `xargs`
270
+
271
+ ### Navigation & Environment
272
+ `basename`, `cd`, `dirname`, `du`, `echo`, `env`, `export`, `find`, `printenv`, `pwd`, `tee`
273
+
274
+ ### Shell Utilities
275
+ `alias`, `bash`, `chmod`, `clear`, `date`, `expr`, `false`, `help`, `history`, `seq`, `sh`, `sleep`, `timeout`, `true`, `unalias`, `which`
276
+
277
+ ### Network Commands (when enabled)
278
+ `curl`, `html-to-markdown`
279
+
280
+ ## Shell Features
281
+
282
+ - Pipes: `cmd1 | cmd2`
283
+ - Redirections: `>`, `>>`, `2>`, `2>&1`, `<`
284
+ - Command chaining: `&&`, `||`, `;`
285
+ - Variables: `$VAR`, `${VAR}`, `${VAR:-default}`
286
+ - Positional parameters: `$1`, `$2`, `$@`, `$#`
287
+ - Glob patterns: `*`, `?`, `[...]`
288
+ - If statements: `if COND; then CMD; elif COND; then CMD; else CMD; fi`
289
+ - Functions: `function name { ... }` or `name() { ... }`
290
+ - Local variables: `local VAR=value`
291
+ - Loops: `for`, `while`, `until`
292
+ - Symbolic links: `ln -s target link`
293
+ - Hard links: `ln target link`
294
+
295
+ ## Network Access Examples
296
+
297
+ ### Allow specific URLs (safest)
298
+
299
+ ```json
300
+ {
301
+ "env": {
302
+ "JUST_BASH_ALLOW_NETWORK": "true",
303
+ "JUST_BASH_ALLOWED_URLS": "https://api.github.com,https://api.example.com/v1/"
304
+ }
305
+ }
306
+ ```
307
+
308
+ ### Allow specific URLs with POST
309
+
310
+ ```json
311
+ {
312
+ "env": {
313
+ "JUST_BASH_ALLOW_NETWORK": "true",
314
+ "JUST_BASH_ALLOWED_URLS": "https://api.example.com",
315
+ "JUST_BASH_ALLOWED_METHODS": "GET,HEAD,POST"
316
+ }
317
+ }
318
+ ```
319
+
320
+ ### Full internet access (use with caution)
321
+
322
+ ```json
323
+ {
324
+ "env": {
325
+ "JUST_BASH_ALLOW_NETWORK": "true"
326
+ }
327
+ }
328
+ ```
329
+
330
+ ## OverlayFS Example
331
+
332
+ Mount a real project directory as read-only:
333
+
334
+ ```json
335
+ {
336
+ "env": {
337
+ "JUST_BASH_OVERLAY_ROOT": "/path/to/your/project"
338
+ }
339
+ }
340
+ ```
341
+
342
+ The agent can read files from the real filesystem, but all writes stay in memory.
343
+
344
+ ## Security Model
345
+
346
+ - The shell only has access to the provided virtual filesystem
347
+ - Execution is protected against infinite loops and deep recursion
348
+ - No binary or WASM execution support
349
+ - Network access is disabled by default
350
+ - When enabled, network requests are checked against URL and HTTP method allow-lists
351
+
352
+ ## Development
353
+
354
+ ```bash
355
+ # Clone the repository
356
+ git clone https://github.com/dalist1/just-bash-mcp.git
357
+ cd just-bash-mcp
358
+
359
+ # Install dependencies
360
+ npm install
361
+
362
+ # Run in development mode
363
+ npm run dev
364
+
365
+ # Type check
366
+ npm run typecheck
367
+
368
+ # Build for production
369
+ npm run build
370
+
371
+ # Test the server
372
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | npm run dev
373
+ ```
374
+
375
+ ## Publishing
376
+
377
+ ```bash
378
+ # Build the package
379
+ npm run build
380
+
381
+ # Publish to npm
382
+ npm publish
383
+ ```
384
+
385
+ ## License
386
+
387
+ Apache-2.0 (same as [just-bash](https://github.com/vercel-labs/just-bash))
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview MCP server providing a sandboxed bash environment using just-bash.
4
+ * @author dalist1
5
+ * @license Apache-2.0
6
+ * @see https://github.com/dalist1/just-bash-mcp
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
package/build/index.js ADDED
@@ -0,0 +1,394 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview MCP server providing a sandboxed bash environment using just-bash.
4
+ * @author dalist1
5
+ * @license Apache-2.0
6
+ * @see https://github.com/dalist1/just-bash-mcp
7
+ */
8
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
+ import { z } from "zod";
11
+ import { Bash, OverlayFs } from "just-bash";
12
+ // ============================================================================
13
+ // Configuration from environment variables
14
+ // ============================================================================
15
+ /** Path to real directory for overlay filesystem (read-only mount) */
16
+ const OVERLAY_ROOT = process.env.JUST_BASH_OVERLAY_ROOT;
17
+ /** Initial working directory for bash environment */
18
+ const INITIAL_CWD = process.env.JUST_BASH_CWD || "/home/user";
19
+ /** Whether network access is enabled */
20
+ const ALLOW_NETWORK = process.env.JUST_BASH_ALLOW_NETWORK === "true";
21
+ /** Comma-separated list of allowed URL prefixes */
22
+ const ALLOWED_URL_PREFIXES = process.env.JUST_BASH_ALLOWED_URLS?.split(",").filter(Boolean) || [];
23
+ /** Allowed HTTP methods for network requests */
24
+ const ALLOWED_METHODS = (process.env.JUST_BASH_ALLOWED_METHODS?.split(",").filter(Boolean) || ["GET", "HEAD"]);
25
+ // ============================================================================
26
+ // Execution limits from environment
27
+ // ============================================================================
28
+ /** Maximum function call/recursion depth */
29
+ const MAX_CALL_DEPTH = parseInt(process.env.JUST_BASH_MAX_CALL_DEPTH || "100", 10);
30
+ /** Maximum number of commands per execution */
31
+ const MAX_COMMAND_COUNT = parseInt(process.env.JUST_BASH_MAX_COMMAND_COUNT || "10000", 10);
32
+ /** Maximum loop iterations */
33
+ const MAX_LOOP_ITERATIONS = parseInt(process.env.JUST_BASH_MAX_LOOP_ITERATIONS || "10000", 10);
34
+ // ============================================================================
35
+ // MCP Server Setup
36
+ // ============================================================================
37
+ /** MCP server instance */
38
+ const server = new McpServer({
39
+ name: "just-bash-mcp",
40
+ version: "1.0.0",
41
+ });
42
+ /**
43
+ * Builds the network configuration based on environment variables.
44
+ * @returns Network configuration object or undefined if network is disabled
45
+ */
46
+ function buildNetworkConfig() {
47
+ if (!ALLOW_NETWORK) {
48
+ return undefined;
49
+ }
50
+ if (ALLOWED_URL_PREFIXES.length > 0) {
51
+ return {
52
+ allowedUrlPrefixes: ALLOWED_URL_PREFIXES,
53
+ allowedMethods: ALLOWED_METHODS,
54
+ };
55
+ }
56
+ // Full internet access if ALLOW_NETWORK is true but no prefixes specified
57
+ return { dangerouslyAllowFullInternetAccess: true };
58
+ }
59
+ /**
60
+ * Builds the execution limits configuration.
61
+ * @returns Execution limits object with all limit values
62
+ */
63
+ function buildExecutionLimits() {
64
+ return {
65
+ maxCallDepth: MAX_CALL_DEPTH,
66
+ maxCommandCount: MAX_COMMAND_COUNT,
67
+ maxLoopIterations: MAX_LOOP_ITERATIONS,
68
+ maxAwkIterations: MAX_LOOP_ITERATIONS,
69
+ maxSedIterations: MAX_LOOP_ITERATIONS,
70
+ };
71
+ }
72
+ /**
73
+ * Creates a new Bash instance with optional overlay filesystem.
74
+ * @param files - Optional initial files to create in the filesystem
75
+ * @returns Configured Bash instance
76
+ */
77
+ function createBashInstance(files) {
78
+ const networkConfig = buildNetworkConfig();
79
+ const executionLimits = buildExecutionLimits();
80
+ if (OVERLAY_ROOT) {
81
+ const overlay = new OverlayFs({ root: OVERLAY_ROOT });
82
+ return new Bash({
83
+ fs: overlay,
84
+ cwd: overlay.getMountPoint(),
85
+ network: networkConfig,
86
+ executionLimits,
87
+ files,
88
+ });
89
+ }
90
+ return new Bash({
91
+ cwd: INITIAL_CWD,
92
+ network: networkConfig,
93
+ executionLimits,
94
+ files,
95
+ });
96
+ }
97
+ // ============================================================================
98
+ // Persistent Bash Instance
99
+ // ============================================================================
100
+ /** Persistent bash instance for stateful operations */
101
+ let persistentBash = null;
102
+ /**
103
+ * Gets or creates the persistent Bash instance.
104
+ * @returns The persistent Bash instance
105
+ */
106
+ function getPersistentBash() {
107
+ if (!persistentBash) {
108
+ persistentBash = createBashInstance();
109
+ }
110
+ return persistentBash;
111
+ }
112
+ // ============================================================================
113
+ // Tool Definitions
114
+ // ============================================================================
115
+ /**
116
+ * Tool: bash_exec
117
+ * Execute a bash command in a sandboxed environment.
118
+ * Each execution is isolated - environment variables, functions, and cwd don't persist.
119
+ */
120
+ server.registerTool("bash_exec", {
121
+ description: "Execute a bash command in a sandboxed environment. Each execution is isolated - environment variables, functions, and cwd don't persist across calls (filesystem does).",
122
+ inputSchema: {
123
+ command: z.string().describe("The bash command to execute"),
124
+ cwd: z.string().optional().describe("Working directory for the command"),
125
+ env: z.record(z.string(), z.string()).optional().describe("Environment variables to set"),
126
+ files: z.record(z.string(), z.string()).optional().describe("Files to create before execution (path -> content)"),
127
+ },
128
+ }, async ({ command, cwd, env, files }) => {
129
+ try {
130
+ const bash = createBashInstance(files);
131
+ const result = await bash.exec(command, { cwd, env });
132
+ return {
133
+ content: [
134
+ {
135
+ type: "text",
136
+ text: JSON.stringify({
137
+ stdout: result.stdout,
138
+ stderr: result.stderr,
139
+ exitCode: result.exitCode,
140
+ env: result.env,
141
+ }, null, 2),
142
+ },
143
+ ],
144
+ isError: result.exitCode !== 0,
145
+ };
146
+ }
147
+ catch (error) {
148
+ return {
149
+ content: [
150
+ {
151
+ type: "text",
152
+ text: `Execution error: ${error instanceof Error ? error.message : String(error)}`,
153
+ },
154
+ ],
155
+ isError: true,
156
+ };
157
+ }
158
+ });
159
+ /**
160
+ * Tool: bash_exec_persistent
161
+ * Execute a bash command in a persistent sandboxed environment.
162
+ * The filesystem persists across calls, but env vars, functions, and cwd are reset.
163
+ */
164
+ server.registerTool("bash_exec_persistent", {
165
+ description: "Execute a bash command in a persistent sandboxed environment. The filesystem persists across calls, but env vars, functions, and cwd are reset each call.",
166
+ inputSchema: {
167
+ command: z.string().describe("The bash command to execute"),
168
+ cwd: z.string().optional().describe("Working directory for the command"),
169
+ env: z.record(z.string(), z.string()).optional().describe("Environment variables to set"),
170
+ },
171
+ }, async ({ command, cwd, env }) => {
172
+ try {
173
+ const bash = getPersistentBash();
174
+ const result = await bash.exec(command, { cwd, env });
175
+ return {
176
+ content: [
177
+ {
178
+ type: "text",
179
+ text: JSON.stringify({
180
+ stdout: result.stdout,
181
+ stderr: result.stderr,
182
+ exitCode: result.exitCode,
183
+ env: result.env,
184
+ }, null, 2),
185
+ },
186
+ ],
187
+ isError: result.exitCode !== 0,
188
+ };
189
+ }
190
+ catch (error) {
191
+ return {
192
+ content: [
193
+ {
194
+ type: "text",
195
+ text: `Execution error: ${error instanceof Error ? error.message : String(error)}`,
196
+ },
197
+ ],
198
+ isError: true,
199
+ };
200
+ }
201
+ });
202
+ /**
203
+ * Tool: bash_reset
204
+ * Reset the persistent bash environment, clearing all files and state.
205
+ */
206
+ server.registerTool("bash_reset", {
207
+ description: "Reset the persistent bash environment, clearing all files and state.",
208
+ inputSchema: {},
209
+ }, async () => {
210
+ persistentBash = null;
211
+ return {
212
+ content: [
213
+ {
214
+ type: "text",
215
+ text: "Persistent bash environment has been reset.",
216
+ },
217
+ ],
218
+ };
219
+ });
220
+ /**
221
+ * Tool: bash_write_file
222
+ * Write content to a file in the persistent bash environment.
223
+ */
224
+ server.registerTool("bash_write_file", {
225
+ description: "Write content to a file in the persistent bash environment.",
226
+ inputSchema: {
227
+ path: z.string().describe("The file path to write to"),
228
+ content: z.string().describe("The content to write"),
229
+ },
230
+ }, async ({ path, content }) => {
231
+ try {
232
+ const bash = getPersistentBash();
233
+ const result = await bash.exec(`cat > '${path}' << 'JUST_BASH_EOF'\n${content}\nJUST_BASH_EOF`);
234
+ if (result.exitCode !== 0) {
235
+ return {
236
+ content: [
237
+ {
238
+ type: "text",
239
+ text: `Failed to write file: ${result.stderr}`,
240
+ },
241
+ ],
242
+ isError: true,
243
+ };
244
+ }
245
+ return {
246
+ content: [
247
+ {
248
+ type: "text",
249
+ text: `Successfully wrote ${content.length} bytes to ${path}`,
250
+ },
251
+ ],
252
+ };
253
+ }
254
+ catch (error) {
255
+ return {
256
+ content: [
257
+ {
258
+ type: "text",
259
+ text: `Write error: ${error instanceof Error ? error.message : String(error)}`,
260
+ },
261
+ ],
262
+ isError: true,
263
+ };
264
+ }
265
+ });
266
+ /**
267
+ * Tool: bash_read_file
268
+ * Read content from a file in the persistent bash environment.
269
+ */
270
+ server.registerTool("bash_read_file", {
271
+ description: "Read content from a file in the persistent bash environment.",
272
+ inputSchema: {
273
+ path: z.string().describe("The file path to read"),
274
+ },
275
+ }, async ({ path }) => {
276
+ try {
277
+ const bash = getPersistentBash();
278
+ const result = await bash.exec(`cat '${path}'`);
279
+ if (result.exitCode !== 0) {
280
+ return {
281
+ content: [
282
+ {
283
+ type: "text",
284
+ text: `Failed to read file: ${result.stderr}`,
285
+ },
286
+ ],
287
+ isError: true,
288
+ };
289
+ }
290
+ return {
291
+ content: [
292
+ {
293
+ type: "text",
294
+ text: result.stdout,
295
+ },
296
+ ],
297
+ };
298
+ }
299
+ catch (error) {
300
+ return {
301
+ content: [
302
+ {
303
+ type: "text",
304
+ text: `Read error: ${error instanceof Error ? error.message : String(error)}`,
305
+ },
306
+ ],
307
+ isError: true,
308
+ };
309
+ }
310
+ });
311
+ /**
312
+ * Tool: bash_list_files
313
+ * List files and directories in the persistent bash environment.
314
+ */
315
+ server.registerTool("bash_list_files", {
316
+ description: "List files and directories in the persistent bash environment.",
317
+ inputSchema: {
318
+ path: z.string().optional().describe("The directory path to list (defaults to current directory)"),
319
+ recursive: z.boolean().optional().describe("Whether to list recursively"),
320
+ showHidden: z.boolean().optional().describe("Whether to show hidden files"),
321
+ },
322
+ }, async ({ path = ".", recursive = false, showHidden = false }) => {
323
+ try {
324
+ const bash = getPersistentBash();
325
+ let cmd = "ls -l";
326
+ if (showHidden)
327
+ cmd += "a";
328
+ if (recursive)
329
+ cmd = `find '${path}' -type f`;
330
+ else
331
+ cmd += ` '${path}'`;
332
+ const result = await bash.exec(cmd);
333
+ return {
334
+ content: [
335
+ {
336
+ type: "text",
337
+ text: result.stdout || "(empty directory)",
338
+ },
339
+ ],
340
+ isError: result.exitCode !== 0,
341
+ };
342
+ }
343
+ catch (error) {
344
+ return {
345
+ content: [
346
+ {
347
+ type: "text",
348
+ text: `List error: ${error instanceof Error ? error.message : String(error)}`,
349
+ },
350
+ ],
351
+ isError: true,
352
+ };
353
+ }
354
+ });
355
+ /**
356
+ * Tool: bash_info
357
+ * Get information about the bash environment configuration.
358
+ */
359
+ server.registerTool("bash_info", {
360
+ description: "Get information about the bash environment configuration.",
361
+ inputSchema: {},
362
+ }, async () => {
363
+ const info = {
364
+ overlayRoot: OVERLAY_ROOT || null,
365
+ initialCwd: INITIAL_CWD,
366
+ networkEnabled: ALLOW_NETWORK,
367
+ allowedUrlPrefixes: ALLOWED_URL_PREFIXES.length > 0 ? ALLOWED_URL_PREFIXES : null,
368
+ allowedMethods: ALLOW_NETWORK ? ALLOWED_METHODS : null,
369
+ executionLimits: buildExecutionLimits(),
370
+ supportedCommands: [
371
+ "File Operations: cat, cp, ln, ls, mkdir, mv, readlink, rm, stat, touch, tree",
372
+ "Text Processing: awk, base64, cut, diff, grep, head, jq, printf, sed, sort, tail, tr, uniq, wc, xargs",
373
+ "Navigation & Environment: basename, cd, dirname, du, echo, env, export, find, printenv, pwd, tee",
374
+ "Shell Utilities: alias, bash, chmod, clear, date, expr, false, help, history, seq, sh, sleep, timeout, true, unalias, which",
375
+ "Network Commands (if enabled): curl, html-to-markdown",
376
+ ],
377
+ };
378
+ return {
379
+ content: [
380
+ {
381
+ type: "text",
382
+ text: JSON.stringify(info, null, 2),
383
+ },
384
+ ],
385
+ };
386
+ });
387
+ // ============================================================================
388
+ // Server Startup
389
+ // ============================================================================
390
+ /** Start the MCP server with stdio transport */
391
+ const transport = new StdioServerTransport();
392
+ await server.connect(transport);
393
+ console.error("just-bash-mcp server running on stdio");
394
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAsB,MAAM,WAAW,CAAC;AAKhE,+EAA+E;AAC/E,2CAA2C;AAC3C,+EAA+E;AAE/E,sEAAsE;AACtE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;AAExD,qDAAqD;AACrD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,YAAY,CAAC;AAE9D,wCAAwC;AACxC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,MAAM,CAAC;AAErE,mDAAmD;AACnD,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,sBA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ChC,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "just-bash-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server providing a sandboxed bash environment using just-bash",
5
+ "type": "module",
6
+ "main": "./build/index.js",
7
+ "types": "./build/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./build/index.d.ts",
11
+ "import": "./build/index.js"
12
+ }
13
+ },
14
+ "bin": {
15
+ "just-bash-mcp": "build/index.js"
16
+ },
17
+ "files": [
18
+ "build",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "start": "node build/index.js",
25
+ "dev": "npx tsx src/index.ts",
26
+ "typecheck": "tsc --noEmit",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "keywords": [
30
+ "mcp",
31
+ "model-context-protocol",
32
+ "bash",
33
+ "sandbox",
34
+ "shell",
35
+ "ai",
36
+ "agent",
37
+ "claude",
38
+ "cursor",
39
+ "cline",
40
+ "roo-code",
41
+ "windsurf"
42
+ ],
43
+ "author": "dalist1",
44
+ "license": "Apache-2.0",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/dalist1/just-bash-mcp.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/dalist1/just-bash-mcp/issues"
51
+ },
52
+ "homepage": "https://github.com/dalist1/just-bash-mcp#readme",
53
+ "engines": {
54
+ "node": ">=18.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@modelcontextprotocol/sdk": "^1.25.1",
58
+ "just-bash": "^1.0.1",
59
+ "zod": "^4.2.1"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^25.0.3",
63
+ "typescript": "^5.9.3"
64
+ }
65
+ }