
Bash MCP
A TypeScript application that allows Claude to safely execute bash commands with security safeguards, providing a secure interface through the Model Context Protocol.
README
Bash MCP (Master Control Program)
A TypeScript application that allows Claude to safely execute bash commands with security safeguards. This project implements the Model Context Protocol (MCP) to provide a secure interface for executing bash commands from AI assistants like Claude.
Features
- Execute bash commands in a controlled environment
- Support for both stateless and stateful (interactive) command execution
- Security safeguards:
- Whitelisted commands
- Whitelisted directories
- Command validation
- Output sanitization
- Session management for interactive commands
- Comprehensive logging
- MCP server implementation for AI integration
Installation
npm install
npm run build
Configuration
The configuration is stored in config/default.json
. You can customize:
- Allowed commands
- Allowed directories
- Session settings
- Security settings
- Logging settings
Example configuration:
{
"allowedCommands": ["ls", "cat", "echo", "pwd"],
"allowedDirectories": ["/tmp", "/home"],
"session": {
"timeout": 300,
"maxActiveSessions": 5,
"defaultMode": "stateless"
},
"security": {
"validateCommandsStrictly": true,
"sanitizeOutput": true,
"maxOutputSize": 1048576,
"commandTimeout": 30
},
"logging": {
"level": "info",
"file": "logs/bash-mcp.log",
"maxSize": 10485760,
"maxFiles": 5
}
}
Usage
As a Library
Simple Command Execution
import { executeCommand } from 'bash-mcp';
const result = await executeCommand('ls -la', { cwd: '/home/user' });
console.log(result.output);
Interactive Sessions
import { initBashMCP } from 'bash-mcp';
const mcp = await initBashMCP();
// Create a session
const session = mcp.createSession('/home/user');
const sessionId = session.sessionId;
// Execute a command in the session
const result1 = await mcp.executeCommand('ls -la', { sessionId });
console.log(result1.output);
// Send input to the session
const result2 = await mcp.sendInput({ sessionId, input: 'echo "Hello, world!"' });
console.log(result2.output);
// Close the session when done
mcp.closeSession(sessionId);
As an MCP Server
This project includes an MCP server implementation that can be used with Claude Desktop or other MCP clients:
# Start the TypeScript MCP server
npm run mcp
# Start the JavaScript MCP server
npm run mcp-js
# Start with MCP Inspector
npm run inspector
See MCP.md
for detailed documentation on the MCP server implementation.
Security Considerations
This MCP is designed with security in mind, but it's important to:
- Keep the allowed commands and directories list as restrictive as possible
- Regularly review and update the configuration
- Monitor the logs for suspicious activity
- Keep the MCP and its dependencies up to date
Development
Building
npm run build
Linting and Formatting
To check for linting issues:
npm run lint
To automatically fix linting and formatting issues:
./fix-lint.sh
Or manually:
npm run lint:fix # Fix linting issues
npm run format # Format code
Testing
npm test
MCP SDK Version
This project uses MCP SDK version 1.0.1.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.