local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Supports .env file configuration for environment-specific settings of the MCP server
Command-Line MCP Server
A secure Model Control Protocol (MCP) server that allows AI assistants to execute terminal commands with controlled directory access and command permissions.
Overview
Command-Line MCP provides a security layer between AI assistants and your terminal. It implements a dual security model:
- Command Permissions: Commands are categorized as read (safe), write (changes data), or system (affects system state), with different approval requirements
- Directory Permissions: Commands can only access explicitly whitelisted directories or directories approved during a session
AI assistants interact with this server using standardized MCP tools, enabling safe terminal command execution while preventing access to sensitive files or dangerous operations. You can configure the security level from highly restrictive to more permissive based on your needs.
Key Features
Security | Usability | Integration |
---|---|---|
Directory whitelisting | Command categorization (read/write/system) | Claude Desktop compatibility |
Command filtering | Persistent session permissions | Standard MCP protocol |
Pattern matching | Command chaining (pipes, etc.) | Auto-approval options |
Dangerous command blocking | Intuitive approval workflow | Multiple config methods |
Supported Commands (out of the box)
Read Commands
ls
,pwd
,cat
,less
,head
,tail
,grep
,find
,which
,du
,df
,file
,sort
, etc.
Write Commands
cp
,mv
,rm
,mkdir
,rmdir
,touch
,chmod
,chown
, etc.
System Commands
ps
,top
,htop
,who
,netstat
,ifconfig
,ping
, etc.
Security Architecture
The system implements a multi-layered security approach:
All security features can be configured from restrictive to permissive based on your threat model and convenience requirements.
Quick Start
Configuration Options
The server supports four configuration methods in order of precedence:
- Built-in default configuration (default_config.json)
- JSON configuration file (recommended for customization)Copy
- Environment variables (for specific overrides)Copy
- .env file (for environment-specific settings)Copy
The default configuration is stored in default_config.json
and is included with the package. You can copy this file to create your own custom configuration.
Core Configuration Settings
Environment Variable Format
Environment variables use a predictable naming pattern:
Examples:
Claude Desktop Integration
Setup
- Install Claude for Desktop
- Configure in
~/Library/Application Support/Claude/claude_desktop_config.json
:
Recommended Claude Desktop Settings
For best experience, configure:
require_session_id: false
- Essential to prevent approval loopsauto_approve_directories_in_desktop_mode: true
- Optional for convenient access- Include common directories in your whitelist
After configuration, restart Claude for Desktop.
AI Assistant Tools
The server provides these MCP tools for AI assistants:
Tool | Purpose | Needs Approval |
---|---|---|
execute_command | Run any command type | Yes, for write/system commands |
execute_read_command | Run read-only commands | Directory approval only |
approve_directory | Grant access to a directory | N/A - it's an approval tool |
approve_command_type | Grant permission for command category | N/A - it's an approval tool |
list_directories | Show authorized directories | No |
list_available_commands | Show command categories | No |
get_command_help | Get command usage guidance | No |
get_configuration | View current settings | No |
Tool Examples
Directory Management
Command Execution
Get Configuration
Directory Security System
The server restricts command execution to specific directories, preventing access to sensitive files.
Directory Security Modes
The system supports three security modes:
Mode | Description | Best For | Configuration |
---|---|---|---|
Strict | Only whitelisted directories allowed | Maximum security | auto_approve_directories_in_desktop_mode: false |
Approval | Non-whitelisted directories require explicit approval | Interactive use | Default behavior for standard clients |
Auto-approve | Auto-approves directories for Claude Desktop | Convenience | auto_approve_directories_in_desktop_mode: true |
Whitelisted Directory Configuration
Directory Approval Flow
- Command is requested in a directory
- System checks:
- Is the directory in the global whitelist? → Allow
- Has directory been approved in this session? → Allow
- Neither? → Request approval
- After approval, directory remains approved for the entire session
Path Format Support
- Absolute paths:
/home/user/documents
- Home directory:
~
(expands to user's home) - User subdirectories:
~/Downloads
Claude Desktop Integration
The server maintains a persistent session for Claude Desktop, ensuring directory approvals persist between requests and preventing approval loops.
Command Customization
The system uses command categorization to control access:
Category | Description | Example Commands | Requires Approval |
---|---|---|---|
Read | Safe operations | ls, cat, find | No |
Write | Data modification | mkdir, rm, touch | Yes |
System | System operations | ps, ping, ifconfig | Yes |
Blocked | Dangerous commands | sudo, bash, eval | Always denied |
Customization Methods
Environment Variable Method:
The MCP server merges these additions with existing commands, letting you extend functionality without recreating complete command lists.
Command Chaining
The server supports three command chaining methods:
Method | Symbol | Example | Config Setting |
---|---|---|---|
Pipes | | | ls | grep txt | allow_command_separators: true |
Sequence | ; | mkdir dir; cd dir | allow_command_separators: true |
Background | & | find . -name "*.log" & | allow_command_separators: true |
All commands in a chain must be from the supported command list. Security checks apply to the entire chain.
Quick Configuration:
To disable specific separators, add them to the dangerous_patterns
list.
License
MIT
This server cannot be installed
Allows AI assistants to safely execute common Unix/macOS terminal commands through a controlled interface with comprehensive security features.