mitsuhiko

pexpect-mcp

Community mitsuhiko
Updated

python + pexpect

pexpect-mcp

An MCP (Model Context Protocol) server thatprovides remote pexpect session control for debugging and process interaction.

Overview

This MCP server enables AI assistants to execute Python code with pexpectfunctionality, allowing for interactive debugging sessions with tools likeLLDB, GDB, and other command-line utilities that require programmaticinteraction.

In some sense this is less of a pexpect MCP as one that is just maintaininga stateful Python session.

Installation

uv tool install git+https://github.com/mitsuhiko/pexpect-mcp

Usage

As an MCP Server

Add to your Claude Code configuration:

{
  "mcpServers": {
    "pexpect": {
      "command": "pexpect-mcp"
    }
  }
}

Tool Usage

The server provides a single tool: pexpect_tool

Parameters:

  • code (string): Python code to execute with pexpect support
  • timeout (optional int): Timeout in seconds (default: 30)

Example Usage:

# Start a debugging session
child = pexpect.spawn('lldb ./my-program')
child.expect('(lldb)')

# Run the program
child.sendline('run')
child.expect('(lldb)')
print(child.before.decode())

# Get backtrace
child.sendline('bt')
child.expect('(lldb)')
print(child.before.decode())

Demo

The repository includes a demo with a buggy C program (demo-buggy.c) that canbe debugged using LLDB through the pexpect interface. This demonstrates theserver's capability for interactive debugging sessions.

The program `./demo-buggy` crashes when executed. Use LLDB to:

- Start the program under the debugger
- Identify where and why it crashes
- Examine variables, memory, and call stack
- Report the root cause of the crash

Requirements

  • Python โ‰ฅ 3.12.1
  • pexpect โ‰ฅ 4.9.0
  • mcp โ‰ฅ 1.13.0

License

See LICENSE file for details.

MCP Server ยท Populars

MCP Server ยท New

    khromov

    Setup

    Svelte developer documentation as an MCP or in llms.txt format

    Community khromov
    firecrawl

    Firecrawl MCP Server

    ๐Ÿ”ฅ Official Firecrawl MCP Server - Adds powerful web scraping to Cursor, Claude and any other LLM clients.

    Community firecrawl
    conorluddy

    Context-Pods

    ๐Ÿซ› Local-first Model Context Protocol management suite. Provides an MCP to create and manage other local MCPs. Useful for local Tooling etc.

    Community conorluddy
    mitsuhiko

    pexpect-mcp

    python + pexpect

    Community mitsuhiko
    vfarcic

    DevOps AI Toolkit

    Intelligent dual-mode agent for deploying applications to ANY Kubernetes cluster through dynamic discovery and plain English governance

    Community vfarcic