just-bash-mcp 2.7.0 → 2.9.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.
Files changed (49) hide show
  1. package/README.md +58 -4
  2. package/package.json +24 -22
  3. package/src/config/index.ts +402 -0
  4. package/{build/index.js → src/index.ts} +12 -6
  5. package/src/just-bash-security.d.ts +705 -0
  6. package/src/tools/bash-instance.ts +212 -0
  7. package/src/tools/exec-tools.ts +165 -0
  8. package/src/tools/file-tools.ts +206 -0
  9. package/src/tools/index.ts +45 -0
  10. package/src/tools/info-tools.ts +175 -0
  11. package/src/tools/sandbox-tools.ts +217 -0
  12. package/src/types.ts +111 -0
  13. package/src/utils/index.ts +84 -0
  14. package/tsconfig.json +18 -0
  15. package/build/config/index.d.ts +0 -79
  16. package/build/config/index.d.ts.map +0 -1
  17. package/build/config/index.js +0 -178
  18. package/build/config/index.js.map +0 -1
  19. package/build/index.d.ts +0 -12
  20. package/build/index.d.ts.map +0 -1
  21. package/build/index.js.map +0 -1
  22. package/build/tools/bash-instance.d.ts +0 -26
  23. package/build/tools/bash-instance.d.ts.map +0 -1
  24. package/build/tools/bash-instance.js +0 -106
  25. package/build/tools/bash-instance.js.map +0 -1
  26. package/build/tools/exec-tools.d.ts +0 -10
  27. package/build/tools/exec-tools.d.ts.map +0 -1
  28. package/build/tools/exec-tools.js +0 -98
  29. package/build/tools/exec-tools.js.map +0 -1
  30. package/build/tools/file-tools.d.ts +0 -10
  31. package/build/tools/file-tools.d.ts.map +0 -1
  32. package/build/tools/file-tools.js +0 -171
  33. package/build/tools/file-tools.js.map +0 -1
  34. package/build/tools/index.d.ts +0 -15
  35. package/build/tools/index.d.ts.map +0 -1
  36. package/build/tools/index.js +0 -29
  37. package/build/tools/index.js.map +0 -1
  38. package/build/tools/info-tools.d.ts +0 -10
  39. package/build/tools/info-tools.d.ts.map +0 -1
  40. package/build/tools/info-tools.js +0 -95
  41. package/build/tools/info-tools.js.map +0 -1
  42. package/build/tools/sandbox-tools.d.ts +0 -10
  43. package/build/tools/sandbox-tools.d.ts.map +0 -1
  44. package/build/tools/sandbox-tools.js +0 -124
  45. package/build/tools/sandbox-tools.js.map +0 -1
  46. package/build/utils/index.d.ts +0 -52
  47. package/build/utils/index.d.ts.map +0 -1
  48. package/build/utils/index.js +0 -56
  49. package/build/utils/index.js.map +0 -1
@@ -1,178 +0,0 @@
1
- /**
2
- * Configuration module for just-bash-mcp
3
- * Handles environment variable parsing and configuration building
4
- */
5
- import { OverlayFs, ReadWriteFs, } from "just-bash";
6
- // ============================================================================
7
- // Environment Variable Parsing
8
- // ============================================================================
9
- function parseEnvString(key, defaultValue) {
10
- return process.env[key] || defaultValue;
11
- }
12
- function parseEnvBoolean(key, defaultValue) {
13
- return process.env[key] === "true" ? true : defaultValue;
14
- }
15
- function parseEnvInt(key, defaultValue) {
16
- const value = process.env[key];
17
- if (!value)
18
- return defaultValue;
19
- const parsed = Number.parseInt(value, 10);
20
- return Number.isNaN(parsed) ? defaultValue : parsed;
21
- }
22
- function parseEnvStringArray(key) {
23
- return process.env[key]?.split(",").filter(Boolean) || [];
24
- }
25
- function getAllowedMethods() {
26
- const methods = parseEnvStringArray("JUST_BASH_ALLOWED_METHODS");
27
- return methods.length > 0 ? methods : ["GET", "HEAD"];
28
- }
29
- function getAllowedCommands() {
30
- const commands = parseEnvStringArray("JUST_BASH_ALLOWED_COMMANDS");
31
- return commands.length > 0 ? commands : undefined;
32
- }
33
- export const config = {
34
- // Server info
35
- VERSION: "2.7.0",
36
- SERVER_NAME: "just-bash-mcp",
37
- // Filesystem configuration
38
- OVERLAY_ROOT: process.env.JUST_BASH_OVERLAY_ROOT,
39
- READ_WRITE_ROOT: process.env.JUST_BASH_READ_WRITE_ROOT,
40
- MOUNTS_CONFIG: process.env.JUST_BASH_MOUNTS,
41
- INITIAL_CWD: parseEnvString("JUST_BASH_CWD", "/home/user"),
42
- // Network configuration
43
- ALLOW_NETWORK: parseEnvBoolean("JUST_BASH_ALLOW_NETWORK", false),
44
- ALLOWED_URL_PREFIXES: parseEnvStringArray("JUST_BASH_ALLOWED_URLS"),
45
- ALLOWED_METHODS: getAllowedMethods(),
46
- MAX_REDIRECTS: parseEnvInt("JUST_BASH_MAX_REDIRECTS", 20),
47
- NETWORK_TIMEOUT_MS: parseEnvInt("JUST_BASH_NETWORK_TIMEOUT_MS", 30000),
48
- // Execution limits
49
- MAX_CALL_DEPTH: parseEnvInt("JUST_BASH_MAX_CALL_DEPTH", 100),
50
- MAX_COMMAND_COUNT: parseEnvInt("JUST_BASH_MAX_COMMAND_COUNT", 10000),
51
- MAX_LOOP_ITERATIONS: parseEnvInt("JUST_BASH_MAX_LOOP_ITERATIONS", 10000),
52
- MAX_SQLITE_TIMEOUT_MS: parseEnvInt("JUST_BASH_MAX_SQLITE_TIMEOUT_MS", 5000),
53
- MAX_PYTHON_TIMEOUT_MS: parseEnvInt("JUST_BASH_MAX_PYTHON_TIMEOUT_MS", 30000),
54
- // Output limits
55
- MAX_OUTPUT_LENGTH: parseEnvInt("JUST_BASH_MAX_OUTPUT_LENGTH", 30000),
56
- // Debugging
57
- ENABLE_LOGGING: parseEnvBoolean("JUST_BASH_ENABLE_LOGGING", false),
58
- ENABLE_TRACING: parseEnvBoolean("JUST_BASH_ENABLE_TRACING", false),
59
- // Command filtering
60
- ALLOWED_COMMANDS: getAllowedCommands(),
61
- };
62
- // ============================================================================
63
- // Logger and Trace Callback
64
- // ============================================================================
65
- export const bashLogger = config.ENABLE_LOGGING
66
- ? {
67
- info(message, data) {
68
- console.error(`[just-bash] INFO: ${message}`, data || "");
69
- },
70
- debug(message, data) {
71
- console.error(`[just-bash] DEBUG: ${message}`, data || "");
72
- },
73
- }
74
- : undefined;
75
- export const traceCallback = config.ENABLE_TRACING
76
- ? (event) => {
77
- console.error(`[just-bash] TRACE: ${event.category}/${event.name} ${event.durationMs}ms`, event.details ? JSON.stringify(event.details) : "");
78
- }
79
- : undefined;
80
- // ============================================================================
81
- // Configuration Builders
82
- // ============================================================================
83
- export function buildNetworkConfig() {
84
- if (!config.ALLOW_NETWORK) {
85
- return undefined;
86
- }
87
- if (config.ALLOWED_URL_PREFIXES.length > 0) {
88
- return {
89
- allowedUrlPrefixes: config.ALLOWED_URL_PREFIXES,
90
- allowedMethods: config.ALLOWED_METHODS,
91
- maxRedirects: config.MAX_REDIRECTS,
92
- timeoutMs: config.NETWORK_TIMEOUT_MS,
93
- };
94
- }
95
- return {
96
- dangerouslyAllowFullInternetAccess: true,
97
- maxRedirects: config.MAX_REDIRECTS,
98
- timeoutMs: config.NETWORK_TIMEOUT_MS,
99
- };
100
- }
101
- export function buildExecutionLimits() {
102
- return {
103
- maxCallDepth: config.MAX_CALL_DEPTH,
104
- maxCommandCount: config.MAX_COMMAND_COUNT,
105
- maxLoopIterations: config.MAX_LOOP_ITERATIONS,
106
- maxAwkIterations: config.MAX_LOOP_ITERATIONS,
107
- maxSedIterations: config.MAX_LOOP_ITERATIONS,
108
- maxJqIterations: config.MAX_LOOP_ITERATIONS,
109
- maxSqliteTimeoutMs: config.MAX_SQLITE_TIMEOUT_MS,
110
- maxPythonTimeoutMs: config.MAX_PYTHON_TIMEOUT_MS,
111
- };
112
- }
113
- export function parseMountsConfig() {
114
- if (!config.MOUNTS_CONFIG)
115
- return [];
116
- try {
117
- const parsed = JSON.parse(config.MOUNTS_CONFIG);
118
- if (!Array.isArray(parsed))
119
- return [];
120
- return parsed.map((mount) => {
121
- const fsType = mount.type || "overlay";
122
- const filesystem = fsType === "readwrite"
123
- ? new ReadWriteFs({ root: mount.root })
124
- : new OverlayFs({ root: mount.root });
125
- return { mountPoint: mount.mountPoint, filesystem };
126
- });
127
- }
128
- catch {
129
- return [];
130
- }
131
- }
132
- // ============================================================================
133
- // Environment Variables Documentation
134
- // ============================================================================
135
- export const ENVIRONMENT_VARIABLES = {
136
- JUST_BASH_OVERLAY_ROOT: "Real directory to mount as overlay (read from disk, write to memory)",
137
- JUST_BASH_READ_WRITE_ROOT: "Real directory with read-write access",
138
- JUST_BASH_MOUNTS: "JSON array of mount configurations",
139
- JUST_BASH_CWD: "Initial working directory (default: /home/user)",
140
- JUST_BASH_ALLOW_NETWORK: "Enable network access (default: false)",
141
- JUST_BASH_ALLOWED_URLS: "Comma-separated URL prefixes to allow",
142
- JUST_BASH_ALLOWED_METHODS: "Comma-separated HTTP methods (default: GET,HEAD)",
143
- JUST_BASH_ALLOWED_COMMANDS: "Comma-separated list of allowed commands",
144
- JUST_BASH_MAX_REDIRECTS: "Max HTTP redirects (default: 20)",
145
- JUST_BASH_NETWORK_TIMEOUT_MS: "Network timeout (default: 30000)",
146
- JUST_BASH_MAX_CALL_DEPTH: "Max recursion depth (default: 100)",
147
- JUST_BASH_MAX_COMMAND_COUNT: "Max commands per execution (default: 10000)",
148
- JUST_BASH_MAX_LOOP_ITERATIONS: "Max loop iterations (default: 10000)",
149
- JUST_BASH_MAX_SQLITE_TIMEOUT_MS: "SQLite timeout (default: 5000)",
150
- JUST_BASH_MAX_PYTHON_TIMEOUT_MS: "Python timeout (default: 30000)",
151
- JUST_BASH_MAX_OUTPUT_LENGTH: "Max output length (default: 30000)",
152
- JUST_BASH_ENABLE_LOGGING: "Enable debug logging (default: false)",
153
- JUST_BASH_ENABLE_TRACING: "Enable performance tracing (default: false)",
154
- };
155
- // ============================================================================
156
- // Command Categories Documentation
157
- // ============================================================================
158
- export const COMMAND_CATEGORIES = {
159
- fileOperations: "cat, cp, file, ln, ls, mkdir, mv, readlink, rm, rmdir, split, stat, touch, tree",
160
- textProcessing: "awk, base64, column, comm, cut, diff, expand, fold, grep (egrep, fgrep), head, join, md5sum, nl, od, paste, printf, rev, rg (ripgrep), sed, sha1sum, sha256sum, sort, strings, tac, tail, tr, unexpand, uniq, wc, xargs",
161
- dataProcessing: "jq (JSON), python3/python (Python via Pyodide), sqlite3 (SQLite), xan (CSV), yq (YAML/XML/TOML/CSV)",
162
- compression: "gzip (gunzip, zcat), tar",
163
- navigation: "basename, cd, dirname, du, echo, env, export, find, hostname, printenv, pwd, tee, whoami",
164
- shellUtilities: "alias, bash, chmod, clear, date, expr, false, help, history, seq, sh, sleep, time, timeout, true, unalias, which",
165
- network: "curl, html-to-markdown (when network enabled)",
166
- };
167
- // ============================================================================
168
- // Features Documentation
169
- // ============================================================================
170
- export const FEATURES = {
171
- customCommands: "Define custom TypeScript commands using defineCommand()",
172
- rawScript: "Preserve leading whitespace in scripts (useful for here-docs)",
173
- logger: "Optional execution logging via BashLogger interface",
174
- trace: "Performance profiling via TraceCallback",
175
- commandFilter: "Restrict available commands via JUST_BASH_ALLOWED_COMMANDS env var",
176
- sandboxApi: "Vercel Sandbox compatible API via bash_sandbox_* tools",
177
- };
178
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAQN,SAAS,EACT,WAAW,GACX,MAAM,WAAW,CAAC;AAwBnB,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E,SAAS,cAAc,CAAC,GAAW,EAAE,YAAoB;IACxD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC;AACzC,CAAC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,YAAqB;IAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,YAAoB;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,YAAY,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,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AC;AAEX,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,cAAc,EACb,iFAAiF;IAClF,cAAc,EACb,yNAAyN;IAC1N,cAAc,EACb,qGAAqG;IACtG,WAAW,EAAE,0BAA0B;IACvC,UAAU,EACT,0FAA0F;IAC3F,cAAc,EACb,kHAAkH;IACnH,OAAO,EAAE,+CAA+C;CAC/C,CAAC;AAEX,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,cAAc,EAAE,yDAAyD;IACzE,SAAS,EAAE,+DAA+D;IAC1E,MAAM,EAAE,qDAAqD;IAC7D,KAAK,EAAE,yCAAyC;IAChD,aAAa,EACZ,oEAAoE;IACrE,UAAU,EAAE,wDAAwD;CAC3D,CAAC"}
package/build/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * just-bash-mcp - MCP Server for sandboxed bash execution
4
- *
5
- * A Model Context Protocol (MCP) server that provides AI agents with a
6
- * secure, sandboxed bash environment powered by just-bash from Vercel Labs.
7
- *
8
- * @see https://github.com/vercel-labs/just-bash
9
- * @see https://modelcontextprotocol.io
10
- */
11
- export {};
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC,OAAO;CACvB,CAAC,CAAC;AAEH,qCAAqC;AACrC,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEzB,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,OAAO,CAAC,KAAK,CACZ,GAAG,MAAM,CAAC,WAAW,YAAY,MAAM,CAAC,OAAO,mBAAmB,CAClE,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Bash instance management
3
- * Handles creation and lifecycle of Bash instances
4
- */
5
- import { Bash, type CustomCommand, Sandbox } from "just-bash";
6
- /**
7
- * Create a new Bash instance with the given configuration
8
- */
9
- export declare function createBashInstance(files?: Record<string, string>, customCommands?: CustomCommand[], env?: Record<string, string>): Bash;
10
- /**
11
- * Get or create the persistent Bash instance
12
- */
13
- export declare function getPersistentBash(): Bash;
14
- /**
15
- * Reset the persistent Bash instance
16
- */
17
- export declare function resetPersistentBash(): void;
18
- /**
19
- * Get or create the persistent Sandbox instance
20
- */
21
- export declare function getPersistentSandbox(): Promise<Sandbox>;
22
- /**
23
- * Reset the persistent Sandbox instance
24
- */
25
- export declare function resetPersistentSandbox(): void;
26
- //# sourceMappingURL=bash-instance.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bash-instance.d.ts","sourceRoot":"","sources":["../../src/tools/bash-instance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,IAAI,EAEJ,KAAK,aAAa,EAKlB,OAAO,EAEP,MAAM,WAAW,CAAC;AAenB;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,cAAc,CAAC,EAAE,aAAa,EAAE,EAChC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,IAAI,CAsDN;AAQD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAQD;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAU7D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -1,106 +0,0 @@
1
- /**
2
- * Bash instance management
3
- * Handles creation and lifecycle of Bash instances
4
- */
5
- import { Bash, InMemoryFs, MountableFs, OverlayFs, ReadWriteFs, Sandbox, } from "just-bash";
6
- import { bashLogger, buildExecutionLimits, buildNetworkConfig, config, parseMountsConfig, traceCallback, } from "../config/index.js";
7
- // ============================================================================
8
- // Bash Instance Factory
9
- // ============================================================================
10
- /**
11
- * Create a new Bash instance with the given configuration
12
- */
13
- export function createBashInstance(files, customCommands, env) {
14
- const networkConfig = buildNetworkConfig();
15
- const executionLimits = buildExecutionLimits();
16
- const baseOptions = {
17
- network: networkConfig,
18
- executionLimits,
19
- files,
20
- env,
21
- logger: bashLogger,
22
- trace: traceCallback,
23
- customCommands,
24
- commands: config.ALLOWED_COMMANDS,
25
- };
26
- // Check for mountable filesystem configuration
27
- const mounts = parseMountsConfig();
28
- if (mounts.length > 0) {
29
- const mountableFs = new MountableFs({
30
- base: new InMemoryFs(),
31
- mounts,
32
- });
33
- return new Bash({
34
- ...baseOptions,
35
- fs: mountableFs,
36
- cwd: config.INITIAL_CWD,
37
- });
38
- }
39
- // Check for read-write filesystem configuration
40
- if (config.READ_WRITE_ROOT) {
41
- const rwfs = new ReadWriteFs({ root: config.READ_WRITE_ROOT });
42
- return new Bash({
43
- ...baseOptions,
44
- fs: rwfs,
45
- cwd: config.READ_WRITE_ROOT,
46
- });
47
- }
48
- // Check for overlay filesystem configuration
49
- if (config.OVERLAY_ROOT) {
50
- const overlay = new OverlayFs({ root: config.OVERLAY_ROOT });
51
- return new Bash({
52
- ...baseOptions,
53
- fs: overlay,
54
- cwd: overlay.getMountPoint(),
55
- });
56
- }
57
- // Default: in-memory filesystem
58
- return new Bash({
59
- ...baseOptions,
60
- cwd: config.INITIAL_CWD,
61
- });
62
- }
63
- // ============================================================================
64
- // Persistent Bash Instance (singleton pattern)
65
- // ============================================================================
66
- let persistentBash = null;
67
- /**
68
- * Get or create the persistent Bash instance
69
- */
70
- export function getPersistentBash() {
71
- if (!persistentBash) {
72
- persistentBash = createBashInstance();
73
- }
74
- return persistentBash;
75
- }
76
- /**
77
- * Reset the persistent Bash instance
78
- */
79
- export function resetPersistentBash() {
80
- persistentBash = null;
81
- }
82
- // ============================================================================
83
- // Persistent Sandbox Instance (singleton pattern)
84
- // ============================================================================
85
- let persistentSandbox = null;
86
- /**
87
- * Get or create the persistent Sandbox instance
88
- */
89
- export async function getPersistentSandbox() {
90
- if (!persistentSandbox) {
91
- const networkConfig = buildNetworkConfig();
92
- const options = {
93
- cwd: config.INITIAL_CWD,
94
- network: networkConfig,
95
- };
96
- persistentSandbox = await Sandbox.create(options);
97
- }
98
- return persistentSandbox;
99
- }
100
- /**
101
- * Reset the persistent Sandbox instance
102
- */
103
- export function resetPersistentSandbox() {
104
- persistentSandbox = null;
105
- }
106
- //# sourceMappingURL=bash-instance.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bash-instance.js","sourceRoot":"","sources":["../../src/tools/bash-instance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,IAAI,EAGJ,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,OAAO,GAEP,MAAM,WAAW,CAAC;AAEnB,OAAO,EACN,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,EACN,iBAAiB,EACjB,aAAa,GACb,M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7D,OAAO,IAAI,IAAI,CAAC;YACf,GAAG,WAAW;YACd,EAAE,EAAE,OAAO;YACX,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE;SAC5B,CAAC,CAAC;IACJ,CAAC;IAED,gCAAgC;IAChC,OAAO,IAAI,IAAI,CAAC;QACf,GAAG,WAAW;QACd,GAAG,EAAE,MAAM,CAAC,WAAW;KACvB,CAAC,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;AAE/E,IAAI,cAAc,GAAgB,IAAI,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAChC,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,cAAc,GAAG,kBAAkB,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAClC,cAAc,GAAG,IAAI,CAAC;AACvB,CAAC;AAED,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAE/E,IAAI,iBAAiB,GAAmB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACxB,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAmB;YAC/B,GAAG,EAAE,MAAM,CAAC,WAAW;YACvB,OAAO,EAAE,aAAa;SACtB,CAAC;QACF,iBAAiB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACrC,iBAAiB,GAAG,IAAI,CAAC;AAC1B,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Bash execution tools
3
- * Core tools for executing bash commands
4
- */
5
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
- /**
7
- * Register bash execution tools with the MCP server
8
- */
9
- export declare function registerExecTools(server: McpServer): void;
10
- //# sourceMappingURL=exec-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exec-tools.d.ts","sourceRoot":"","sources":["../../src/tools/exec-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmIzD"}
@@ -1,98 +0,0 @@
1
- /**
2
- * Bash execution tools
3
- * Core tools for executing bash commands
4
- */
5
- import { z } from "zod/v4";
6
- import { createErrorResponse, formatExecResult } from "../utils/index.js";
7
- import { createBashInstance, getPersistentBash, resetPersistentBash, } from "./bash-instance.js";
8
- /**
9
- * Register bash execution tools with the MCP server
10
- */
11
- export function registerExecTools(server) {
12
- // ========================================================================
13
- // bash_exec - Isolated execution
14
- // ========================================================================
15
- server.registerTool("bash_exec", {
16
- 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).",
17
- inputSchema: {
18
- command: z.string().describe("The bash command to execute"),
19
- cwd: z
20
- .string()
21
- .optional()
22
- .describe("Working directory for the command"),
23
- env: z
24
- .record(z.string(), z.string())
25
- .optional()
26
- .describe("Environment variables to set for execution"),
27
- initialEnv: z
28
- .record(z.string(), z.string())
29
- .optional()
30
- .describe("Initial environment variables to set when creating the bash instance"),
31
- files: z
32
- .record(z.string(), z.string())
33
- .optional()
34
- .describe("Files to create before execution (path -> content)"),
35
- rawScript: z
36
- .boolean()
37
- .optional()
38
- .describe("If true, skip normalizing the script (preserves leading whitespace). Useful for here-docs."),
39
- },
40
- }, async ({ command, cwd, env, initialEnv, files, rawScript, }) => {
41
- try {
42
- const bash = createBashInstance(files, undefined, initialEnv);
43
- const result = await bash.exec(command, { cwd, env, rawScript });
44
- return formatExecResult(result);
45
- }
46
- catch (error) {
47
- return createErrorResponse(error, "Execution error");
48
- }
49
- });
50
- // ========================================================================
51
- // bash_exec_persistent - Persistent execution
52
- // ========================================================================
53
- server.registerTool("bash_exec_persistent", {
54
- 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.",
55
- inputSchema: {
56
- command: z.string().describe("The bash command to execute"),
57
- cwd: z
58
- .string()
59
- .optional()
60
- .describe("Working directory for the command"),
61
- env: z
62
- .record(z.string(), z.string())
63
- .optional()
64
- .describe("Environment variables to set"),
65
- rawScript: z
66
- .boolean()
67
- .optional()
68
- .describe("If true, skip normalizing the script (preserves leading whitespace). Useful for here-docs."),
69
- },
70
- }, async ({ command, cwd, env, rawScript, }) => {
71
- try {
72
- const bash = getPersistentBash();
73
- const result = await bash.exec(command, { cwd, env, rawScript });
74
- return formatExecResult(result);
75
- }
76
- catch (error) {
77
- return createErrorResponse(error, "Execution error");
78
- }
79
- });
80
- // ========================================================================
81
- // bash_reset - Reset persistent environment
82
- // ========================================================================
83
- server.registerTool("bash_reset", {
84
- description: "Reset the persistent bash environment, clearing all files and state.",
85
- inputSchema: {},
86
- }, async () => {
87
- resetPersistentBash();
88
- return {
89
- content: [
90
- {
91
- type: "text",
92
- text: "Persistent bash environment has been reset.",
93
- },
94
- ],
95
- };
96
- });
97
- }
98
- //# sourceMappingURL=exec-tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exec-tools.js","sourceRoot":"","sources":["../../src/tools/exec-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAClD,2EAA2E;IAC3E,iCAAi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W,EACV,sEAAsE;QACvE,WAAW,EAAE,EAAE;KACf,EACD,KAAK,IAAI,EAAE;QACV,mBAAmB,EAAE,CAAC;QACtB,OAAO;YACN,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,6CAA6C;iBACnD;aACD;SACD,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * File operation tools
3
- * Tools for reading, writing, and listing files in the bash environment
4
- */
5
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
- /**
7
- * Register file operation tools with the MCP server
8
- */
9
- export declare function registerFileTools(server: McpServer): void;
10
- //# sourceMappingURL=file-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkNzD"}
@@ -1,171 +0,0 @@
1
- /**
2
- * File operation tools
3
- * Tools for reading, writing, and listing files in the bash environment
4
- */
5
- import { z } from "zod/v4";
6
- import { config } from "../config/index.js";
7
- import { createErrorResponse, createSuccessResponse, truncateOutput, } from "../utils/index.js";
8
- import { getPersistentBash } from "./bash-instance.js";
9
- /**
10
- * Register file operation tools with the MCP server
11
- */
12
- export function registerFileTools(server) {
13
- // ========================================================================
14
- // bash_write_file - Write file via shell
15
- // ========================================================================
16
- server.registerTool("bash_write_file", {
17
- description: "Write content to a file in the persistent bash environment.",
18
- inputSchema: {
19
- path: z.string().describe("The file path to write to"),
20
- content: z.string().describe("The content to write"),
21
- },
22
- }, async ({ path, content }) => {
23
- try {
24
- const bash = getPersistentBash();
25
- const escapedContent = content.replace(/'/g, "'\\''");
26
- const result = await bash.exec(`mkdir -p "$(dirname '${path}')" && cat > '${path}' << 'JUST_BASH_EOF'\n${escapedContent}\nJUST_BASH_EOF`);
27
- if (result.exitCode !== 0) {
28
- return {
29
- content: [
30
- {
31
- type: "text",
32
- text: `Failed to write file: ${result.stderr}`,
33
- },
34
- ],
35
- isError: true,
36
- };
37
- }
38
- return createSuccessResponse(`Successfully wrote ${content.length} bytes to ${path}`);
39
- }
40
- catch (error) {
41
- return createErrorResponse(error, "Write error");
42
- }
43
- });
44
- // ========================================================================
45
- // bash_read_file - Read file via shell
46
- // ========================================================================
47
- server.registerTool("bash_read_file", {
48
- description: "Read content from a file in the persistent bash environment.",
49
- inputSchema: {
50
- path: z.string().describe("The file path to read"),
51
- },
52
- }, async ({ path }) => {
53
- try {
54
- const bash = getPersistentBash();
55
- const result = await bash.exec(`cat '${path}'`);
56
- if (result.exitCode !== 0) {
57
- return {
58
- content: [
59
- {
60
- type: "text",
61
- text: `Failed to read file: ${result.stderr}`,
62
- },
63
- ],
64
- isError: true,
65
- };
66
- }
67
- return {
68
- content: [
69
- {
70
- type: "text",
71
- text: truncateOutput(result.stdout, config.MAX_OUTPUT_LENGTH, "stdout"),
72
- },
73
- ],
74
- };
75
- }
76
- catch (error) {
77
- return createErrorResponse(error, "Read error");
78
- }
79
- });
80
- // ========================================================================
81
- // bash_list_files - List files
82
- // ========================================================================
83
- server.registerTool("bash_list_files", {
84
- description: "List files and directories in the persistent bash environment.",
85
- inputSchema: {
86
- path: z
87
- .string()
88
- .optional()
89
- .describe("The directory path to list (defaults to current directory)"),
90
- recursive: z
91
- .boolean()
92
- .optional()
93
- .describe("Whether to list recursively"),
94
- showHidden: z
95
- .boolean()
96
- .optional()
97
- .describe("Whether to show hidden files"),
98
- },
99
- }, async ({ path = ".", recursive = false, showHidden = false, }) => {
100
- try {
101
- const bash = getPersistentBash();
102
- let cmd;
103
- if (recursive) {
104
- cmd = showHidden
105
- ? `find '${path}' -type f`
106
- : `find '${path}' -type f ! -name '.*' ! -path '*/.*'`;
107
- }
108
- else {
109
- cmd = showHidden ? `ls -la '${path}'` : `ls -l '${path}'`;
110
- }
111
- const result = await bash.exec(cmd);
112
- return {
113
- content: [
114
- {
115
- type: "text",
116
- text: result.stdout || "(empty directory)",
117
- },
118
- ],
119
- isError: result.exitCode !== 0,
120
- };
121
- }
122
- catch (error) {
123
- return createErrorResponse(error, "List error");
124
- }
125
- });
126
- // ========================================================================
127
- // bash_direct_read - Direct filesystem read
128
- // ========================================================================
129
- server.registerTool("bash_direct_read", {
130
- description: "Read a file directly from the persistent bash filesystem (without running cat).",
131
- inputSchema: {
132
- path: z.string().describe("The file path to read"),
133
- },
134
- }, async ({ path }) => {
135
- try {
136
- const bash = getPersistentBash();
137
- const content = await bash.readFile(path);
138
- return {
139
- content: [
140
- {
141
- type: "text",
142
- text: truncateOutput(content, config.MAX_OUTPUT_LENGTH, "stdout"),
143
- },
144
- ],
145
- };
146
- }
147
- catch (error) {
148
- return createErrorResponse(error, "Read error");
149
- }
150
- });
151
- // ========================================================================
152
- // bash_direct_write - Direct filesystem write
153
- // ========================================================================
154
- server.registerTool("bash_direct_write", {
155
- description: "Write a file directly to the persistent bash filesystem (without running shell commands).",
156
- inputSchema: {
157
- path: z.string().describe("The file path to write"),
158
- content: z.string().describe("The content to write"),
159
- },
160
- }, async ({ path, content }) => {
161
- try {
162
- const bash = getPersistentBash();
163
- await bash.writeFile(path, content);
164
- return createSuccessResponse(`Successfully wrote ${content.length} bytes to ${path}`);
165
- }
166
- catch (error) {
167
- return createErrorResponse(error, "Write error");
168
- }
169
- });
170
- }
171
- //# sourceMappingURL=file-tools.js.map