simple-mcp-runner

simple-mcp-runner

Simple MCP Runner makes it effortless to safely expose system commands to language models via a lightweight MCP server—all configurable with a clean, minimal YAML file and zero boilerplate.

Category
访问服务器

README

Simple MCP Runner

A production-ready Model Context Protocol (MCP) server that provides Language Learning Models (LLMs) with a safe interface to discover and execute system commands on the local machine.

Features

  • Command Discovery: Pattern-based discovery of available system commands
  • Safe Execution: Configurable security policies, timeouts, and resource limits
  • Structured Configuration: YAML-based configuration with validation
  • Production Logging: Structured logging with multiple output formats
  • Graceful Shutdown: Proper signal handling and cleanup
  • Comprehensive Testing: Unit and integration tests for critical functionality
  • Clean Architecture: Modular design with separation of concerns

Installation

From Source

go install github.com/mjmorales/simple-mcp-runner@latest

Building Locally

git clone https://github.com/mjmorales/simple-mcp-runner.git
cd simple-mcp-runner
go build -o simple-mcp-runner

Quick Start

  1. Run with default configuration:
simple-mcp-runner run
  1. Run with custom configuration:
simple-mcp-runner run --config config.yaml
  1. Run with debug logging:
simple-mcp-runner run --log-level debug

Configuration

Create a config.yaml file to customize the server behavior:

app: my-mcp-server
transport: stdio

# Define custom commands
commands:
  - name: list_files
    description: List files in current directory
    command: ls
    args: ["-la"]
    
  - name: show_date
    description: Show current date and time
    command: date

# Security settings
security:
  # Maximum command length
  max_command_length: 1000
  
  # Disable shell expansion for safety
  disable_shell_expansion: true
  
  # Block dangerous commands
  blocked_commands:
    - rm
    - dd
    - mkfs
    - shutdown
    - reboot
    
  # Or use a whitelist approach
  # allowed_commands:
  #   - echo
  #   - ls
  #   - cat
  
  # Restrict execution to specific paths
  # allowed_paths:
  #   - /home/user/projects
  #   - /tmp

# Execution limits
execution:
  default_timeout: 30s
  max_timeout: 5m
  max_concurrent: 10
  max_output_size: 10485760  # 10MB
  kill_timeout: 5s

# Logging configuration
logging:
  level: info  # debug, info, warn, error
  format: text # text, json
  output: stderr
  include_source: false

# Command discovery settings
discovery:
  max_results: 100
  common_commands:
    - ls
    - cat
    - grep
    - find
    - git
    - npm
    - go
    - python
    - node

Usage

CLI Commands

Run the MCP Server

simple-mcp-runner run [flags]

Flags:
  -c, --config string       Path to configuration file
      --log-level string    Log level (debug, info, warn, error) (default "info")
      --log-format string   Log format (text, json) (default "text")
  -h, --help               Help for run

Validate Configuration

simple-mcp-runner validate --config config.yaml

Show Version

simple-mcp-runner version

MCP Tools

The server exposes the following tools via the Model Context Protocol:

1. Command Discovery

  • Name: discover_commands
  • Description: Discover available system commands
  • Parameters:
    • pattern (optional): Filter pattern (e.g., "git*", "npm")
    • max_results (optional): Limit number of results
    • include_desc (optional): Include command descriptions

2. Command Execution

  • Name: execute_command
  • Description: Execute a system command
  • Parameters:
    • command (required): Command to execute
    • args (optional): Command arguments
    • workdir (optional): Working directory
    • timeout (optional): Execution timeout

3. Configured Commands

Custom commands defined in the configuration file are exposed as individual tools.

Security Considerations

This tool is designed for local development use only. Security features include:

  1. Command Blocking: Dangerous commands are blocked by default
  2. Shell Expansion Protection: Prevents shell injection attacks
  3. Path Restrictions: Limit execution to specific directories
  4. Resource Limits: Prevent resource exhaustion
  5. Timeout Protection: Commands have configurable timeouts
  6. Output Limits: Prevent memory exhaustion from large outputs

Architecture

The project follows clean architecture principles:

.
├── cmd/                    # CLI commands
│   ├── root.go
│   ├── run.go
│   ├── validate.go
│   └── version.go
├── internal/              # Private packages
│   ├── config/           # Configuration management
│   ├── discovery/        # Command discovery
│   ├── errors/          # Error handling
│   ├── executor/        # Command execution
│   ├── logger/          # Structured logging
│   └── server/          # MCP server implementation
├── pkg/                  # Public packages
│   └── types/           # Shared types
├── config.yaml          # Example configuration
├── go.mod
├── go.sum
└── main.go

Development

Running Tests

# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Run specific package tests
go test ./internal/executor

Building with Version Info

VERSION=$(git describe --tags --always --dirty)
COMMIT=$(git rev-parse --short HEAD)
BUILD_TIME=$(date -u '+%Y-%m-%d %H:%M:%S')

go build -ldflags "-X 'github.com/mjmorales/simple-mcp-runner/cmd.Version=$VERSION' \
  -X 'github.com/mjmorales/simple-mcp-runner/cmd.Commit=$COMMIT' \
  -X 'github.com/mjmorales/simple-mcp-runner/cmd.BuildTime=$BUILD_TIME'" \
  -o simple-mcp-runner

Code Quality

The codebase follows Go best practices:

  • Comprehensive error handling with context
  • Structured logging for debugging
  • Proper resource cleanup and timeouts
  • Thread-safe operations
  • Extensive test coverage

Contributing

Contributions are welcome! Please ensure:

  1. Code follows Go conventions
  2. Tests are included for new functionality
  3. Documentation is updated as needed
  4. Security implications are considered

License

MIT License

Acknowledgments

Built using:

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选