laravel-rust-studio 0.1.1

See what a running Laravel for Rust application did: requests with their queries, errors with their source lines, mail, queued jobs, and durable workflows. For you in the browser, and for coding agents over MCP.
Documentation

Studio shows every request with its queries, each error with its source line, the mail the application sent, its queued jobs, and its durable workflow runs. Laravel for Rust already traces all of that, and Studio listens, so your application needs no instrumentation.

Install

cargo add laravel-rust-studio

Add the provider in src/app.rs:

use laravel_rust_studio::StudioServiceProvider;

Application::configure()
    .with_providers(|providers| {
        providers.add(StudioServiceProvider::new());
    })

Run the application and open /studio.

Studio is a community package. It isn't affiliated with Laravel.

What it shows

Traces. Each request, queued job, workflow advance, console command, and scheduled task is a trace: a timeline of its queries, cache operations, outgoing HTTP requests, and mail. A query shows its SQL, the types of its bindings, and the line of your code that built it.

Problems. Studio looks through what it captured for errors and panics, N+1 queries, slow queries, slow requests, failed outgoing requests, failed and overdue workflow runs, failed jobs, and queues that are paused or can't be reached. Each problem names the line behind it and says when it was last seen.

Workflows. Durable workflows are new in Laravel for Rust, and the framework ships no interface for them. Studio lists the runs and shows each one's steps with their outputs, tries, and timing, the token a run waits for, and the values it was resumed with. You can resume a waiting run with a value, retry a failed run from the step that failed, and cancel a run.

Queues. Each queue's depth, the jobs waiting on it, the attempts workers ran, each batch's progress, and the jobs that failed for good, with their errors and payloads. You can retry or delete failed jobs, cancel a batch, pause and resume queues, and tell workers to restart.

Mail. With the log mailer, which is the default, Laravel sends nothing. Studio keeps each email and text message, renders its HTML, and pulls out its links and codes, so a verification link or a sign-in code is one click away.

Exceptions and logs. Every error the application reported, with its type, its causes, and where it was raised, and the application's log lines, each linked to the trace it happened in.

The web server and its queue workers are separate processes, and Studio shows them together. An email that a workflow step sends from a worker shows up in the browser a second later.

For coding agents

An agent working on your application can't see the terminal the server logs to, and shouldn't have to query the database to learn what a request did. Studio gives it the same facts you see, in a form it reads well.

curl -s "http://localhost:8000/studio/api/agent/diagnose?format=markdown"
# Diagnostics — CRITICAL (2 critical, 1 warning)

1. **CRITICAL** [exception] at `src/http/handlers/invoices.rs:44:20`: InvoiceRenderFailed: the invoice PDF couldn't be rendered — 12s ago
   Caused by: No such file or directory (os error 2). Raised during GET /invoices/7.
   → Read the code at the location, and what the application did before it failed.
   → GET /studio/api/traces/610a47d9a50c519d07c26aafca42b490
2. **CRITICAL** [workflow_failed]: Workflow `orders.charge` failed — 14s ago
   the step `charge card` failed: the payment gateway declined the charge: gateway offline
   → Fix what made the step fail, then retry the run, which continues from that step.
   → GET /studio/api/workflows/01a2339e-0c7e…, then POST /studio/api/workflows/01a2339e-0c7e…/retry
3. **WARNING** [n_plus_one] at `src/http/handlers/posts.rs:54:22`: N+1 query: the same SELECT ran 10× in one trace (0.6ms) — 9s ago
   select "users".* from "users" where "users"."id" = ? limit ?
   → Load the rows in one query: eager load the relationship with `.with(...)`, count with `with_count`, or filter with `is_in(...)`.
   → GET /studio/api/traces/85ca778fd678e2cf1d144b948753bb43

After the agent changes the code and sends a request, it reads what that request did:

curl -s "http://localhost:8000/studio/api/agent/last-request?format=markdown"
# GET /posts → 200 — 4.8ms
request trace `93e1942137a86aa7202fccffa61fc8b5`, captured by `serve` just now. 21 queries in 1.2ms, 18 of them repeats (N+1).

## Spans
- +0.0ms GET /posts (4.8ms)
  - +0.3ms SELECT posts (0.1ms) `select "posts".* from "posts" order by "posts"."votes" desc` at `src/http/handlers/posts.rs:50:60`
  - +0.8ms SELECT users ×10 (0.5ms in all) `select "users".* from "users" where "users"."id" = $1 limit 1` at `src/http/handlers/posts.rs:54:22` ← N+1
  - +1.0ms SELECT comments ×10 (0.5ms in all) `select count(*) as "aggregate" from "comments" where "comments"."post_id" = $1` at `src/http/handlers/posts.rs:55:78` ← N+1

Asked again after that, diagnose lists the problems from before the restart apart, under Before the server restarted, and leaves them out of its status. A change to the code rebuilds and restarts the application, so the code that runs now hasn't shown them, and the report says whether the fix held instead of repeating what was wrong before it. ?since=60 narrows the report to the last minute, for a change that restarts nothing.

When a request sets off work that finishes later, the agent waits for it instead of sleeping. This call answers as soon as a queue worker sends the email:

curl -s "http://localhost:8000/studio/api/agent/wait?for=mail&contains=ada@example.com&timeout=20"

Its answer carries the email's extracted_urls and extracted_codes, so an agent can sign a user up, follow the verification link, and carry on.

There are three ways to connect an agent:

The skill laravel studio:skill writes .agents/skills/laravel-rust-studio/SKILL.md, next to the skills a new Laravel application ships with. It teaches an agent when to ask Studio and what to ask, and needs only curl. It's also served at /studio/skill.md.
MCP Studio is an MCP server at /studio/mcp, over Streamable HTTP. With Claude Code: claude mcp add --transport http laravel-studio http://localhost:8000/studio/mcp. The Agents page in Studio has the setup for other clients.
The API Every page reads a JSON API that's listed at /studio/llms.txt. A response's X-Request-Id header is its trace's ID, so GET /studio/api/traces/<id> is that exact request.

The MCP tools are studio_summary, studio_diagnose, studio_trace, studio_traces, studio_queries, studio_exceptions, studio_logs, studio_mail, studio_workflows, studio_workflow, studio_resume_workflow, studio_retry_workflow, studio_cancel_workflow, studio_queues, studio_retry_failed_job, and studio_wait.

How it works

Studio adds a layer to the application's logger. The layer reads the spans and log lines Laravel already emits, and builds traces from them. A query listener adds what a span doesn't carry: the SQL as it was sent, the types of its bindings, and the line that built the query. Bound values stay hidden unless a query binds them with bind_visible, as they do in Laravel's own logs.

Each process appends what it captures to a file in storage/studio, and the process that serves Studio reads the other processes' files. That's how a worker's traces reach the browser, and how what Studio captured survives the restarts laravel dev does on every save. The files are capped in size, deleted after a day, and kept out of Git by the directory's own .gitignore.

Studio keeps the latest 500 traces, 2,000 queries, and 2,000 log lines in memory. It leaves out its own requests, and requests for files such as /favicon.ico and your built assets.

Workflow runs, queued jobs, failed jobs, and batches are read from their tables, and Studio's actions do what the workflow:* and queue:* commands do.

Requirements

  • laravel-rust 0.1.3 or later.
  • A database driver feature on laravel-rust, which nearly every application has.
  • The Workflows page lists runs from the database workflow store, which is the default. With another store, it shows the runs Studio saw advance.
  • The Queues page shows the depth of each queue in use, whatever its driver, and the failed jobs. It lists the waiting jobs of database queues, and it retries failed jobs onto database queues.
  • Studio reads those tables on SQLite, PostgreSQL, and MySQL, and its tests run against all three.

An application without a database turns Studio's database feature off:

laravel-rust-studio = { version = "0.1", default-features = false }

Who can open it

Studio answers in the local and testing environments. Everywhere else it responds 403 and captures nothing, so leaving it installed costs a production deployment nothing.

To open Studio in another environment, decide who may see it. Studio shows queries, mail, and job payloads, and it can cancel workflows and delete failed jobs, so choose carefully.

providers.add(StudioServiceProvider::new().authorize(|request| {
    let token = &laravel::config().section::<Services>().studio_token;

    request.bearer_token() == Some(token.as_str())
}));

authorize receives each request to Studio and decides alone, in every environment. Services here stands for a config section of your own. To check the signed-in user instead, add middleware, which puts Studio's routes in the web group so the session is available:

use laravel::auth::Authenticate;

providers.add(
    StudioServiceProvider::new()
        .authorize(|_| true)
        .middleware((Authenticate, ensure_user_is_admin)),
);

Locally, Studio answers only to requests for a local host name: localhost, an IP address, *.localhost, *.test, and the host in APP_URL. That keeps a page on another site from reading it through your browser. Add other names with STUDIO_ALLOWED_HOSTS.

Configuration

Set these in .env:

Variable What it sets Default
STUDIO_ENABLED Whether Studio is installed at all true
STUDIO_PATH Where Studio is served studio
STUDIO_ALLOW_IN_PRODUCTION Opens Studio outside local and testing without an authorize callback false
STUDIO_ALLOWED_HOSTS Extra host names Studio answers to locally, separated by commas None
STUDIO_MCP_ENABLED Whether the MCP server answers true
STUDIO_SLOW_QUERY_MS How long a query takes before it counts as slow 100
STUDIO_SLOW_REQUEST_MS How long a request takes before it counts as slow 500
STUDIO_IGNORE_PATHS Request paths to leave out of the traces, separated by commas None
STUDIO_MAX_TRACES, STUDIO_MAX_QUERIES, STUDIO_MAX_LOGS, STUDIO_MAX_EXCEPTIONS, STUDIO_MAX_MAILS How many of each Studio keeps 500, 2000, 2000, 500, 200
STUDIO_JOURNAL Whether processes share what they capture through storage/studio true
STUDIO_JOURNAL_MAX_MB, STUDIO_JOURNAL_HOURS How much disk the shared files may use, and how long they're kept 32, 24

Or change the section in src/app.rs:

use laravel_rust_studio::StudioConfig;

.with_config(|config, _| {
    config.section_mut::<StudioConfig>().slow_query_ms = 25;
})

Try the demo

The repository has a small application with an N+1 query, a slow query, a handler that panics, a job that fails, and three workflows, one of which waits for approval:

git clone https://github.com/n7olkachev/laravel-rust-studio
cd laravel-rust-studio/demo
cp .env.example .env
cargo run -- key:generate
cargo run -- migrate
cargo run                    # the server, in one terminal
cargo run -- queue:work      # a worker, in another
./tour.sh                    # sends the requests that fill Studio

Then open http://127.0.0.1:8000/studio.

Developing

The interface is a React application in ui/, built into dist/, which the crate embeds. An application that installs Studio needs neither Node nor Vite.

cargo test                           # the crate's tests, against SQLite in memory
cd ui && npm install && npm run build

To run the tests against PostgreSQL or MySQL, name a database that the user may create copies of:

STUDIO_TEST_DATABASE_URL=postgres://postgres@127.0.0.1/studio_test \
    cargo test -p laravel-rust-studio --features database-postgres --test studio
STUDIO_TEST_DATABASE_URL=mysql://root@127.0.0.1/studio_test \
    cargo test -p laravel-rust-studio --features database-mysql --test studio

In a debug build, Laravel serves dist/ from disk, so npm run dev in ui/ rebuilds the interface as you edit it, without recompiling the demo.

License

MIT