Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

All notable changes to this project will be documented in this file.

## [1.2.0] - 2025-01-24

### Added

- New `cd` tool to change persistent working directory that persists across tool calls
- New `pwd` tool to get current persistent working directory
- Server-level state management for working directory within each Claude Desktop session
- `BASH_DEFAULT_CWD` to set default working directory at server startup
- `BASH_SHELL` for shell configuration with auto-detection of shell types (bash, PowerShell, cmd, etc.)
- Automatic shell command flag detection (e.g., `-c` for bash, `-Command` for PowerShell)
- Validation for `BASH_DEFAULT_CWD` with graceful fallback to current directory
- New `validateDirectory()` function with path validation
- Prevention of path traversal attacks
- Improved error messages for directory access issues

### Changed

- `run` and `run_background` tools now automatically use persistent working directory when no explicit `cwd` is provided
- Existing `cwd` parameters continue to work as overrides to persistent directory
- Enhanced path resolution supporting both absolute and relative paths
- Cross-platform compatibility improvements for Windows and Unix-like systems

### Fixed

- Shell variable expansion issues with commands like awk (e.g., `$2`, `$NF` now work correctly)
- Previous directory tracking now updates properly when changing directories

### Technical

- Server version updated to 1.2.0
- Comprehensive documentation updates with usage examples
- Backward compatibility maintained for all existing functionality

## [1.1.0] - 2025-06-28

### Added
Expand Down
66 changes: 62 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ kill_background("frontend")
list_background()
```

### `cd` - Change persistent working directory
```javascript
// Change to absolute path
cd("/path/to/directory")

// Change to relative path (relative to current persistent directory)
cd("../parent-directory")
cd("subdirectory")
```

### `pwd` - Get current persistent working directory
```javascript
pwd()
```

## Example Usage

```
Expand All @@ -88,7 +103,7 @@ Both servers are running successfully!

## Response Format

All tools return JSON formatted responses:
All process tools return JSON formatted responses:

```json
{
Expand Down Expand Up @@ -119,13 +134,17 @@ For background processes:
- Set working directory for commands
- Configure timeout for commands
- Automatic cleanup on server shutdown
- **NEW**: Automatic output truncation with full output saved to temp files
- **NEW**: Configurable output size limits and temp directory via environment variables
- Automatic output truncation with full output saved to temp files
- Configurable output size limits and temp directory via environment variables
- **NEW**: Persistent working directory across tool calls with `cd` and `pwd` commands
- **NEW**: Configurable default working directory via `BASH_DEFAULT_CWD` environment variable

## Environment Variables

- `BASH_MCP_MAX_OUTPUT_SIZE`: Maximum output size in bytes before truncation (default: 51200/50KB)
- `BASH_MCP_TEMP_DIR`: Directory for storing full output when truncated (default: system temp directory)
- `BASH_DEFAULT_CWD`: Default working directory for all commands (default: current directory at startup)
- `BASH_SHELL`: Shell to use for command execution (default: system default shell). Auto-detects shell type and adds appropriate execution flags (e.g., `-c` for bash, `-Command` for PowerShell)

### Example Configuration

Expand All @@ -137,13 +156,52 @@ For background processes:
"args": ["bash-mcp"],
"env": {
"BASH_MCP_MAX_OUTPUT_SIZE": "102400",
"BASH_MCP_TEMP_DIR": "/tmp/bash-mcp-outputs"
"BASH_MCP_TEMP_DIR": "/tmp/bash-mcp-outputs",
"BASH_DEFAULT_CWD": "/path/to/your/project",
"BASH_SHELL": "/bin/bash"
}
}
}
}
```

## Persistent Working Directory

The server now maintains a persistent working directory across tool calls within the same session:

- **Default Directory**: Set via `BASH_DEFAULT_CWD` environment variable, or current directory at startup
- **Change Directory**: Use the `cd` tool to change the persistent working directory
- **Check Directory**: Use the `pwd` tool to get the current persistent working directory
- **Auto-Use**: All `run` and `run_background` commands automatically use the persistent directory when no explicit `cwd` is provided
- **Override**: You can still override the persistent directory for individual commands by specifying the `cwd` parameter

### Example Workflow

```javascript
// Check current directory
pwd()
// → "/original/path"

// Change to project directory
cd("/path/to/my/project")
// → Success: Changed to /path/to/my/project

// Now all commands run from the project directory automatically
run("ls")
// → Lists contents of /path/to/my/project

run("npm test")
// → Runs tests in /path/to/my/project

// Move to subdirectory
cd("src")
// → Success: Changed to /path/to/my/project/src

// Still can override for individual commands
run("git status", { cwd: "/path/to/my/project" })
// → Runs git status in parent directory, not src
```

## Output Overflow Handling

When command output exceeds `BASH_MCP_MAX_OUTPUT_SIZE`:
Expand Down
Loading