Skip to main content
Glama

Archived. Claude Code's built-in Bash tool covers the same use case natively — no MCP server required. The source remains available to clone and adapt under GPLv3+. No further maintenance is planned.

ProcExecMCP

Stateless command execution and process management MCP server for Claude

ProcExecMCP enables Claude (acting in an architectural role) to search code content, execute commands, monitor processes, and terminate processes. The server exposes 4 MCP tools using FastMCP with Python 3.11+, psutil for cross-platform process management, and system ripgrep for file content search.

Features

  • 🔍 search_file_contents: Search for patterns in file contents using ripgrep

  • ⚡ execute_command: Execute commands safely with timeout and output limits

  • 📊 list_processes: List running processes with filtering and sorting

  • 🛑 kill_process: Terminate processes by PID

Related MCP server: Desktop Commander MCP

Security

  • ✅ No shell injection (no shell=True)

  • ✅ Mandatory timeouts on all operations

  • ✅ Resource limits prevent memory exhaustion

  • ✅ Path validation prevents traversal attacks

  • ✅ Sanitized error messages

For comprehensive security documentation, see SECURITY_ARCHITECTURE.md.

Prerequisites

Quick Start

1. Install Dependencies

# Clone repository
git clone https://github.com/Positronikal/ProcExecMCP.git ProcExecMCP
cd ProcExecMCP

# Install with uv
uv sync

2. Verify ripgrep

# Check if ripgrep is installed
rg --version

If not installed:

  • Windows: winget install BurntSushi.ripgrep.MSVC

  • macOS: brew install ripgrep

  • Linux: sudo apt install ripgrep

3. Configure Claude Desktop

Edit your Claude Desktop configuration file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

Add ProcExecMCP to mcpServers:

{
  "mcpServers": {
    "procexec": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/ProcExecMCP",
        "run",
        "procexec"
      ],
      "env": {
        "PROCEXEC_TIMEOUT": "30000",
        "PROCEXEC_MAX_OUTPUT": "10485760",
        "PROCEXEC_ENABLE_KILL": "true",
        "PROCEXEC_RIPGREP_PATH": "/path/to/rg"
      }
    }
  }
}

Windows Example:

{
  "mcpServers": {
    "procexec": {
      "command": "C:\\Users\\YourName\\.local\\bin\\uv.exe",
      "args": [
        "--directory",
        "D:\\dev\\ProcExecMCP",
        "run",
        "procexec"
      ],
      "env": {
        "PROCEXEC_RIPGREP_PATH": "C:\\Program Files\\ripgrep\\rg.exe"
      }
    }
  }
}

4. Restart Claude Desktop

Close and reopen Claude Desktop to load the new MCP server.

5. Verify Installation

In Claude, try:

What MCP tools do you have available?

You should see all 4 ProcExecMCP tools listed.

Configuration

Environment Variables

  • PROCEXEC_TIMEOUT: Command timeout in milliseconds (default: 30000, range: 1000-300000)

  • PROCEXEC_MAX_OUTPUT: Maximum output size in bytes (default: 10485760 = 10MB)

  • PROCEXEC_BLOCKED_PATHS: Comma-separated list of paths to block access

  • PROCEXEC_ENABLE_KILL: Enable process termination tool (default: "true")

  • PROCEXEC_RIPGREP_PATH: Full path to ripgrep binary (use if not in PATH)

Security Considerations

  1. Blocked Paths: Configure PROCEXEC_BLOCKED_PATHS to protect sensitive directories

  2. Process Termination: Disable with PROCEXEC_ENABLE_KILL="false" if not needed

  3. Timeouts: Set appropriate limits to prevent runaway commands

  4. Privileges: Avoid running Claude Desktop with elevated privileges unless necessary

Usage Examples

Search for Code Patterns

Search for all TODO comments in my Python project at /path/to/project

Execute Analysis Tools

Run 'pylint src/' in my project directory and show the results

Monitor Processes

List all Python processes sorted by memory usage

Terminate Stuck Processes

Terminate process 1234 gracefully

Development

For development setup, running tests, modifying the server, and building documentation, see USING.md.

Documentation

Troubleshooting

ripgrep not found

Ensure ripgrep is installed and in PATH, or set PROCEXEC_RIPGREP_PATH environment variable.

Timeout errors

Increase timeout via PROCEXEC_TIMEOUT environment variable (milliseconds).

Permission denied

Check file/directory permissions or configure PROCEXEC_BLOCKED_PATHS.

For more troubleshooting guidance, see BUGS.md.

License

This project is licensed under the GNU General Public License version 3 or any later version (GPLv3+). See COPYING.md for the full license text.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

Support

Available Tools

4 tools
execute_commandA

Execute a command safely with timeout and output limits.

This tool executes commands without shell injection vulnerabilities. Commands are parsed into argument lists and executed directly via subprocess without shell=True.

Args: command: Command to execute (e.g., "python --version", "npm test") working_directory: Working directory for execution (default: current) timeout_ms: Timeout in milliseconds (default: 30000, max: 300000) capture_output: Whether to capture stdout/stderr (default: True) ctx: MCP context for logging (optional)

Returns: ExecuteCommandOutput with stdout, stderr, exit code, and timing

Raises: ValueError: If input validation fails SanitizedError: If command execution fails

Security: - No shell=True (prevents shell injection) - Command parsed with shlex.split (safe parsing) - Mandatory timeout enforcement - Output size limits (prevents memory exhaustion) - Path validation for working directory - Sanitized error messages (no information leakage)

Examples: >>> result = await execute_command("python --version") >>> print(result.stdout) # "Python 3.11.5" >>> print(result.exit_code) # 0

>>> result = await execute_command(
...     "npm test",
...     working_directory="./myproject",
...     timeout_ms=60000
... )

Inputs: command (required), timeout_ms, capture_output, working_directory. Returns: Output schema for execute_command tool.

kill_processA

Terminate a process by PID with graceful or forced termination.

This tool allows terminating stuck or hung processes to clean up system resources. It supports both graceful termination (SIGTERM/WM_CLOSE) with a timeout, and forced termination (SIGKILL/TerminateProcess) for unresponsive processes.

Args: pid: Process ID to terminate (must be >= 1) force: If True, forcefully kill the process. If False, attempt graceful termination with timeout. Default: False timeout_seconds: Timeout in seconds to wait for graceful termination. Ignored if force=True. Range: 0.1-30.0s. Default: 5.0s ctx: MCP context for logging (optional)

Returns: KillProcessOutput with success status, PID, message, timing, and whether forced termination was used

Raises: SanitizedError: If process termination fails or is not enabled

Security: - Requires PROCEXEC_ENABLE_KILL=true environment variable to function - Handles permission errors gracefully (no crashes) - Cannot terminate system-critical processes (OS protection) - Error messages are sanitized (no sensitive info)

Examples: >>> # Graceful termination >>> result = await kill_process(pid=1234, force=False, timeout_seconds=5.0) >>> print(result.success, result.message) True 'Process terminated gracefully'

>>> # Forced termination
>>> result = await kill_process(pid=5678, force=True)
>>> print(result.success, result.forced)
True True

Inputs: pid (required), force, timeout_seconds. Returns: Output schema for kill_process tool.

list_processesA

List running processes with optional filtering and sorting.

This tool retrieves information about running processes on the system, including PID, name, CPU usage, memory usage, command line, and status. Results can be filtered by name, sorted by various criteria, and limited to a maximum number of results.

Args: name_filter: Filter processes by name (case-insensitive substring match). If None, return all processes. sort_by: Sort processes by: cpu (descending), memory (descending), pid (ascending), or name (ascending). Default: cpu. limit: Maximum number of processes to return. Default: 100, max: 1000. ctx: MCP context for logging (optional)

Returns: ListProcessesOutput with process list, total count, truncation flag, and retrieval time

Raises: SanitizedError: If process iteration fails

Security: - Handles permission errors gracefully (skips inaccessible processes) - No sensitive system information leaked in errors - Command lines are included but may be empty if access denied - Zombie and terminated processes handled without errors

Performance: - Uses psutil.process_iter() for efficient iteration - oneshot() context for batch info retrieval per process - Target: <2s for process list retrieval

Examples: >>> result = await list_processes() >>> print(result.total_count, "processes found") 245 processes found

>>> result = await list_processes(
...     name_filter="python",
...     sort_by=ProcessSortBy.MEMORY,
...     limit=50
... )
>>> for proc in result.processes:
...     print(f"{proc.name}: {proc.memory_mb}MB")

Inputs: limit, sort_by, name_filter. Returns: Output schema for list_processes tool.

search_file_contentsA

Search for patterns in file contents across a directory or file.

This tool uses ripgrep to efficiently search for regex patterns in files. It returns matches with line numbers and surrounding context lines.

Args: pattern: Regular expression pattern to search for path: File or directory path to search in case_sensitive: Whether search should be case-sensitive (default: True) file_types: File type filters (e.g., ['py', 'js']). None = all files exclude_patterns: Glob patterns to exclude (e.g., ['node_modules']) max_results: Maximum number of results to return (1-10000) context_lines: Lines of context before/after match (0-10) ctx: MCP context for logging (optional)

Returns: SearchFileContentsOutput with matches and metadata

Raises: ValueError: If input validation fails SanitizedError: If search execution fails

Examples: >>> result = search_file_contents("TODO", "./src", case_sensitive=False) >>> print(f"Found {len(result.matches)} TODO comments")

Inputs: path (required), pattern (required), file_types, max_results, +3 more. Returns: Output schema for search_file_contents tool.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a distinct purpose: executing commands, searching file contents, listing processes, and killing processes. There is no functional overlap, and descriptions clearly differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case: execute_command, search_file_contents, list_processes, kill_process. The naming is predictable and uniform.

    Tool Count5/5

    With only 4 tools, the set is well-scoped for its purpose of process and command management plus file content searching. Each tool earns its place with comprehensive parameters and security considerations.

    Completeness5/5

    The tool surface covers the core operations for its domain: command execution, file content search, process enumeration, and process termination. There are no obvious gaps for the intended functionality.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A secure MCP server for executing whitelisted shell commands with resource and timeout controls, designed for integration with Claude and other MCP-compatible LLMs.
      20
      389 npm
      7
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A server that lets Claude desktop app execute terminal commands on your computer and edit files through Model Context Protocol, featuring command execution, process management, and advanced file operations.
      19
      1,287,096 npm
      6
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A server implementation for the Model Context Protocol (MCP) that allows Claude AI to execute commands through a command-line interface, enabling direct system interactions from within Claude.
      -