Skip to main content

pexpect-mcp

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

Overview

This MCP server enables AI assistants to execute Python code with pexpect functionality, allowing for interactive debugging sessions with tools like LLDB, GDB, and other command-line utilities that require programmatic interaction.

In some sense this is less of a pexpect MCP as one that is just maintaining a 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 can be debugged using LLDB through the pexpect interface. This demonstrates the server'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.

Metadata

Release files for iflow-mcp_mitsuhiko-pexpect-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iflow-mcp_mitsuhiko-pexpect-mcp 0.1.0
File Size Uploaded
iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iflow-mcp_mitsuhiko-pexpect-mcp 0.1.0
File Interpreter ABI Platform
iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0.tar.gz

Download URL iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e2f2f6b2dea1677dae9c1d934dcd512f119d24a511790b789faf2eddea3cd348
BLAKE2b-256 checksum
How to use checksums
9dc508443f39bda5d9dcd18e9cbac61e96b615f103a23a0cfe035279cd011cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0-py3-none-any.whl

Download URL iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93a6968c1c499cc2b5f81b40d632cf2fd866fb507e1cd884470f0d7218fd0d77
BLAKE2b-256 checksum
How to use checksums
6585a5395690773da0922f270217154eed84b7cbf00aaeee04b6c79c442a1214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page