Skip to main content
Glama

Pexpect MCP Server

by mitsuhiko

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.

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Enables AI assistants to execute Python code with pexpect functionality for interactive debugging sessions with command-line tools like LLDB and GDB. Maintains a stateful Python session allowing programmatic control of interactive processes.

  1. Overview
    1. Installation
      1. Usage
        1. As an MCP Server
        2. Tool Usage
      2. Demo
        1. Requirements
          1. License

            Related MCP Servers

            • -
              security
              F
              license
              -
              quality
              Provides an interactive Python REPL environment that maintains persistent session state, allowing users to execute Python code and access session history.
              Last updated -
              56
              Python
              • Apple
            • -
              security
              A
              license
              -
              quality
              An interactive Python code execution environment that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.
              Last updated -
              20
              Python
              Apache 2.0
            • -
              security
              A
              license
              -
              quality
              An interactive Python code execution tool that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.
              Last updated -
              20
              Python
              Apache 2.0
            • -
              security
              A
              license
              -
              quality
              A comprehensive Model Context Protocol server that enables Claude Code to perform expect/pexpect-style automation for interactive programs, supporting complex interactions with terminal programs, SSH sessions, databases, and debugging workflows.
              Last updated -
              2
              Python
              MIT License
              • Linux
              • Apple

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/mitsuhiko/pexpect-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server