MCP server for remote pexpect session control
Project description
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 supporttimeout(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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f2f6b2dea1677dae9c1d934dcd512f119d24a511790b789faf2eddea3cd348
|
|
| MD5 |
48c4212e0c836b503562093f1598fa9d
|
|
| BLAKE2b-256 |
9dc508443f39bda5d9dcd18e9cbac61e96b615f103a23a0cfe035279cd011cea
|
File details
Details for the file iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_mitsuhiko_pexpect_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a6968c1c499cc2b5f81b40d632cf2fd866fb507e1cd884470f0d7218fd0d77
|
|
| MD5 |
e59658dc1f64b58fa2be2f936bfde7b1
|
|
| BLAKE2b-256 |
6585a5395690773da0922f270217154eed84b7cbf00aaeee04b6c79c442a1214
|