Skip to main content

MRP (MRMD Runtime Protocol) server for Bash

Project description

mrmd-bash

MRP (MRMD Runtime Protocol) server for Bash. Enables notebook-style editors to execute Bash code with persistent sessions, completions, and variable inspection.

Installation

pip install mrmd-bash

Or with uv:

uv pip install mrmd-bash

Usage

Start the server:

mrmd-bash --port 8001

The server will be available at http://localhost:8001/mrp/v1/.

Options

--host HOST       Host to bind to (default: 127.0.0.1)
--port PORT       Port to bind to (default: 8001)
--cwd PATH        Working directory for bash sessions
--log-level LEVEL Log level: debug, info, warning, error (default: info)
--reload          Enable auto-reload for development

Features

Feature Support Notes
execute Run code and return result
executeStream Stream output via SSE
interrupt Cancel running execution (SIGINT)
complete Completions via compgen
inspect Not supported
hover Variable values and command types
variables Environment and shell variables
variableExpand Bash variables are flat
reset Restart bash session
isComplete Detect incomplete statements
format Not supported
assets Not supported

API Examples

Check capabilities

curl http://localhost:8001/mrp/v1/capabilities

Execute code

curl -X POST http://localhost:8001/mrp/v1/execute \
  -H "Content-Type: application/json" \
  -d '{"code": "echo Hello, World!"}'

Get completions

curl -X POST http://localhost:8001/mrp/v1/complete \
  -H "Content-Type: application/json" \
  -d '{"code": "ec", "cursor": 2}'

List variables

curl -X POST http://localhost:8001/mrp/v1/variables \
  -H "Content-Type: application/json" \
  -d '{"session": "default"}'

Stream execution

curl -X POST http://localhost:8001/mrp/v1/execute/stream \
  -H "Content-Type: application/json" \
  -d '{"code": "for i in 1 2 3; do echo $i; sleep 1; done"}'

Sessions

Sessions maintain persistent Bash state:

  • Environment variables persist between executions
  • Working directory changes persist
  • Shell functions and aliases persist
# Create a session
curl -X POST http://localhost:8001/mrp/v1/sessions \
  -H "Content-Type: application/json" \
  -d '{"id": "my-session"}'

# Execute in session
curl -X POST http://localhost:8001/mrp/v1/execute \
  -H "Content-Type: application/json" \
  -d '{"code": "export MY_VAR=hello", "session": "my-session"}'

# Variable persists
curl -X POST http://localhost:8001/mrp/v1/execute \
  -H "Content-Type: application/json" \
  -d '{"code": "echo $MY_VAR", "session": "my-session"}'

# Reset session (clear state)
curl -X POST http://localhost:8001/mrp/v1/sessions/my-session/reset

# Delete session
curl -X DELETE http://localhost:8001/mrp/v1/sessions/my-session

Completions

The server provides completions via bash's compgen:

  • Commands: builtins, functions, aliases, executables
  • Files: paths with / prefix
  • Variables: names with $ prefix

Development

# Clone and install in development mode
git clone <repo>
cd mrmd-bash
pip install -e ".[dev]"

# Run with auto-reload
mrmd-bash --reload

# Run tests
pytest

Protocol

This server implements the MRMD Runtime Protocol (MRP).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mrmd_bash-0.1.2.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mrmd_bash-0.1.2-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file mrmd_bash-0.1.2.tar.gz.

File metadata

  • Download URL: mrmd_bash-0.1.2.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mrmd_bash-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e72c635096f1e837cea6d5a2bf6fd110a4384478841f391e651b36d209a4d2fb
MD5 34ac98eebe3645d6305e88145d4df298
BLAKE2b-256 aeabf790f5486882beee53e4a660767af41ead601aea89fb201ee00e72c72aec

See more details on using hashes here.

File details

Details for the file mrmd_bash-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mrmd_bash-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mrmd_bash-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d4fd32ead91af52a6727ac4abe568c1df301e97104b2959d9d0ffb46a08363d2
MD5 59154fb1c9afd6ca67bdbb588faf8adf
BLAKE2b-256 1f322fd5c88681ad93012cdaba79babb573ec3fd1dac3503a4b1b473787c854a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page