Rusterpret
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Rusterpret
English · Deutsch · Español · Français · Türkçe · العربية
Use with Codex or Claude Code
An assistant can write a Rust page with Rusterpret, read what the compiler says about it, correct it and run it, while you watch the result in your browser. Install Rusterpret first. Then open a terminal in an empty folder and start one of the two clients with Rusterpret as its MCP server for this folder:
$ codex -c 'mcp_servers.rusterpret={command="rusterpret",args=["mcp",".","--port","0"]}'$ claude --mcp-config '{"mcpServers":{"rusterpret":{"command":"rusterpret","args":["mcp",".","--port","0"]}}}'Both commands give the client the server for this session only; codex mcp add and
claude mcp add would write it into the configuration of the client. The server lives as long as
the session, and it serves the folder to your browser as well, on a free port of 127.0.0.1 that
the system picks. The assistant gets the address from Rusterpret and tells you. Give it this
prompt:
Use the Rusterpret tools to create index.rs with this page:
pub fn run() -> String {
let total: i32 = "42";
format!("<h1>Rusterpret</h1><p>Total: {total}</p>")
}
Request / and show me what the compiler says. Then change line 2 to
let total: i32 = 6 * 7;
request / again, and tell me the address where I can see the page in my browser.This ran on 2026-12-04 on a MacBook with Apple M5 Max and macOS 27.0.1, with the code of this
version, in the interactive interface of Codex CLI 0.174.0 and of Claude Code 2.1.336. Each
client wrote index.rs, got status 500 with error[E0308]: mismatched types at index.rs:2:22,
changed line 2, got status 200 and named the address. A browser there showed the diagnostic and
then "Total: 42". The recorder of the run set the port to 29480, because the machine allowed that
run only a fixed range of ports.
Codex asked before every call of a tool that changes files or runs a page, here write and get
("Allow the rusterpret MCP server to run tool "write"?"), and not before about, which only
reads. While the server started, it looked through the folder with its own shell without asking.
Claude Code asks according to the permission mode you set: in its default mode it asked "Do you
want to proceed?" before every call of a tool of Rusterpret, about included, and in its
automatic mode it asked nothing.
The first start prepares the standard library, once. With an empty cache folder the tools reached
Codex 14.9 s and Claude Code 12.1 s after the start of the client on that MacBook, and both
clients waited for them. Codex 0.174.0 started the server a second time while it waited, and the second process found
the library the first one had prepared. On Linux the preparation takes about 15 s, and no client
has run there yet. How the clients were run is in
research/2026-12-04-clients/.
Save. Reload. See. Plain Rust that answers in the browser the moment the file is saved.
Rusterpret is a Rust interpreter with its own HTTP server. You write an ordinary .rs file, save it and
open an address. Rusterpret lets the real Rust compiler front end parse, type-check and borrow-check the
file, then runs the result itself and sends the answer back. Change the file, reload, and the new code
answers. The server process never restarts and nothing is built in between. A folder of such files
is a website: pages written in Rust that answer with HTML, next to ordinary files.
What you do by hand, a program can do too: Rusterpret has an MCP server for assistants and an
HTTP API for scripts, see MCP and API. And rusterpret playground puts an editor
and a preview of one page next to each other in the browser, see
A playground in the browser.
Related MCP server: CodeCortX-MCP
Install
One command:
$ curl -fsSL https://raw.githubusercontent.com/LEVOGNE/rusterpret/main/install.sh | shThat is all. The script sets up everything Rusterpret needs:
If Rust is not installed yet, it installs it first with the official installer from rustup.rs. That installer adds
~/.cargo/binto the PATH of new terminals.It fetches the exact Rust toolchain Rusterpret is built on (1.0 to 1.5 GB on disk, once). Any Rust you already have stays as it is. On a machine without Rust this toolchain also becomes the default, and
rustup default stablechanges that at any time.It builds the
rusterpretcommand, which takes a few seconds.
The first time rusterpret starts, it prepares the standard library for interpretation. That takes
about 15 seconds, once, and needs no network.
On a Mac the script first checks for the Command Line Tools of Xcode, which every Rust program needs
for linking. If they are missing, it stops before downloading anything and names the command that
installs them. On Linux it checks for a C compiler (cc) in the same way, because Rust uses it as the
linker. If the script had to install Rust, open a new terminal afterwards so that the rusterpret
command is found.
If you prefer to type it yourself, these are the two commands the script runs once Rust is there:
$ rustup toolchain install nightly-2026-11-14 --profile minimal --component rustc-dev --component llvm-tools --component rust-src
$ rustup run nightly-2026-11-14 cargo install rusterpret@0.1.16Rusterpret 0.1.16 is tested on Linux on x86_64. Its tests also run with the standard library of
macOS on Apple Silicon, interpreted on Linux. On a MacBook with Apple M5 Max and macOS 27.0.1 the
agent "Rusterpret Debugger" installed 0.1.7 with the installer of this README, taken from the tag
v0.1.7, served the first page and its change, and ran the tests: two of them failed. 0.1.8 changes
the server and the test for both, and on the same MacBook the published 0.1.8 installed with the
same installer, served the first page and its change, and passed all 80 tests. The code and the
tests of 0.1.9 passed all 84 tests on the same MacBook after 0.1.9 was published, and the published
0.1.10 passed its installation, its first page and its change, all 88 tests and the storage example
there. The published 0.1.11 passed its installation, its first page and its change, 86 of its 90
tests and the storage example there; the agent left out the four tests that swap a folder while a
call runs, so they have not run on a Mac. Before 0.1.12 was published, its code passed 86 of its 93
tests there as the candidate 714fb6c, with the seven tests that change a folder while a call or a
read runs left out in the same way. Before 0.1.13 was published, its code passed 94 of its 106
tests there as the candidate aa1e014: the agent left out the same seven tests and three that try
to read outside the served folder or the session of another visitor, and the two tests of a
session behind a virtual machine run on Linux only. The page of the playground was checked there
in Chromium 158. Before 0.1.14 was published, its section for assistants passed its runs and 87 of
its 98 tests there as the candidate 45d925e, before it was joined with the playground of 0.1.13:
the agent left out the same seven tests, two in which a page tries to get round the border of the
served folder, and two that start the server on a port the system picks, which that machine did not
allow. The joined code of 0.1.14 and the code of 0.1.15 and 0.1.16 have run on Linux only, because the machine
of the check was not available before their publication. 0.0.1 was tested on macOS on Apple
Silicon. Windows is not supported yet.
Your first page
Create a file hello.rs:
pub fn run() -> i32 {
6 * 7
}Start Rusterpret with it:
$ rusterpret serve hello.rs
rusterpret 0.1.16 serving hello.rs
http://127.0.0.1:8787/Open http://127.0.0.1:8787/ in your browser. It shows 42.
Now change 6 * 7 to 6 * 8, save the file and reload the page. It shows 48. You did not restart
anything and you did not build anything.
A slightly bigger example
The repository contains examples/calculator.rs:
fn double(x: i32) -> i32 {
x * 2
}
pub fn run() -> i32 {
let x = 8;
if x < 0 { 0 } else { double(x) }
}$ rusterpret serve ./examples/calculator.rs
$ curl http://127.0.0.1:8787/
16Change let x = 8; to let x = 9;, save, and the next request returns 18.
A value from the address
If run takes a parameter, the value comes from the address:
pub fn run(x: i32) -> i32 {
if x < 0 { 0 } else { double(x) }
}$ curl 'http://127.0.0.1:8787/?x=7'
14
$ curl 'http://127.0.0.1:8787/?x=-1'
0
$ curl http://127.0.0.1:8787/
Parameter x is missing: `run` takes `x: i32`. Example: /?x=7/run is a second name for /, so /run?x=7 works as well.
Parameters are found by their names. run may take several, of any integer type up to 64 bits, of
bool, of &str and of Option<&str>, which is None when the value is missing:
pub fn run(name: &str, times: u8, loud: bool) -> String {
let text = name.repeat(usize::from(times));
if loud { text.to_uppercase() } else { text }
}$ curl 'http://127.0.0.1:8787/?name=ho×=3&loud=true'
HOHOHOA website from a folder
Give Rusterpret a folder instead of a file, and every .rs file in it becomes a page. A page whose
run returns text answers with HTML. All other files are delivered as they are.
The repository contains examples/site/:
File | Address | What it is |
|
| the start page, written in Rust |
|
| a page that returns a number |
|
| a static HTML page |
|
| delivered as they are |
A page can be split into several files. examples/vorgaenge/ has a page vorgaenge.rs that declares
mod records; and a module records.rs with three records and a function that filters them:
$ rusterpret serve ./examples/vorgaenge
$ curl 'http://127.0.0.1:8787/vorgaenge?status=offen'
<h1>Vorgänge: offen</h1>
<ul>
<li><strong>A-101</strong> Angebot prüfen (offen)</li>
<li><strong>A-103</strong> Termin bestätigen (offen)</li>
</ul>
<p>2 of 3</p>Change the status of A-103 in records.rs, save, and the next request lists A-101 alone.
The start page builds its HTML with format!. page is a function of the same file that wraps the
body in a complete HTML document:
fn double(x: i32) -> i32 {
x * 2
}
pub fn run() -> String {
let x = 21;
let body = format!(
" <h1>Hello from Rust</h1>
<p>{x} doubled is {}.</p>
<p><a href=\"/about\">About</a> · <a href=\"/double?x={x}\">The number alone</a></p>",
double(x)
);
page("Rusterpret", &body)
}$ rusterpret serve ./examples/site
$ curl 'http://127.0.0.1:8787/double?x=21'
42Open http://127.0.0.1:8787/ in your browser. It shows "21 doubled is 42." Change let x = 21;, save
and reload.
How an address finds its file
Address | Answered by |
|
|
|
|
|
|
| redirect (301) to |
| the file |
If
about.rsandabout.htmlboth exist, the program answers at/about. The response names the hidden file inX-Rusterpret-Hiddenand the server log says which file takes precedence. The file itself is still delivered at/about.html.A file without an extension does not take the address of a program of the same name: if
about.rsand a fileaboutboth exist, the program answers at/about, and the response and the log nameaboutin the same way. That file has no other address, so a browser does not get it while the program is there. The interface for programs still reads it.Every page is prepared and cached on its own.
?x=works on every page whoseruntakesx..rsfiles are never delivered as files, not even as/index.rs. Files and folders whose names start with a dot are not delivered, and neither is anything a symbolic link points to outside the folder.An address finds a file only in the spelling of its name in the folder:
/Aboutdoes not findabout.rs. This is built for a file system that does not tell upper from lower case, as that of a Mac, and checked on Linux and with 0.1.8 and 0.1.9 on a Mac.The content type follows the extension: HTML, CSS, JavaScript, JSON, web manifest, SVG, PNG, JPEG, GIF, WebP, AVIF, ICO, WebAssembly, WOFF, PDF, MP4, WebM, MP3, otherwise
application/octet-stream. Files are streamed, not loaded into memory.HTML is sent with
Content-Security-Policy: default-src 'self'; frame-ancestors 'none': a page may load styles, scripts and images from the same server and nothing else. All other answers getdefault-src 'none'.
Forms
A page can answer a form. Next to run it declares pub fn post, which the server calls for a
POST to the address of the page. Its parameters are read by name from the form, as those of run
are read from the address. A function that wants to choose its status and a Location returns a
struct with the fields status: u16, location: Option<String> and body: String. The name of
the struct is yours. A parameter of the type Option<&str> is None when the value is missing.
examples/formular/vorgang.rs shows a case with a button "Erledigt". The button sends the number
of the case to the same address, the page answers 303 See Other, and the browser follows to a
confirmation:
pub struct Antwort {
pub status: u16,
pub location: Option<String>,
pub body: String,
}
pub fn post(id: &str) -> Antwort {
if id != VORGANG.id {
return Antwort::seite(
400,
"<h1>Ungültige Vorgangs-ID</h1>\n<p>Das Formular nennt keinen bekannten Vorgang. Erwartet wird zum Beispiel A-101.</p>\n",
);
}
Antwort {
status: 303,
location: Some(format!("/vorgang?erledigt={id}")),
body: String::new(),
}
}run(erledigt: Option<&str>) shows the case with its form when erledigt is missing, and the
confirmation for /vorgang?erledigt=A-101. Antwort::seite wraps a text in an HTML document with
the given status.
$ rusterpret serve ./examples/formularOpen http://127.0.0.1:8787/vorgang in your browser and press "Erledigt". The browser shows the
confirmation at /vorgang?erledigt=A-101. Reloading it asks for that address again and does not
send the form a second time. Change a text in vorgang.rs, save and reload: the server, still
running, shows the new text.
The same with curl, which shows the status and the Location:
$ curl -i -d id=A-101 http://127.0.0.1:8787/vorgang
HTTP/1.1 303 See Other
Content-Type: text/html; charset=utf-8
Content-Security-Policy: default-src 'self'; frame-ancestors 'none'
Cache-Control: no-store
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer
Connection: close
Content-Length: 0
Location: /vorgang?erledigt=A-101
X-Rusterpret-Steps: 960
X-Rusterpret-Version: 1
X-Rusterpret-Prepared: reused
$ curl -i -X POST http://127.0.0.1:8787/vorgang
HTTP/1.1 400 Bad Request
...
Form field id is missing: `post` takes `id: &str`.The confirmation says that the form was processed. This page stores nothing, so the case is open again at the next visit. How a page keeps what it is sent shows the next section, Storing data.
A program sends the same form through the interface, with run and the fields in form. Started
with --api and the token my-secret, the server answers:
$ curl -H 'Authorization: Bearer my-secret' -H 'Content-Type: application/json' -d '{"page":"/vorgang","form":{"id":"A-101"}}' http://127.0.0.1:8787/.rusterpret/api/run
{"status":303,"content_type":"text/html; charset=utf-8","headers":{"Location":"/vorgang?erledigt=A-101","X-Rusterpret-Steps":"960","X-Rusterpret-Version":"1","X-Rusterpret-Prepared":"fresh"},"body":"","encoding":"utf-8","bytes":0,"truncated":false,"printed":"","printed_bytes":0,"diagnostics":{"version":1,"items":[],"truncated":false,"omitted":0}}The tool run of the MCP server takes the same form. The interface does not follow the
Location: the program reads it and asks for it with get.
What the server does with a form:
It takes a form only from its own address.
Hosthas to be127.0.0.1:<port>orlocalhost:<port>, anOrigin, if the browser sends one, has to name that address, andSec-Fetch-Site: cross-siteorsame-siteis refused. Otherwise the answer is 403, so another website open in the same browser cannot send a form to a page.It reads
application/x-www-form-urlencoded, with+as a space and%XXas a byte of UTF-8. Other encodings, such asmultipart/form-data, are answered with 415.It reads at most 64 KiB. A larger
Content-Lengthis answered with 413 before the body is read. A body that ends before itsContent-Lengthis answered with 400, one that stops arriving for 5 seconds with 408, andTransfer-Encodingwith 400.A field that is missing is answered with 400 and its name, unless the parameter is an
Option<&str>, which is thenNone. A field given twice or one that is not valid percent-encoded UTF-8 is answered with 400 and its name, also for anOption<&str>.A page without
pub fn post, and a file of the folder, answer a form with 405 andAllow: GET. A privatefn postis an ordinary function of the page, not an entry point.The status of a page answer is one of 200, 201, 202, 301, 302, 303, 307, 308, 400, 403, 404, 409, 410, 422, 429, 500 and 503. A
Locationis a path on this server: it starts with a single/and holds only visible ASCII characters. A status from 300 to 399 needs one. A page that answers otherwise gets 500 with the reason.The body of a page answer is sent as HTML.
Storing data
A page keeps data in files, with std::fs as in any Rust program. What it writes is there at the
next request and after a restart of the server. examples/ablage/ marks cases as done and keeps
them in .daten/erledigt.txt:
$ cd examples/ablage
$ rusterpret serveOpen http://127.0.0.1:8787/vorgaenge, press "Erledigt" next to A-101, stop the server with Ctrl+C,
start it again and reload: A-101 is still done. vorgaenge.rs shows the list and takes the form,
speicher.rs stores a case. Storing is ordinary Rust:
pub fn erledigen(&self, id: &str) -> io::Result<bool> {
fs::create_dir_all(&self.ordner)?;
let sperre = OpenOptions::new()
.create(true)
.truncate(false)
.write(true)
.open(self.ordner.join(Self::SPERRE))?;
sperre.lock()?;
let mut ids = self.erledigte()?;
if ids.iter().any(|vorhanden| vorhanden == id) {
return Ok(false);
}
ids.push(id.to_owned());
let entwurf = self.ordner.join(Self::ENTWURF);
let mut datei = File::create(&entwurf)?;
for vorhanden in &ids {
writeln!(datei, "{vorhanden}")?;
}
datei.sync_all()?;
fs::rename(&entwurf, self.ordner.join(Self::LISTE))?;
File::open(&self.ordner)?.sync_all()?;
Ok(true)
}The lock keeps two requests that store at the same time from both reading the old list: the server
runs every request on a thread of its own. The whole list is written into a new file and renamed
over the old one, so a reader sees the old list or the new one, and a write that fails leaves the old
list as it was. post answers 303 See Other only after this has returned, and the server sends
an answer only when the function has returned, so the browser gets the confirmation after the case
is stored. A form sent twice stores its case once.
The same with curl, started in a copy of examples/ablage:
$ curl -i -d id=A-101 http://127.0.0.1:8787/vorgaenge
HTTP/1.1 303 See Other
...
Location: /vorgaenge?erledigt=A-101
$ cat .daten/erledigt.txt
A-101
$ chmod 555 .daten
$ curl -i -d id=A-102 http://127.0.0.1:8787/vorgaenge
HTTP/1.1 500 Internal Server Error
...
<h1>Nicht gespeichert</h1>
<p>Vorgang A-102 wurde nicht gespeichert: Permission denied (os error 13). Der bisherige Stand ist unverändert.</p>
<p><a href="/vorgaenge">Zur Liste</a></p>
</html>The 500 comes from the page, which says why; it has no X-Rusterpret-Error, which marks the errors
of Rusterpret itself.
What a page can do with files:
read and write:
fs::read,fs::read_to_string,fs::write,File::open,File::create,File::create_new,OpenOptions,Read,WriteandSeek,BufReader,BufWriter,set_len,try_clone,fs::copyfolders and names:
fs::create_dir,fs::create_dir_all,fs::remove_file,fs::remove_dir,fs::remove_dir_all,fs::rename,fs::metadata,fs::read_dirwith the name, path, kind and metadata of every entry,fs::canonicalize,std::env::current_dir,std::env::set_current_dir,std::path::absolutelinks, permissions and times:
std::os::unix::fs::symlink,fs::read_link,fs::symlink_metadata,fs::hard_link,fs::set_permissions,File::set_permissions,File::set_times,File::set_modifieddurability and locks:
sync_all,sync_data,File::lock,lock_shared,try_lock,try_lock_shared,unlock
An error has the code and the text the system gives, as in a native program, and a test compares 35
cases with the same file built by rustc, on Linux and on a Mac. The order of the entries of a
folder is the order the system gives, which native Rust does not promise either, so the test
compares the names sorted. A path that ends with a slash follows the rules of each system: macOS
follows a link before the slash, Linux does not. Every file and folder a request opens is closed when
the request ends.
The working folder of a page is the served folder, or the folder of the file when the server serves
one file: std::env::current_dir answers it, and fs::canonicalize and std::path::absolute
give paths below it, as in a native program started in that folder. std::env::set_current_dir
changes it to another folder below the served folder for the rest of the request. The next request
starts in the served folder again.
A request that waits for a lock another request or another program holds waits at most 30 seconds.
Then it ends with 500, X-Rusterpret-Error: runtime and a message that names the file, and the log
of the server says that it gave up. --lock-limit sets another limit, see
Command line. A page that locks a file it already holds through another
File, which would wait forever in a native program, is answered with 501 at once.
A page reaches only the files below the served folder. A relative path starts at the folder the
server serves, also for a page in a subfolder, or at the folder of the file when the server serves
one file. A path out of it, with .., as an absolute path or through a symbolic link, ends the
request with 501 and names the path. It is not answered with an error a program could take for the
answer of the system. That holds for every call above: a link a page creates must lead into the
folder when it is made, a copy, a hard link and a change of permissions take only paths in it, and
reading a link that leads out, with fs::read_link or fs::symlink_metadata, ends with 501. The
target of a link a page creates may not hold .. either, also when it leads inside: such a link
would lead elsewhere once a page or the interface moved it or a folder above it, so the request
ends with 501, and so does a hard link a page makes of such a link. A relative target without .. leads down from the folder of the link, an absolute
one names one place, and neither leads out after a move. A link you lay yourself may hold .., and
a link of a page may pass through it. When a move makes such a link lead out, every access through
it is refused like any other path that leads out, by a page, by the interface and by the compiler.
A program outside Rusterpret that works on the folder follows the link as the system does.
fs::read_dir lists the names of a folder as the system gives them, a link that leads out among
them. The border also holds while the folders on a path change: every path is
walked from an open descriptor of the served folder, one folder at a time, and used relative to the
open folder that holds its last name, so a folder that is swapped for a link to somewhere else while
a call runs cannot lead the call out. The server reads a file it delivers and the source of a page
in the same way, so a link that a page makes after the server checked an address cannot lead the
answer out either. The server delivers no file whose path has a part that starts with a dot, so data
in a folder such as .daten cannot be fetched by a browser.
While the interface for programs is on, a page reaches only the files the interface reaches: the
served file alone when the server serves one file, and otherwise no path with a part that starts
with a dot. Other paths are answered with 501 then, and so is a listing of a folder that holds such
a name, when fs::read_dir reaches it, and a link to such a name (see
What a page can read while the interface is on).
examples/ablage stores with rusterpret serve. A page that is to store through the interface too
keeps its data in a folder without a dot, which the server also delivers to a browser.
A library from crates.io
A folder with a Cargo.toml and a Cargo.lock is a project, and its pages may call the libraries
the project depends on. research/2026-12-04-first-crate/project/ is such a project, the one the
tests of the first external crate use, in a checkout of this repository: its page index.rs calls
strsim 0.11.1 from crates.io.
pub fn run() -> i32 {
match strsim::hamming("café", "cafe") {
Ok(distance) => distance as i32,
Err(_) => -1,
}
}$ cd research/2026-12-04-first-crate/project
$ rusterpret serve
rusterpret: preparing the dependencies of /home/you/rusterpret/research/2026-12-04-first-crate/project with cargo ...
prepared the dependencies of /home/you/rusterpret/research/2026-12-04-first-crate/project in 336 ms (ready: strsim 0.11.1)
rusterpret 0.1.16 serving /home/you/rusterpret/research/2026-12-04-first-crate/project
http://127.0.0.1:8787/
$ curl http://127.0.0.1:8787/
1Change "cafe" to "Kanu", save and reload: 3. cargo run of the same project prints 1 and
3 as well.
When the server starts on a project, it prepares the dependencies before it prints its address.
It runs cargo metadata and cargo check of the toolchain of Rusterpret, against the standard
library it prepared, so that the compiler keeps the MIR of every function of a dependency. Nothing
is linked and no code of a dependency runs: the interpreter runs their MIR as it runs the page's.
Cargo runs offline (--frozen) with your cargo home: it uses what your own cargo build or
cargo fetch downloaded, and Rusterpret downloads nothing. When a source is missing, the page
answers 500 with the message of cargo and the advice to run cargo fetch in the project once.
Rusterpret never writes Cargo.lock, and it keeps what cargo checks in its cache folder, not in the
target folder of the project.
A change of a page prepares only the page. A change of Cargo.toml, Cargo.lock or a
configuration file of cargo prepares the dependencies again, and the next request waits for that, up
to the limit of an analysis (--analysis-limit). At the limit it is answered with 503, and the
preparation goes on for a later request. When cargo fails, the page answers 500 with the message of
cargo, and the server goes on serving; the dependencies are prepared again when one of those files
changes or the server starts. A page in a project is compiled with the edition of its package and
the features its package turns on. The operation describe of the interface names the state of the
dependencies and their packages.
What Rusterpret refuses before cargo check runs. Cargo itself decides what a project asks for:
Rusterpret reads the graph of cargo metadata and the plan of cargo check --unit-graph, which
lists every unit cargo check would build without building one, and never the text of Cargo.toml
on its own. It refuses with 501:
a build script and a procedural macro, and anything else that would be built for your machine to run there, because
cargo checkwould run it natively;a source other than crates.io: a dependency from git or from another registry, a path dependency, also one inside the served folder (a local library is not supported yet), and a package that
[patch]or[replace]takes from a folder;a project inside the workspace of a folder above, and a workspace with other members.
Cargo itself refuses every cargo-features of a manifest, in every spelling, because Rusterpret
starts it with -Zallow-features=: through such a feature a profile could make the compiler load a
library of native code even while it only checks. Unstable settings of cargo that could do the same
or change the linker, from a configuration or from the environment, are switched off for every call.
Cargo reads a private copy of exactly the Cargo.toml and Cargo.lock Rusterpret read, so a file
written while cargo works is not what cargo checks. As a last layer, the linker for build scripts and
procedural macros is a program that does not exist, and a wrapper of rustc from a configuration is
not used.
Whom this trusts. Without the interface for programs, Rusterpret prepares the dependencies on
the same trust as your own cargo build: with your environment and your configuration of cargo,
which can still set [env], [patch], [source], paths, include and build-dir for the
preparation of the dependencies. The page itself is compiled by Rusterpret, and [env], the
rustflags of a configuration and [lints] of Cargo.toml do not reach it, see the known limits.
While the interface is on, it guards against what a program that drives it or a page can write,
which is the files without a dot in the served folder: they can write Cargo.toml, but no .cargo
folder, cargo gets no environment but PATH, HOME and TMPDIR, and a setting of [unstable]
that is not true or false is refused. The message of cargo then reaches neither the answer nor the
log of the interface, because cargo quotes the files it reads, also a Cargo.toml outside the
served folder that a path dependency names; the answer names the kind of the failure and the file in
the cache folder where you find the message. With --api or rusterpret mcp the server does not
start when the served folder lies inside its cache folder, or its cache folder inside the served
folder below a first name without a dot; below a first name with a dot, as .cache when you serve
your home folder, the cache stays out of reach of the interface and of a page. Nor does it start
when the path of its cache folder leads through a folder or a link in the visible part of the served
folder, because a program could then decide where the next start puts the cache. Set
RUSTERPRET_CACHE then. A session of the playground prepares no dependencies and answers a
Cargo.toml as not supported there. A server that serves one file reads no Cargo.toml.
The idea
Some languages earned their place on the web by being immediate. You put a file on a server, request it, and it runs. You change a line, reload, and the change is there. Others earned it by asking nothing of the visitor except a browser. Rust has never felt like that: between saving and seeing there has always been a build.
Rusterpret is an attempt to give Rust that rhythm and keep the best of both worlds. You keep writing ordinary Rust. Every request runs code that has passed the real parser, the real type checker and the real borrow checker. And the distance between an idea and a visible result shrinks to a save and a reload. A visitor needs nothing but a browser.
This is version 0.1.16. 0.0.1 was the first complete path from a real .rs file to an answer in the
browser, for a deliberately tiny part of the language. 0.0.2 made that path correct and reliable.
0.0.3 ran ordinary Rust for the first time: your own data types, modules and the standard library.
0.1.0 was the first version with a proven milestone: its arithmetic was compared with native Rust on
25,456 edge cases, where nothing differed, and on the compiler's own 70 test files for arithmetic,
of which 66 end like the native programs and four are reported as not supported. Since 0.1.0 a panic
unwinds as in native Rust: catch_unwind catches it and destructors run. 0.1.1 hardened that
version. 0.1.2 added an interface for programs: an MCP server and an HTTP API. 0.1.3 corrects the
interpreter where it calls functions, among other things errors that returned wrong results, the
worst of them with a closure used as a function pointer and with a trait object converted to its
second supertrait. It lets a request start and end like a process, and it runs ordinary library
calls that 0.1.2 refused, such as collect into a Result and a search in a long text. 0.1.4 sends
the translated library functions of a page to the server once instead of with every preparation,
compares 22,400 calls with native Rust, and answers std::process::exit, the process number and the
texts of errors of the system. 0.1.5 lets a page answer a form with its own status and a redirect.
0.1.6 lets a page keep data in files below its folder, so that what a form sends is still there
after a restart of the server. 0.1.7 prepares a second platform: it answers what the standard
library of macOS asks of the system, among other things its calls for files, and it measures a fresh
installation step by step. 0.1.8 changes what a check on a Mac found: an address finds a file only
in the spelling its folder holds. 0.1.9 lets a page list a folder, copy a file, ask for its working
folder and for canonical paths, set permissions and make and read links, all below the served
folder, and it ends a wait for a file lock after a limit. 0.1.10 reads every branch that the
standard library takes because Rusterpret prepares it in the form it has for Miri, and corrects the
one a page saw without an error: the line that a panic inside some functions of the library names.
It also keeps every line a page prints, which since 0.1.0 lost a line that began like a note of
the panic hook, and on macOS it gives remove_dir_all the native result when a folder is swapped.
0.1.11 uses every path of a page where it was checked, through open folders, so that a folder
swapped for a link while a call runs cannot lead it out of the served folder, which with 0.1.10
let 20 of 22 calls out. It lets a page change its working folder and set the times of a file.
0.1.12 does the same for the operations of the interface for programs, for the files the server
delivers, for the source of a page and for the files a page is compiled from while the interface is
on, so that a page may make and move links again while the interface is on. 0.1.13 adds a
playground: an editor and a preview of one page in the browser, with a session of its own for
every tab, on the machine that runs it. 0.1.14 lets Codex and Claude Code drive it through MCP:
a section at the top of this README shows how, and the repository holds an entry for the MCP
Registry and a plugin for Claude Code. 0.1.15 runs pages that call a library from crates.io: a
folder with a Cargo.toml and a Cargo.lock is a project, cargo prepares its dependencies without
running any of their code, and the interpreter runs them. 0.1.16 gives an assistant the warnings
and the diagnostics of the compiler as data and the rule of the parameters of a page before its
first page. It is still a development tool for one
machine, and the list of what it cannot run yet is further down.
What 0.1.16 can run
Rusterpret 0.1.16 interprets ordinary Rust. A page is one .rs file with the modules it declares.
Area | Supported in 0.1.16 |
Types | all integer types, |
Your own types | structs, enums with data, unions, |
Expressions | every operator, |
Control flow |
|
Panics |
|
Standard library |
|
Files | below the served folder: reading, writing, appending, seeking, copying, creating and removing files and folders, listing folders, renaming, metadata, canonical paths, the working folder and changing it, permissions, the times of a file, symbolic and hard links (a link the page makes, also as a hard link of a link, holds no |
Unsafe code | raw pointers, |
Several files |
|
Libraries | the dependencies that a |
Entry point |
|
Results | an integer as plain text, text as HTML, a page answer with its own status and |
Results, text and panic messages are compared in the tests with the same files compiled natively. Every row of this table is covered by such a test, in the forms the test programs use. That is not every form the language has: before 0.1.3 function pointers were tested with functions and never with closures, and a closure used as a function pointer returned wrong results, as did a trait object converted to its second supertrait (see the changelog). Since 0.1.4 the calls are compared as a catalogue: 20 kinds of call with 10 lists of arguments and 28 types.
What a program reaches and Rusterpret cannot run is reported explicitly instead of being run wrongly. The answer is HTTP 501 and names it:
$ curl http://127.0.0.1:8787/
rusterpret: runtime error in `run`: the program reached a call to the foreign function `libc::unix::chown`, which is not supported yetNot supported yet: parameters of 128-bit integer types, files outside the served folder, the owner
of a file, the environment,
processes and sockets, threads, async closures, crates with a build script or a procedural macro,
local libraries, crates from git or from another registry than crates.io, foreign functions,
inline assembly, vector operations beyond the ones the library uses for text, f16, f128 and the
fast-math intrinsics.
How it works
Rusterpret reads the file of the requested page and keeps a snapshot of its content.
The Rust compiler front end runs in a separate analysis process that Rusterpret starts and keeps: parsing, type checking, borrow checking. Rusterpret links the compiler as a library (
rustc_driver). No object code is generated.Starting at
run, and atpostfor a page that takes a form, the analysis process asks the compiler for the MIR of every function the page can reach, with its generic arguments filled in. That includes the functions of the standard library, which Rusterpret prepared with their MIR at its first start.The MIR is translated into instructions owned by Rusterpret. They work on bytes: sizes, field offsets and the layout of enums are the compiler's own. The analysis process keeps the translated functions of the standard library for the next preparation of the same page, and sends the instructions and the constants back to the server. Kept library functions travel once: after the first preparation of a page only the ones that were added are sent.
Rusterpret's own interpreter executes them inside the server, in one block of memory per request with constants, a stack and a heap.
The result is sent as the HTTP response: an integer as plain text, text as HTML, a page answer with its status, its
Locationand its body as HTML.
For user code the server never runs cargo run, never starts a generated native program and never
uses Miri. The standard library is interpreted like user code. What the interpreter provides itself
(allocation, also for the allocator of the C library, the message of a panic and the unwinding
after it, intrinsics, mathematical functions, random bytes, standard output, the clock, the files
below the served folder, and what the runtime of the library does before and after main) is
listed in the changelog.
Live reload
On every request Rusterpret reads the file of the page and compares its content with the content it prepared last for that file. Only new content is prepared again. The prepared instructions are reused for every following request. A broken or unsupported file is remembered in the same way, so it is not analysed again on every request.
Every page is prepared on its own. While one page is being analysed, the prepared pages keep answering, and requests for the same new content wait for one shared preparation.
A page knows the files it was built from: its modules, the files it includes, and the module files the compiler looked for and did not find. When one of them changes or appears, the page is prepared again, and so is every other page that uses it. If one of them changes while the page is being prepared, the request that started the preparation gets its result, and the requests that waited for it share one new preparation.
Five response headers make this visible:
Header | Meaning |
| counter of prepared file contents since the server started |
|
|
| the kind of failure: |
| executed interpreter steps of this request |
| the |
Answers
Situation | Status | Body |
Number | 200 | the number as plain text, for example |
Text | 200 | the text as HTML |
Page answer | its status | its body as HTML, with |
Other file of a folder | 200 | the file, with the type of its extension |
Folder without a trailing | 301 |
|
| 400 | what is wrong with |
No page or file for the address, a | 404 | which files were looked for |
Other method than | 405 |
|
A form for a page without | 405 |
|
A form from another host or origin | 403 | short notice |
A form that is not | 415 | short notice |
A form larger than 64 KiB | 413 | short notice |
A form field missing, repeated or not of its type | 400 | what is wrong with the field |
Request head started but not complete after 5 seconds | 408 | short notice |
Request head larger than 8 KiB | 431 | short notice |
File does not compile | 500 | the compiler's diagnostic, unchanged up to 128 KiB as JSON counts it |
A panic that nothing catches (overflow, index, | 500 | function, position and the message native Rust would print |
The program reached something Rusterpret cannot run yet | 501 | what was reached |
File not readable | 500 | the reason |
Valid Rust outside the supported part | 501 | position and construct |
The analysis process failed (compiler panic, abort, killed) | 503 | what happened. The next request starts a new analysis process |
The preparation took longer than its limit | 503 | the limit, how long the request waited for a free analysis process and how long the analysis ran, or that no analysis process became free, and how to change the limit. A stopped analysis process is replaced for the next request |
A connection that never sends anything is closed without an answer. Browsers open such connections in advance.
After a correction the same address works again without a restart. A failure of the analysis process never ends the server: prepared pages keep answering, and the failed content is analysed again by the next request.
A preparation may take 30 seconds: the wait for a free analysis process, of which at most four run
at the same time, and the analysis together. If the analysis process has not answered by then,
Rusterpret stops it. The request that waited and every request that waited with it get the same
503, which says how long the request waited and how long the analysis ran. Other pages keep
answering, and the next request starts a new analysis. --analysis-limit sets another limit. The
measurements behind the 30 seconds are in BENCHMARKS.md.
Runtime errors and limits
Arithmetic is checked exactly as in a debug build of Rust, because the checks are the same code. A panic that nothing catches ends the request, not the server, after the destructors on its way have run:
$ curl 'http://127.0.0.1:8787/?x=2000000000'
rusterpret: runtime error in `double`: panicked at hello.rs:2:5:
attempt to multiply with overflowEach request may execute at most 100,000,000 steps, nest at most 1,000 calls, use a stack of 4 MiB and a heap of 64 MiB. A runaway program is stopped with a clear message and the server stays available. On the Linux test machine the step limit is reached after about 0.5 seconds.
This budget belongs to the running page and is counted in steps. A wait for a file lock counts no
steps, because the page does no work while it waits, and has a limit of its own in time: 30
seconds, or --lock-limit. The limit of an analysis belongs to
the preparation of the page and is measured in time.
MCP and API
Everything you do by hand with Rusterpret, a program can do too: list the pages, read and write the sources, run a page with values, read the compiler's warnings and diagnostics as data and read what the server logged. There are two ways in, and both offer the same eleven operations:
an MCP server for assistants that speak the Model Context Protocol,
an HTTP API with JSON for scripts and editors.
The operations
Operation | What it does | Changes files |
| version, toolchain, what is served, where a browser reaches the site, the limits of a request, how many pages are held prepared | no |
| every file of the folder with the address that answers for it, if one does | no |
| prepares a page as a request would: the parameters of | no |
| runs a page with named values, exactly as a | through the page it runs |
| answers any address as a browser gets it, pages and files alike | through the page it runs |
| analyses and runs a source text with | through the page it runs |
| the content of a file, Rust sources included | no |
| creates or replaces a file, from text or from base64, and the folders on the way to it | yes |
| moves or renames a file or a folder. Nothing is replaced: the new path must be free | yes |
| deletes one file or one empty folder | yes |
| lines of the server log: preparations, requests and what pages printed | no |
run, get and evaluate return what a browser gets: status, content_type, headers and
body, and in printed what the page wrote to standard output and standard error. A page that
does not compile is not a failed operation. It is an answer with status 500 and the diagnostic in
body, as in the browser.
An answer that comes from a page also carries diagnostics: what the compiler reported about the
source that ran, the warnings of a page it accepted, and the errors and warnings of one it did not.
Each entry has level, code (the lint, such as unused_variables, or the code of the error,
such as E0308), message, file, line, column, end_line, end_column and the compiler's
notes as text. version names the prepared state they belong to, the counter that
X-Rusterpret-Version and describe carry, so that a warning about source that has been replaced
is never taken for current. A request that finds the page prepared gets the same entries without a
second analysis. describe carries the same, and evaluate carries them without a version. At
most 1,000 entries come, with at most 128 KiB together as they are written in JSON, escapes
included, and a message or a note longer than 4,096 bytes of JSON is cut and ends with the number
of bytes left out; truncated says when entries were left out, and omitted how many. The entries come in the order the compiler reported them;
between different functions that order can change from one preparation to the next, as it does
with rustc itself, so do not rely on it. A file inside the served folder is named by its path
there, a file outside with a placeholder, <toolchain> for the standard library, and no field
holds a line of source. For an error inside a macro of another crate the entries name the place
inside the macro, as rustc --error-format=json does, and the text names the place where the macro
is called. The text in body and in the browser is the compiler's text, unchanged, up to 128 KiB
as JSON counts it: a longer text is cut, and its last line says how many bytes were left out. So an
answer with both stays below 1 MiB, also through MCP, which writes the result twice. The limit of
1,048,576 bytes of a body counts the bytes as they are, as it has since 0.1.2.
The instructions of the MCP server, the prompt new-page and the descriptions of describe and
run say which types the parameters of pub fn run and pub fn post may have, in the words of
the answer 501 that refuses another type, so an assistant learns the rule before its first page.
A page is ordinary Rust and can write, move and delete files in the served folder, so run, get
and evaluate, which run pages, can change files too. MCP marks them, like write, move and
remove, as tools that can change something (readOnlyHint false, destructiveHint true), and
GET /.rusterpret/api lists them with runs_pages. A page reaches no other computer: a socket and
the lookup of a name end the request with 501, because the interpreter does not run these calls. So
every tool says openWorldHint false.
A file is named by its path inside the served folder, for example blog/post.rs. Refused are a
path that leaves the folder, a name that starts with a dot, and a link that leads outside or to
such a name. When Rusterpret serves one file instead of a folder, only this file can be read and
written. pages and describe name files the way read takes them. pages does not enter a
folder that is a link. Of a link, remove deletes the link and never what it leads to, and
move moves no links. Every operation walks its path from an open descriptor of the served folder
and uses the last name relative to the open folder that holds it, as the calls of a page do, so a
folder swapped for a link between the check of a path and its use cannot lead an operation out.
One answer carries at most 1,048,576 bytes of a body, of a file and of what a page printed. A
longer body is cut and truncated says so, a longer file is refused by read, and printed_bytes
says how much a page printed in all. write takes as much as read returns. Text comes as text.
Content that is not UTF-8, or that holds control characters other than tab, line feed and
carriage return, comes in base64, and encoding says which of the two it is. write takes both
in the same way, so a picture can be read from one place and written to another.
pages lists at most 5,000 files and says in truncated when there are more. log returns the
newest 200 lines of the last 2,000 the server keeps, or with after the lines that follow a line
number. The kept lines hold 512 KiB of text at most, so there are fewer of them when the lines
are long. A line of more than 1,024 bytes is cut there and ends with its whole length.
MCP for an assistant
$ rusterpret mcp ./siteThis speaks MCP over standard input and standard output. That is how an MCP client starts a local server, so the line above is the command you give your client. Most clients take it in this form:
{
"mcpServers": {
"rusterpret": {
"command": "rusterpret",
"args": ["mcp", "/path/to/site"]
}
}
}For Claude Code the same is one command. It follows that client's own help and was not run for this version:
$ claude mcp add rusterpret -- rusterpret mcp /path/to/siteThe repository is also a marketplace for Claude Code. Its plugin starts rusterpret mcp over the
folder Claude Code works in, with a port the system picks:
$ claude plugin marketplace add LEVOGNE/rusterpret
$ claude plugin install rusterpret@rusterpretThe plugin holds no program, so rusterpret has to be on the PATH. On 2026-12-04 Claude Code
2.1.336 on the MacBook installed it with these two commands, with a checkout of this version in
place of LEVOGNE/rusterpret. Installed with --scope local for one folder, it listed its 11
tools in /mcp and made a page through it. Installed from GitHub it was not yet. The page answered 501 first, because its parameter was an
Option<String>, and the assistant corrected it to Option<&str> from the message.
In this mode nothing listens on a port and there is no token: only the program that started Rusterpret can talk to it. The log goes to standard error.
With a port the assistant and you look at the same site. The assistant works over MCP, and you open
the pages in the browser. about tells the assistant the address:
$ rusterpret mcp ./site --port 8787What the MCP server offers:
Part of MCP | What Rusterpret offers |
Tools | the eleven operations. Each has an input schema and an output schema. A result comes as |
Resources | every file of the served folder under its |
Prompts |
|
Protocol revisions |
|
Transports | standard input and output, and with |
An operation that is refused, for example a path outside the folder, is a tool result with
isError and the reason. An unknown tool and a malformed request are protocol errors.
Rusterpret does not send notifications. A client learns of a changed file when it asks again. Sampling, elicitation, completion and tasks are not there.
The official MCP Registry ties an entry to a crate by a line in the README of that crate. This is the line for Rusterpret:
mcp-name: io.github.LEVOGNE/rusterpret
The HTTP API
The API is off until you switch it on:
$ RUSTERPRET_TOKEN=my-secret rusterpret serve ./site --api
rusterpret 0.1.16 serving /home/you/site
http://127.0.0.1:8787/
api http://127.0.0.1:8787/.rusterpret/api and mcp http://127.0.0.1:8787/.rusterpret/mcp, token from RUSTERPRET_TOKENWithout RUSTERPRET_TOKEN Rusterpret makes a new token at every start, 16 bytes from the random
source of the system, and prints it in that line.
An operation that writes, moves or removes no file itself takes GET with a query or POST with
a JSON object, run, get and evaluate included. An operation that changes files itself takes
POST only:
$ curl -H 'Authorization: Bearer my-secret' 'http://127.0.0.1:8787/.rusterpret/api/describe?page=/double'
{"page":"/double","kind":"program","file":"double.rs","version":1,"prepared":"fresh","sources":[],"dependencies":{"state":"none","packages":[]},"state":"ready","parameters":[{"name":"x","type":"i32","example":"7"}],"returns":"integer","content_type":"text/plain; charset=utf-8","library_functions":{"kept":973,"translated":1},"diagnostics":{"version":1,"items":[],"truncated":false,"omitted":0}}
$ curl -H 'Authorization: Bearer my-secret' -H 'Content-Type: application/json' \
-d '{"page":"/double","arguments":{"x":21}}' http://127.0.0.1:8787/.rusterpret/api/run
{"status":200,"content_type":"text/plain; charset=utf-8","headers":{"X-Rusterpret-Steps":"443","X-Rusterpret-Version":"1","X-Rusterpret-Prepared":"reused"},"body":"42","encoding":"utf-8","bytes":2,"truncated":false,"printed":"","printed_bytes":0,"diagnostics":{"version":1,"items":[],"truncated":false,"omitted":0}}
$ curl -H 'Authorization: Bearer my-secret' -H 'Content-Type: application/json' \
-d '{"file":"triple.rs","content":"pub fn run(x: i32) -> i32 {\n x * 3\n}\n"}' \
http://127.0.0.1:8787/.rusterpret/api/write
{"file":"triple.rs","bytes":40,"created":true}
$ curl 'http://127.0.0.1:8787/triple?x=14'
42GET /.rusterpret/api lists the operations with their schemas.
Situation | Status | Body |
The operation was carried out | 200 | its result as JSON |
An argument is missing or wrong, or the operation needs | 400 |
|
No token or a wrong one | 401 | kind |
A path the server may not touch, or a request from another origin | 403 | kind |
No such file or operation | 404 | kind |
Another method than | 405 | kind |
A body of more than 4 MiB, in a request that carries the token | 413 | short notice |
A | 415 | kind |
The file system refused | 500 | kind |
Who can reach it
The server listens on 127.0.0.1 only, with and without --api. The interface answers a request
only when it carries the token, is addressed to 127.0.0.1 or localhost with the port of the
server, and names no other origin. A web page that is open in your browser can therefore not call it, although it runs on the
same computer.
While the interface is on, with --api or with rusterpret mcp --port, the server answers a page
and a file as well only when the request is addressed to 127.0.0.1 or localhost with the port of
the server. A request that names another host in its header Host gets 403 and the name it asked
for. This is meant for a web page whose own name was made to lead to 127.0.0.1: its requests still
carry that name. No browser was run against it. --host <name> adds a name, written exactly as the
request writes the header Host, for example --host dev.example:8787. The interface itself still
answers 127.0.0.1 and localhost only. Without the interface, rusterpret serve answers every
name as before, so that a tunnel or a proxy in front of your own site keeps working.
Whoever has the token can write and delete files inside the served folder, and nothing outside it.
Rusterpret prints a token it made itself into its log, so keep that log to yourself, or set
RUSTERPRET_TOKEN.
What a page can read while the interface is on
A page is Rust source, and Rust source can take in other files and the environment while it is
compiled: include_str!("../notes.txt"), #[path = "/somewhere/else.rs"], option_env!("HOME").
For pages you write yourself that is ordinary Rust. A program that writes pages for you could use
it to read what you never showed it. So while the interface is on, with --api or with
rusterpret mcp:
a page is compiled only from files the interface itself can read: files inside the served folder whose names do not start with a dot, and when one file is served, that file alone, so serve the folder when a page has modules. For any other file the compiler reports that it could not read it, also when a link inside the folder leads there, and the diagnostic ends with the files that were not read. The sources of the standard library stay readable, because diagnostics quote them,
the analysis runs with an empty environment, so
option_env!finds nothing andenv!does not compile,a running page reaches with
std::fsonly the same files: the served file alone when one file is served, and otherwise no path with a part that starts with a dot. Another path ends the request with 501, as a path outside the folder does, and so does a listing that reaches such a name, and a link to such a name. A page moves links as natively, because every path the server, the interface and the compiler check is used where it was checked, and it makes them as natively, except that a target with..ends the request with 501.in a project with a
Cargo.toml, cargo reads the manifests the project names, and a path dependency orpackage.workspacecan name a folder outside the served folder. No answer and no line of the log shows a line of such a file or the name of its package. The kind of the failure still tells a program whether a path it chose holds aCargo.tomlthat cargo can read, one it cannot read, or none; this stays, see A library from crates.io.
Without the interface nothing changes: rusterpret serve compiles what you wrote, with the files
and the environment you gave it, and a running page reaches every file below the folder, also one
whose name starts with a dot. A running page reaches the environment in no mode, because the
interpreter does not run that call yet.
A playground in the browser
rusterpret playground serves an editor and a preview: index.rs on the left, what the page
answers on the right. Save writes the file and loads the preview again, and a page that does
not compile shows the compiler's diagnostic in place of the preview. The browser only shows this.
The compiler front end and the interpreter work on the machine that runs the command, as they do
for serve.
$ rusterpret playground
rusterpret 0.1.16 playground, at most 8 sessions, each ends after 600 s without use, after 3600 s at the latest and when a call to it takes longer than 120 s, kept in /tmp/rusterpret-playground-8787
http://127.0.0.1:8787/
previews at http://127.0.0.1:41873/.rusterpret/preview/
isolation: none. Every session is a process of this user, so this is for development onlyEvery tab that opens the address gets a session of its own: a folder with a fresh index.rs, and
a Rusterpret that serves this folder and nothing else. The page a session starts with is a list of
three cases, each with a button:
Press "Erledigt" next to a case. The page stores that in a file of its session.
Change
const KNOPF: &str = "Erledigt";to another label and save. The buttons carry the new label, and the case you closed is still closed. The session went on, only its page is new.Open the address in a second tab. It starts with the untouched page and sees nothing of the first one.
Reset ends the session and starts a fresh one.
A session ends by itself after 600 seconds without use, after 3,600 seconds at the latest, and
when one call to it takes longer than 120 seconds, and its folder is deleted with it. The
playground holds 8 sessions at a time and tells a ninth visitor to come back later. A session takes
about 128 MiB of memory in its two processes after its first preview, so 8 sessions take about
1 GiB; the numbers are in BENCHMARKS.md.
The previews come from a second port, so for the browser the page you edit has another origin than
the editor around it, and every answer of a preview carries a Content-Security-Policy with
sandbox. A page lives below /.rusterpret/preview/<key>/ there and not at /, so it links to
its own addresses relatively, as the example does with <form method="post">. A Location that a
page answers with is passed on with that prefix.
A program reaches a session as it reaches a server with --api: the same eleven operations below
/.rusterpret/api/, and MCP at /.rusterpret/mcp, with the session as the token:
$ curl -X POST http://127.0.0.1:8787/.rusterpret/playground/session
{"session":"6aff…","preview":"http://127.0.0.1:41873/.rusterpret/preview/838c…/","file":"index.rs","idle_seconds":600,"isolation":"none"}
$ curl -H 'Authorization: Bearer 6aff…' 'http://127.0.0.1:8787/.rusterpret/api/describe?page=/'
{"page":"/","kind":"program","file":"index.rs","version":1,"prepared":"fresh","sources":[],"dependencies":{"state":"none","packages":[]},"form":{"parameters":[{"name":"id","type":"&str","example":"text"}],"returns":"response"},"state":"ready","parameters":[],"returns":"response","content_type":"text/html; charset=utf-8","library_functions":{"kept":973,"translated":250},"diagnostics":{"version":1,"items":[],"truncated":false,"omitted":0}}
$ curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' -d id=A-102 http://127.0.0.1:41873/.rusterpret/preview/838c…/
303 http://127.0.0.1:41873/.rusterpret/preview/838c…/
$ curl -s http://127.0.0.1:41873/.rusterpret/preview/838c…/ | grep A-102
<li><strong>A-102</strong> Rechnung senden: erledigt</li>The session and the key of a preview are 32 hexadecimal digits each and are shortened here.
What keeps a session apart, and what does not
Read this before you show a playground to anybody else.
In 0.1.16 the operating system keeps nothing apart. Every session is a process of the user who started the playground, with the rights of that user. What holds a page inside its session is Rusterpret itself, with the checks of the interface: a page is compiled only from the files of its folder and with an empty environment, and a running page reaches the files below its folder and neither the environment nor a socket nor another process. A test writes eleven such attempts into the page of one visitor, among them a file outside at compile time and at run time, the source of the neighbouring session, a link that leads out, an outgoing connection, a loop and an allocation without an end, and checks that none of them gets anything from outside and that the neighbour and the file outside are untouched.
These checks were made for a program that writes pages for you. They are no border against a
stranger. An error in the interpreter or in the compiler would be an error with the rights of your
user, and while the run of a page is bounded in steps and memory, its analysis is bounded only in
time. So the playground listens on 127.0.0.1 only, answers only requests that are addressed to
127.0.0.1 or localhost with its port or to a name given with --host, and there is no public
playground and no link to one.
A second border is written and has never run. With --machine, --kernel and --image every
session is a virtual machine of its own, started by Firecracker without a network device, with a
read-only image of the runtime and with its folder in memory. The Linux test machine cannot start
virtual machines, so only the start was checked, against a stand-in for Firecracker. Whether the
machine boots, what it costs and whether it holds is open, see
Known limits.
Command line
rusterpret [serve] [<folder> | <file.rs>] [--port <port>] [--analysis-limit <seconds>] [--lock-limit <seconds>] [--api [--host <name>]]
rusterpret mcp [<folder> | <file.rs>] [--port <port> [--api] [--host <name>]] [--analysis-limit <seconds>] [--lock-limit <seconds>]
rusterpret playground [--port <port>] [--preview-port <port> | --one-address] [--sessions <number>] [--idle <seconds>] [--lifetime <seconds>] [--call-limit <seconds>] [--host <name>] [--machine <program> --kernel <file> --image <file> [--memory <MiB>] [--processors <number>]]Without a folder or file the current folder is served.
serve answers browsers. The server listens on 127.0.0.1 only. The default port is 8787. With
--port 0 the system picks a free port and Rusterpret prints it.
mcp answers an MCP client over standard input and standard output and listens on no port. With
--port it serves the site to a browser as well.
--api switches on the HTTP API and MCP over HTTP below /.rusterpret/, see
MCP and API.
--host adds a name under which the server answers while the interface is on, see
Who can reach it.
--analysis-limit is the time one preparation may take, the wait for a free analysis process
included, in whole seconds from 1 to 3600. The default is 30.
--lock-limit is the time a request waits for a file lock, in whole seconds from 1 to 3600. The
default is 30.
playground serves the editor of A playground in the browser at
--port and takes no folder: every session gets one of its own below the temporary folder of the
system, and the folders of an earlier playground at the same port are deleted at the start.
--preview-port is the port the previews come from. Without it the system picks a free one and
Rusterpret prints it. --one-address serves the previews at the port of the editor instead, for
a place that offers one port only. Then only the sandbox of the browser keeps a preview apart from
the editor, and the log says so.
--sessions is the number of sessions at a time, from 1 to 1000. The default is 8. --idle is
the time after which a session ends that was not used, --lifetime the time after which it ends
in any case, and --call-limit the time one call to a session may take before the session is
ended, each in whole seconds from 1 to 86400. The defaults are 600, 3600 and 120.
--host names one more address the playground answers to, for example play.example:8080 behind
a proxy that passes the name on. It can be given several times. The playground still listens on
127.0.0.1 only.
--machine, --kernel and --image start every session in a virtual machine: the Firecracker
program, the kernel of the guest and the image with the runtime, on Linux with KVM. --memory is
the memory of one machine in MiB from 128 to 65536, by default 1024, and --processors its number
of processors from 1 to 32, by default 1. These options have never started a real machine, see
What keeps a session apart, and what does not.
Requirements in detail
Rusterpret uses compiler internals, so it needs one exact nightly toolchain with three extra components. The installer takes care of this. The details:
Requirement | Value |
Toolchain |
|
Components |
|
Disk space | 1.0 GB for the toolchain on macOS, 1.5 GB on Linux, and 100 MB for the prepared standard library |
Cache folder |
|
Linker | the system linker: on macOS from the Command Line Tools of Xcode ( |
Tested platform | 0.0.2 to 0.1.16: Ubuntu 26.04 on x86_64 ( |
The built program finds the compiler libraries of that toolchain through an rpath set by build.rs,
so the toolchain must stay installed. Your normal Rust toolchain is not changed. A stable toolchain
cannot build Rusterpret and stops with error[E0463]: can't find crate for rustc_driver.
From source
$ git clone https://github.com/LEVOGNE/rusterpret
$ cd rusterpret
$ rustup toolchain install
$ cargo run --release -- serve ./examples/calculator.rsInside the checkout rustup toolchain install reads rust-toolchain.toml and installs exactly what
is needed. cargo install --path . installs the rusterpret command from the checkout.
What was actually run
Every command in this table was executed on the Linux test machine on the final code of 0.1.16,
before it was published. That machine keeps the port 8787 free for other work, so every serve and
every mcp with a port ran there with another port, and every curl asked that port:
Command | Result |
| installs |
| 10.42 s from a clean target directory in the measurement, at a load of 2.5, binary of 1,945,056 bytes on the final code |
| serves on |
| same, without cargo |
| installed command serves on |
| the crate as it is published installs and serves |
the same install with the stable toolchain | fails as described above |
the first start of the installed command with an empty cache folder | prepares the standard library into 100 MB, then serves: in 14.3 to 14.6 s in the measurement, and in 14.6 s in the run of this table |
|
|
|
|
|
|
|
|
| the start page with |
|
|
| A-101 and A-103, and A-101 alone after changing the status of A-103 in |
| 200 and the form with the button "Erledigt" |
|
|
| 400 with the page's message, 400 with |
a text changed in | the next request shows the new text |
| the answer shown there, with status 303 and the |
|
|
the same server stopped with Ctrl+C and started again, then | A-101 is still done |
| 500 with |
a page that changes the owner of a file, one that reads the environment and one that starts a thread | status 501 with the name of the function that was reached, and for the thread |
a page that copies a file, lists its folder and asks for its working folder | the number of copied bytes, the sorted names of the folder and the served folder as the working folder |
a page that changes its working folder, reads a file there and sets its time of modification |
|
a page that reads | status 501 and |
a folder with | the program answers, with |
| prepares the dependencies with cargo in 383 ms before it prints its address, then |
the same project with | the first ends with exit code 2 and names the cache folder inside the served folder; the second serves |
| the answers shown there: the description of |
the first of these | status 401, and status 403 |
with |
|
with | 501 with the sentence about |
with | both carry in |
| eleven tools, three prompts, the files of the folder as resources, and |
|
|
| the tool |
the same with |
|
| 403, and 200 with the address of the server; without |
|
|
|
|
the two commands of the section "Use with Codex or Claude Code" | not on the Linux test machine, where neither client has a login. They ran on a MacBook, as that section says |
opening the address in a browser, editing the file, reloading | not repeated since 0.0.1, because the browser of the test machine may not open local addresses. Last run with 0.0.1 on a Mac |
| the answers shown there: a session with its preview, the description of its page, |
in that session | two buttons "Abhaken", none "Erledigt", and A-102 still done |
a second | three buttons "Erledigt" and no case done |
| the old preview answers 404 and the old session 401, and the new preview shows three buttons "Erledigt" and no case done |
a page with a type error written into a session, then | 500 with |
| 404 each |
| 403 each |
| the second answers 503 with the kind |
| 200, then 404 |
| the preview is the relative address |
| 40 checks passed |
the page of the playground in a browser | not on the Linux test machine, which has no browser for it. The checking agent opened it in Chromium 158 on macOS 27.0.1 on the code of 0.1.13, commit |
a session in a virtual machine ( | not run. The Linux test machine has no access to |
| 170 tests passed, 2 ignored: the benchmark and the endurance run |
| every test passed except one that compares vector code of x86_64 and is left out on purpose |
| the measurements in |
| format, lint, the fuzz package, tests, the check with the reference client, deep random run, three minutes of fuzzing for each of the four targets and package passed |
The one-line installer and the installation from crates.io can only be run once a version is public. That check is the last step of every release, and its result is recorded in the changelog. The path for a machine without Rust is run with an empty home directory, so that nothing on the test machine is changed.
Tests and contributing
$ cargo testThe tests start the real server, send real HTTP requests and compare the answers with natively
compiled Rust: the same .rs files that Rusterpret interprets are also compiled into the test program,
and both must agree for fixed inputs, edge values and seeded random inputs. Where native Rust panics
with an overflow, Rusterpret must answer with an overflow error. Pages that return text must agree
character by character.
The interface for programs is tested in the same way. The same calls go through the HTTP API, through MCP over HTTP and through MCP over standard input and must return the same, and every result is checked against the schema its tool announces.
CONTRIBUTING.md explains how to set up a checkout, how the tests are organised,
which rules the code follows and how a release is made.
Documents
CHANGELOG.md: what each version contains, the decisions behind it and what was learnedBENCHMARKS.md: all measurements, with method and machineCONTRIBUTING.md: development, tests, rules, releases (English only)
This README, the changelog and the benchmarks are maintained in six languages: English, German, Spanish, French, Turkish and Arabic. The program's own messages and the compiler's diagnostics are English.
Known limits of 0.1.16
Two entry points per page,
runforGETandpostfor a form. A page chooses its status and aLocation, no other headers and no cookies. A form is read asapplication/x-www-form-urlencodedof at most 64 KiB, without files.A panic has no backtrace. The text of the default panic hook goes to the log of the server, without its note about backtraces.
A link a page makes may not hold
..in its target, also when the target lies inside the folder, and neither may a hard link a page makes of a link: the request ends with 501, where native Rust makes the link. A relative target without..and an absolute one stay inside after any move. A link you lay yourself may hold.., and every access through it is checked.In a diagnostic Rusterpret names types with their whole path,
std::string::StringwhererustcwritesString, and a long type in full, whererustcwrites it to a file. The text of the diagnostics of one preparation ends after 128 KiB, as JSON counts it, with a line that says how much was left out.A parameter of
runorpostof a 128-bit integer type, or of type&mut str, ends the request with 501.The page of a project is compiled by Rusterpret, not by cargo, and part of what cargo gives a crate does not reach it. Three cases answer 200 with another value than
cargo run:option_env!("CARGO_PKG_NAME")and the other variables cargo sets giveNone; therustflagsand the[env]of a configuration of cargo do not apply, socfg!(fast)afterrustflags = ["--cfg", "fast"]is false and a variable of[env]is not there; andpanic = "abort"of a profile is not seen, socfg!(panic = "abort")is false.env!of a variable cargo sets answers 500. A lint that[lints]ofCargo.tomldenies does not stop the page, which answers 200 where cargo stops with the lint. A crate that deniesunused_crate_dependencies, for example with#![deny(unused_crate_dependencies)], and does not use a dependency of itsCargo.tomlanswers 500 with that lint, wherecargo runruns. The version that brings a local library corrects the profile and the last case; the variables of cargo,[lints]and therustflagscome later, through the calls of the compiler that cargo makes itself.A
#[global_allocator]that a dependency declares is not used, and the page answers 200 with another value thancargo run: with an allocator that counts allocations of 12,345 bytes it answers12345 0wherecargo runprints12345 1. A#[global_allocator]in the page itself is used. The version that brings a local library corrects it.When a module is found twice, as
a.rsand asa/mod.rs, the page answers 500 with E0761, and after one of the two files is removed it still does; also without aCargo.toml. Abuild.rsthat appears in a project after the server started is not noticed until the server starts again orCargo.toml,Cargo.lockor a configuration of cargo changes; natively cargo would run it, Rusterpret runs no build script. The version that brings a local library corrects both.A page reaches only the files below the served folder, and while the interface for programs is on, only those the interface reaches. Every path is used through open folders, by the calls of a page, by the operations of the interface, by the delivery of a file and by the compiler while the interface is on, so a folder swapped for a link between the check of a path and its use cannot lead it out. A file whose path changed in that moment is not delivered (404). On a file system that cannot name a file relative to an open folder (no
/proc/self/fdand no/.vol), a change of permissions, a folder with a mode, links and a path through a link end with 501, and the interface does not read or write through a link there. A folder that another program moves out of the served folder while a page works in it stays usable for that request by names below it, as natively, but a page cannot go up out of it. The owner of a file cannot be changed yet. File access on macOS has been checked on a Mac with the storage example and the tests of 0.1.8 to 0.1.11; the tests that swap a folder while a call runs have not run on a Mac.A request that waits for a file lock tries again every 1 to 16 ms, so it may take up to 16 ms longer than a native program to get a lock that was released, and its wait does not show in
/proc/locks. After 30 seconds, or--lock-limit, it ends with an error.The environment, threads, other crates and foreign functions are not supported yet.
Condvarand standard input are not supported either. The changelog of 0.1.3 lists what else its review found unsupported, and the one of 0.1.4 which of these work now.In a few places a page shows something else than the same file built as a native program:
std::any::type_nameandmodule_path!name the crate of a pagerusterpret_source, a panic inside the library always names the file in the folder of the toolchain, on x86_64 aHashMapwith a fixed hasher is walked in another order and a smallHashSetcan have a smaller capacity,Backtrace::force_capture()captures nothing, andis_x86_feature_detected!andis_aarch64_feature_detected!report only the features the target enables at compile time. The changelogs of 0.1.3 and 0.1.10 have the list.A
staticstarts with its initial value in every request. What a page keeps beyond a request, it writes into a file.Undefined behaviour in
unsafecode is not detected.Every
.rsfile of a folder is a page, a module file too. Asked directly, a module answers that its entry point is missing.A file is checked when a request arrives. There is no background watcher.
An analysis that is stopped at its limit is not explained. The answer does not say what the compiler was doing.
Only the newest content of each page is kept. Returning to an earlier content prepares it again.
One thread per connection, no keep-alive. This is a development server for one machine.
When the interpreter stops a page itself, at a limit or at something it cannot run, the output that still stood in the buffer of standard output is lost. Everything up to the last line feed is in the log.
The MCP server sends no notifications. A client learns of a changed file when it asks again. It was checked with the official TypeScript client for MCP and with no assistant.
The interface cannot start or stop a server. It gives a page a body only as a form, with
runandevaluate, as a browser does.The playground keeps its sessions apart with the checks of the interface and with nothing of the operating system. It is for your own machine, and it listens on
127.0.0.1only. A virtual machine for every session is written: the options, the first process of the guest and a script that builds the image. None of it has run in a machine, because the Linux test machine has no access to/dev/kvm: not the boot, not the limits and not one attack against it. The test of the eleven attempts to get out of a session ran on Linux only. A playground that is killed leaves the folders of its sessions behind until the next one starts at that port, andabouttells a session the path of its folder on the machine.The page of the playground was opened in one browser, Chromium 158 on macOS. Firefox and Safari have not shown it. The editor is a plain text field for the one file
index.rs, without highlighting and without completion, and a file of more than 1 MiB is not taken. The page in the preview is the example as it is, without styles of its own.A page in a preview lives below
/.rusterpret/preview/<key>/. A link or a form that names an address from the root, likehref="/about", leaves the preview and gets 404.The first request after an edit takes 6 to 38 ms on the Linux test machine, depending on the page. A request that arrives at the moment the server has started takes about 36 ms, and one that arrives 0.2 seconds later 28 ms. The numbers are in
BENCHMARKS.md.A project may depend only on crates from crates.io without a build script, without a procedural macro and without
#![feature], which cargo forbids them because Rusterpret starts it with-Zallow-features=. A local library, a crate from git or from another registry and a workspace with members are refused. Cargo runs offline: what is not in the cargo home is fetched withcargo fetch, by you. A preparation that failed is kept untilCargo.toml,Cargo.lockor a configuration file of cargo changes or the server starts. A server that serves one file reads noCargo.toml. With the interface on, the server does not start when the cache folder lies inside the served folder below a first name without a dot, as~/Library/Caches/rusterpreton macOS does when the home folder itself is served;RUSTERPRET_CACHEnames another folder then. What cargo checked stays in the cache folder, in a folder for each project. None of this has run on a Mac.Installing needs the Rust toolchain manager, 1.0 to 1.5 GB for the pinned toolchain, and 15 seconds at the first start.
Every version prepares a standard library of its own. After an update the folder of the older version stays in the cache folder until you delete it.
The server keeps about 3 MiB of memory for every prepared page. Each of its analysis processes, of which there are at most four, takes 30 MiB before its first preparation and 98 to 140 MiB afterwards.
License
Rusterpret is licensed under either of
Apache License, Version 2.0 (
LICENSE-APACHE)MIT license (
LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Rusterpret by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Scrape, crawl, map & search the web. Open-source, self-hostable Rust crawler & search for AI agents.
Draw diagrams, build HTML pages and write Markdown in a live editor the user sees.
Comment on AI-generated webpages; feedback flows back to your coding agent. Free, MIT, local-first.
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA MCP server to allow the LLM in Cursor to access Rust Analyzer, Crate Docs and Cargo Commands.83-
- FlicenseNot gradedqualityDmaintenanceA lightning-fast, language-agnostic code analysis MCP (Model Context Protocol) server built in Rust9-
- FlicenseNot gradedqualityBmaintenanceOne Rust binary AI coding agents call for code and document work: ripgrep/fd-compatible search from a self-refreshing trigram index, symbol reads, PDF/Office/HWP text, AST rewrites and compare-and-swap edits that never overwrite another agent's change. Ships a local stdio MCP server (no API keys, no network calls).3-
- AlicenseNot gradedqualityBmaintenanceA Rust MCP server for searchable project memory, versioned investigation evidence, and private coding preferences. Run it locally over stdio or self-host it with revocable device tokens.MIT