rash-mcp

Crates.iorash-mcp
lib.rsrash-mcp
version1.0.0
created_at2025-10-04 13:42:43.080511+00
updated_at2025-10-10 17:09:00.110974+00
descriptionMCP server for Rash (Rust-to-Shell transpiler)
homepage
repositoryhttps://github.com/paiml/bashrs
max_upload_size
id1867902
size94,137
Noah Gift (noahgift)

documentation

README

Rash MCP Server

MCP (Model Context Protocol) server for Rash - the Rust-to-Shell transpiler.

Features

  • Transpile Tool: Convert Rust code to POSIX-compliant shell scripts
  • Type-safe: Strongly typed inputs and outputs using JSON Schema
  • Async execution: Built on tokio for efficient async processing
  • Zero-boilerplate: Powered by pforge framework

Installation

cargo build --release -p rash-mcp

Usage

Standalone Demo

cargo run -p rash-mcp

As MCP Server

The server exposes one tool:

transpile

Transpiles Rust source code to POSIX shell script.

Input:

{
  "source": "fn main() { println!(\"Hello, World!\"); }",
  "optimize": false,
  "strict": false
}

Output:

{
  "shell_script": "#!/bin/sh\n...",
  "warnings": []
}

Parameters:

  • source (string, required): Rust source code to transpile
  • optimize (boolean, optional): Enable optimizations (default: false)
  • strict (boolean, optional): Enable strict mode (default: false)

Examples

Basic Transpilation

fn main() {
    let x = 42;
}

Generates:

#!/bin/sh
main() {
    x=42
}
main "$@"

With println! Macro

fn main() {
    println!("Hello, MCP!");
}

Generates:

#!/bin/sh
rash_println() {
    printf '%s\n' "$1"
}
main() {
    rash_println 'Hello, MCP!'
}
main "$@"

Testing

cargo test -p rash-mcp

Architecture

  • Handler: TranspileHandler implements pforge Handler trait
  • Runtime: Uses pforge-runtime for MCP protocol
  • Transpiler: Delegates to bashrs crate

Development

Built using EXTREME TDD:

  1. RED: Write failing test
  2. GREEN: Make it pass
  3. REFACTOR: Clean up

All 3 handler tests passing (100% coverage of critical paths).

Commit count: 1117

cargo fmt