Описание
MCP server for Rash (Rust-to-Shell transpiler)
README
schema_version: "1.0" kind: cli entrypoints: [rash/src/bin/bashrs.rs] contract_count: 120
bashrs
Rust-to-POSIX Shell Transpiler
Installation | Quick Start | Features | Book | API Docs
A bidirectional shell safety tool that transpiles Rust to deterministic POSIX shell scripts and purifies legacy bash into safe, portable shell. Also known as Rash (the library crate). Part of the PAIML Sovereign AI Stack transpiler family alongside depyler and decy.
Table of Contents
- What is bashrs?
- Installation
- Quick Start
- Features
- Architecture
- Quality
- Sovereign AI Stack
- Documentation
- Verify
- Contracts
- Contributing
- License
What is bashrs?
Shell scripts power CI/CD pipelines, deployment automation, and system configuration across every production environment. They are also notoriously fragile -- unquoted variables, non-idempotent operations, and injection vulnerabilities are the norm, not the exception.
bashrs solves this in two directions:
- Rust to Shell -- Write type-safe Rust, transpile to deterministic POSIX shell with automatic safety guarantees.
- Shell to Shell -- Purify existing bash scripts by rewriting unsafe patterns at the AST level, not just warning about them.
Generated scripts run on any POSIX-compliant system with zero runtime dependencies. Same input always produces identical output.
Installation
CLI
cargo install bashrs
Library
Add to your Cargo.toml:
[dependencies]
bashrs = "7.4"
Quick Start
Write Rust, Get Safe Shell
// install.rs
#[rash::main]
fn main() {
let version = env_var_or("VERSION", "1.0.0");
let prefix = env_var_or("PREFIX", "/usr/local");
echo("Installing MyApp {version} to {prefix}");
mkdir_p("{prefix}/bin");
mkdir_p("{prefix}/share/myapp");
if exec("cp myapp {prefix}/bin/") {
echo("Binary installed");
} else {
eprint("Failed to install binary");
exit(1);
}
}
Transpile to safe POSIX shell:
bashrs build install.rs -o install.sh
Purify Existing Bash
Before (unsafe bash):
#!/bin/bash
SESSION_ID=$RANDOM # Non-deterministic
mkdir /app/releases/$RELEASE # Non-idempotent
rm /app/current # Fails if missing
After (purified by Rash):
#!/bin/sh
session_id="session-${version}" # Deterministic
mkdir -p "/app/releases/${release}" # Idempotent
rm -f "/app/current" # Safe removal
CLI Usage
# Transpile Rust to shell
bashrs build input.rs -o output.sh
# Purify legacy bash scripts
bashrs purify messy.sh -o clean.sh
# Lint shell scripts (including Dockerfiles)
bashrs lint script.sh
# Quality scoring
bashrs score script.sh
# Interactive REPL
bashrs repl
# Mutation testing
bashrs mutate script.sh --count 10
Features
- POSIX Compliance -- Generated scripts target POSIX sh and run on sh, dash, bash, ash, zsh, and mksh.
- Injection Prevention -- Automatic variable quoting, word-split protection, and glob expansion suppression at the AST level.
- ShellCheck Integration -- All transpiler output passes strict ShellCheck validation (99.9% compliance).
- Dockerfile/Makefile Transpilation -- Transpile and lint Dockerfiles and Makefiles alongside shell scripts.
- Built-in Linter -- 100+ lint rules with auto-fix, severity
levels,
.bashrsignoresupport, and watch mode. - Built-in Formatter -- Configurable shell script formatter with TOML configuration.
- Deterministic Output -- Same input always produces identical scripts. Verified across 17,882 corpus entries.
- MCP Server -- Model Context Protocol server for AI-assisted shell
generation (
rash-mcp, registered asio.github.paiml/rash). - LSP Server -- Language Server Protocol for editor integration.
- Mutation Testing -- 10 mutation operators (string, command, conditional, redirect) for test quality verification.
Beyond ShellCheck
| ShellCheck | bashrs |
|---|---|
| Warns about unquoted variables | Quotes all variables automatically |
Warns about non-deterministic $RANDOM |
Rewrites to version-based deterministic IDs |
Warns about non-idempotent mkdir |
Transforms to mkdir -p |
| Static pattern matching | Full AST semantic understanding |
| Read-only analysis | Read-write transformation |
Architecture
bashrs is a workspace of five crates:
| Crate | Purpose |
|---|---|
bashrs (rash) |
Core library: parser, transpiler, linter, formatter |
bashrs-specs |
Formal verification specs and benchmarks |
bashrs-oracle |
ML-powered error classification |
bashrs-wasm |
Browser-compatible WASM build |
rash-runtime |
Runtime support for transpiled scripts |
The transpilation pipeline:
Rust Source --> Parse (syn) --> Rash IR --> POSIX Shell AST --> Emit
|
+--> Makefile AST --> Emit
|
+--> Dockerfile AST --> Emit
The purification pipeline:
Bash Source --> Parse (AST) --> Safety Analysis --> Rewrite --> Emit
Quality
| Metric | Value |
|---|---|
| Tests | 15,117 passing |
| Line Coverage | 95.04% |
| Corpus Score | 97.5/100 (Grade A+) |
| Corpus Entries | 17,882 (100% pass) |
| ShellCheck Compliance | 99.9% |
| Cross-Shell Compatibility | 6 shells (sh, dash, bash, ash, zsh, mksh) |
| Deterministic | 100% (same input = same output) |
bashrs uses Popperian falsification -- tests attempt to disprove functionality rather than confirm it. A passing test means the falsification attempt failed.
# 130-point transpiler falsification checklist
cargo test -p bashrs --test transpiler_tcode_tests
# 30-point Dockerfile falsification checklist
cargo test -p bashrs --test dockerfile_dcode_tests
Performance
| Operation | Time |
|---|---|
| Rust-to-Shell transpilation | 21.1 us |
| Makefile parsing | 0.034--1.43 ms |
| Memory usage | < 10 MB |
Sovereign AI Stack
bashrs is part of the PAIML Sovereign AI Stack -- a pure-Rust ecosystem for privacy-preserving ML infrastructure.
| Layer | Crate | Purpose |
|---|---|---|
| Compute | aprender-compute | SIMD/GPU primitives (AVX2/AVX-512/NEON) |
| ML | aprender | ML algorithms, APR v2 model format |
| Training | aprender-train | Autograd, LoRA/QLoRA, quantization |
| Inference | aprender-serve | LLM inference, GPU kernels |
| Distribution | aprender-distribute | Distributed compute (CPU/GPU/Remote) |
| Orchestration | aprender-orchestrate | Stack coordination and CLI |
| Transpilers | bashrs, depyler, decy | Shell/Python/C to Rust |
| Verification | aprender-contracts | YAML contract verification |
Documentation
- The Rash Book: paiml.github.io/bashrs -- canonical documentation with tested examples
- API Reference: docs.rs/bashrs
- Cookbook: bashrs-cookbook -- examples and recipes
- Changelog: CHANGELOG.md
Verify
This README is a checked document. CI turns it into one readme:Readme
node and validates it against the SHACL shape in
contracts/readme-root.yaml. Every command
in a bash fence must be one a merge-path CI job runs; fences labelled
console or text are illustration. No CI job runs the shape check yet:
pv-readme is not on the runners. Until it is, these are run by hand:
pv-readme --check
sh tests/readme-shape-falsifier.sh
The second command plants four defects in a copy of this file and requires each to be refused.
Contracts
bashrs carries 110
contract files under contracts/. pv-readme --write renders
that number by walking the directory for regular *.yaml files; the 10
symlinked contracts from provable-contracts are not followed. The
frontmatter contract_count: is contracts/census.json n_files, which
counts the symlinked contracts too. sh tests/readme-count-falsifier.sh
checks both numbers and this paragraph.
Contributing
- Fork the repository
- Make changes on a feature branch and open a pull request against
main - Run quality gates:
make lint && make test - Run coverage:
make coverage - Submit a pull request
License
MIT License. See LICENSE for details.
Установка Rash
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/paiml/bashrsFAQ
Rash MCP бесплатный?
Да, Rash MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Rash?
Нет, Rash работает без API-ключей и переменных окружения.
Rash — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Rash в Claude Desktop, Claude Code или Cursor?
Открой Rash на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Unyly Deploy
Deploy sites and MCP servers to Unyly straight from your AI agent
автор: UnylyTemplate MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectServer Sequential Thinking
MCP server for sequential thinking and problem solving
автор: GitHub Actionsgnomancer
Local raw DNA analysis: haplogroups, traits, ClinVar, pharmacogenomics. Nothing is uploaded.
автор: com.gnomancerAmap Maps Mcp Server
MCP server for using the AMap Maps API
автор: duxiaohuiPayMCP
Lightweight payments layer for MCP servers: turn tools into paid endpoints with a two-line decorator. [PyPI](https://pypi.org/project/paymcp/) · [npm](https://w
автор: blustAIdemo
demo — MCP server via Smithery
автор: yoojoohans-jpgCompare Rash with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
