Skip to main content
Glama

Bash MCP (Master Control Program)

by yannbam

Bash MCP(主控制程序)

一个 TypeScript 应用程序,允许 Claude 在安全保障下安全地执行 bash 命令。

特征

  • 在受控环境中执行 bash 命令
  • 支持无状态和有状态(交互式)命令执行
  • 安全保障措施:
    • 白名单命令
    • 白名单目录
    • 命令验证
    • 输出清理
  • 交互式命令的会话管理
  • 综合日志记录

安装

npm install npm run build

配置

配置存储在config/default.json中。您可以自定义:

  • 允许的命令
  • 允许的目录
  • 会话设置
  • 安全设置
  • 日志记录设置

示例配置:

{ "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 } }

用法

简单命令执行

import { executeCommand } from 'bash-mcp'; const result = await executeCommand('ls -la', { cwd: '/home/user' }); console.log(result.output);

互动环节

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);

安全注意事项

此 MCP 在设计时充分考虑了安全性,但重要的是:

  • 保持允许的命令和目录列表尽可能严格
  • 定期检查并更新配置
  • 监控日志中是否存在可疑活动
  • 保持 MCP 及其依赖项保持最新

发展

建筑

npm run build

代码检查和格式化

要检查 linting 问题:

npm run lint

要自动修复 linting 和格式问题:

./fix-lint.sh

或者手动:

npm run lint:fix # Fix linting issues npm run format # Format code

测试

npm test
-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

一个 TypeScript 应用程序,允许 Claude 使用安全保障措施(包括白名单命令、目录和全面日志记录)安全地执行 bash 命令。

  1. 特征
    1. 安装
      1. 配置
        1. 用法
          1. 简单命令执行
          2. 互动环节
        2. 安全注意事项
          1. 发展
            1. 建筑
            2. 代码检查和格式化
            3. 测试

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
            Last updated -
            1
            74
            Python
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            A secure server for executing terminal commands within predefined paths, allowing safe interaction by Large Language Models with operating system environments.
            Last updated -
            1
            11
            3
            JavaScript
            MIT License
            • Apple
            • Linux
          • -
            security
            F
            license
            -
            quality
            A secure server that allows LLM applications like Claude to execute whitelisted system commands with user confirmation and comprehensive security features.
            Last updated -
            Python
            • Linux
            • Apple
          • A
            security
            F
            license
            A
            quality
            Provides a secure, isolated JavaScript execution environment with configurable time and memory limits for safely running code from Claude.
            Last updated -
            1
            5
            JavaScript
            • Apple

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/yannbam/bash-mcp'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server