A comprehensive, security-focused MCP (Model Context Protocol) TypeScript SDK server that provides safe terminal command execution capabilities for Claude Desktop. This server implements enterprise-grade security controls following all MCP security requirements.
The easiest way to use this server is with npx - no installation required!
- Node.js 18+
- Claude Desktop
Simply add the server to your Claude Desktop configuration using npx:
Claude Desktop Configuration: ~/.claude_desktop_config.json (macOS) or %APPDATA%/Claude/claude_desktop_config.json (Windows)
{
"servers": {
"secure-terminal": {
"command": "npx",
"args": ["@modelcontextprotocol/mcp-terminal-server"]
}
}
}That's it! Claude Desktop will automatically download and run the server when needed.
If you prefer to install globally:
npm install -g @modelcontextprotocol/mcp-terminal-serverThen configure Claude Desktop:
{
"servers": {
"secure-terminal": {
"command": "mcp-terminal-server"
}
}
}This server addresses all major security requirements and threat vectors identified in the MCP security documentation:
- β Mandatory code signing - Ready for production deployment
- β Static tool definitions - Tools cannot be changed at runtime
- β Security tested interfaces - Comprehensive validation and sanitization
- β Package identity - Clear provenance and version control
- β Privilege declarations - Explicit capability requirements
- β Cross-Prompt Injection (XPIA) - Input sanitization and validation
- β Authentication Gaps - Rate limiting and client identification
- β Credential Leakage - Output sanitization and credential filtering
- β Tool Poisoning - Strict command whitelist enforcement
- β Lack of Containment - Process isolation and resource limits
- β Command Injection - Comprehensive input validation
- β Limited Security Review - Extensive security testing
- Command Whitelist: Only pre-approved, safe commands allowed
- Input Sanitization: All inputs validated and sanitized
- Output Filtering: Credentials and sensitive data automatically redacted
- Rate Limiting: Risk-based rate limiting with progressive blocking
- Audit Logging: Comprehensive security event logging
- Path Traversal Protection: Directory access restrictions
- Timeout Enforcement: Commands automatically terminated
- Process Isolation: Secure environment for command execution
Safely list directory contents with security validation.
Parameters:
- path (optional): Directory path to list
- includeHidden (optional): Include hidden files
- longFormat (optional): Use detailed listing
Get the current working directory.
Execute commands from the security whitelist.
Parameters:
- command: Command to execute (must be whitelisted)
- args (optional): Command arguments
- workingDirectory (optional): Working directory
Safely read file contents with size limits.
Parameters:
- filePath: Path to file
- maxLines (optional): Maximum lines to read (default: 100)
Get Git repository status.
Parameters:
- workingDirectory (optional): Git repository path
- short (optional): Use short format
Count lines, words, or characters in files.
Parameters:
- filePath: Path to file
- countType (optional): 'lines', 'words', or 'characters'
Get basic system information.
Parameters:
- infoType (optional): 'user', 'os', or 'system'
Lists all whitelisted commands with descriptions and risk levels.
Shows security status including rate limits and blocking status.
Displays server capabilities and security features.
The server only allows execution of pre-approved commands:
ls- Directory listingpwd- Current directorytree- Directory treewc- Word/line/character countwhich- Command locationuname- System informationwhoami- Current user
cat,head,tail- File reading (with restrictions)git status,git log,git branch,git diff- Git operationsnpm list,npm outdated- Package information
npm audit- Security vulnerability check (limited rate)
All dangerous commands are explicitly forbidden:
- File modification:
rm,mv,cp,chmod - System administration:
sudo,su,systemctl - Network operations:
curl,wget,ssh - Script execution:
python,node,bash - And many more...
The server implements sophisticated rate limiting:
- 100 commands per minute across all tools
- Progressive blocking for violations
- Low Risk: 50 executions/minute
- Medium Risk: 20 executions/minute
- High Risk: 5 executions/minute
- 10 failed attempts per 5 minutes
- 3 suspicious activities per hour
- Automatic blocking and logging
When running, the server creates logs in the current directory:
logs/security-audit.log- All security eventslogs/security-alerts.log- High-risk events onlylogs/combined.log- General application logslogs/error.log- Error events
# Watch security events
tail -f logs/security-audit.log
# Check for alerts
tail -f logs/security-alerts.log
# Monitor rate limiting
grep "RATE_LIMIT_EXCEEDED" logs/security-audit.logOnce configured with Claude Desktop, you can ask Claude to:
- List directories: "Show me the files in the current directory"
- Check Git status: "What's the status of this Git repository?"
- Read files safely: "Show me the first 50 lines of package.json"
- Get system info: "What user am I running as?"
- Execute safe commands: "Run 'npm list' to show installed packages"
- Check security status: "Show me the current security status"
-
Clone and setup
git clone https://github.com/luiscnext/mcp-terminal-server.git cd mcp-terminal-server npm install -
Build and test
npm run build npm test npm run test:security -
Run locally
npm run dev
npm run build- Build TypeScript to JavaScriptnpm run dev- Development mode with auto-reloadnpm test- Run security testsnpm run lint- Code lintingnpm run format- Code formatting
To publish this package to npm:
-
Build and test
npm run build npm test -
Login to npm
npm login
-
Publish
npm publish
The package is configured with proper publishConfig for npm registry.
- Monitor logs - Check security audit logs regularly
- Update frequently - Keep the package updated
- Review commands - Understand what commands are available
- Report issues - Submit security concerns immediately
- Never bypass security checks - All validation is mandatory
- Review command additions - New commands require security analysis
- Monitor audit logs - Watch for suspicious patterns
- Test thoroughly - Run security tests before deployment
MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Security: See SECURITY.md for reporting security issues
- Documentation: Check the repository for detailed docs
- Command Execution: < 30 seconds timeout
- Memory Usage: < 100MB per session
- Output Limits: 1MB max per command
- Concurrent Users: Supports multiple Claude Desktop clients
π― Quick Start: Just add "npx @modelcontextprotocol/mcp-terminal-server" to your Claude Desktop config and start using secure terminal commands immediately!