Watching your workflows

MCP

From docs/mcp.md at commit 548821a.

Spinto 0.1.0. These docs follow the main branch. Spinto isn't on crates.io yet, so you install it from a clone.

Introduction

Spinto serves its workflow records to agents over the Model Context Protocol. An agent can list runs, open one, read a journal entry, and search, and it gets the same records the dashboard shows: the same spinto.v1 contract, the same payload redaction, and nothing the dashboard wouldn’t show.

The tools only read. None of them retries, cancels or resumes a run, and Spinto never writes to the workflow tables. Search is plain keyword matching over stored fields. There are no embeddings and no calls to an outside AI service.

There are two ways in:

  • stdio: the spinto:mcp console command. An MCP client on your machine starts it and talks to it over stdin and stdout. Use it in development, or on a server where you already have a shell.
  • HTTP: POST {SPINTO_PATH}/mcp, which is /spinto/mcp by default. It exists only when SPINTO_MCP_TOKEN is set, and every request must carry that token.

Connecting a client

Laravel for Rust reads .env from the directory the application starts in, so a stdio client must start spinto:mcp from your application’s directory. The examples below cd there first, because a client may start its servers from any directory.

Build the application before you add it to a client. The first cargo run compiles the application, which can take longer than a client waits for a server to start (the MCP Inspector gives up after 15 seconds). After a build, the command starts in about two seconds.

cd /path/to/your-app
cargo build

Log lines must not reach stdout, which carries the protocol. spinto:mcp refuses to start when a log channel writes to stdout and tells you to set LOG_CHANNEL=stderr.

Over stdio

Any MCP client that starts a local command can run Spinto. Give it sh as the command, with arguments that change to your application’s directory and then start the server:

{
    "command": "sh",
    "args": ["-c", "cd /path/to/your-app && exec cargo run --quiet -- spinto:mcp"]
}

Clients keep their servers in a list, usually as JSON under a key such as mcpServers. Name this entry spinto; clients use the name to tell Spinto’s tools from other servers’ tools.

To skip Cargo, run the built binary instead:

{
    "command": "sh",
    "args": ["-c", "cd /path/to/your-app && exec target/debug/your-app spinto:mcp"]
}

Over HTTP

For a deployed application, set SPINTO_MCP_TOKEN on the server, then give your client the endpoint’s URL and the token in an Authorization header:

{
    "url": "https://your-app.example.com/spinto/mcp",
    "headers": {
        "Authorization": "Bearer your-spinto-mcp-token"
    }
}

Keep the real token out of any configuration file you commit. If your client can read a header’s value from an environment variable, use that.

Spinto answers clients on every protocol revision from 2024-11-05 to 2026-07-28.

Trying the tools

The MCP Inspector is the quickest way to try the tools from a terminal:

cd /path/to/your-app
npx @modelcontextprotocol/inspector --cli target/debug/your-app spinto:mcp \
    --method tools/call --tool-name list_waiting_workflows

npx @modelcontextprotocol/inspector --cli https://your-app.example.com/spinto/mcp \
    --header "Authorization: Bearer $SPINTO_MCP_TOKEN" --method tools/list

Tools

The queue tools, list_queues, list_failed_jobs and inspect_batch, are described in Queues.

Tool Reads
get_runtime_capabilities What this installation can read, and the store’s schema check.
get_workflow_overview Counts and durations over a time range.
list_workflow_runs Runs, newest first, with the dashboard’s filters.
list_workflow_failures Failed runs and the step each stopped at.
list_waiting_workflows Runs that are sleeping, waiting for a resume, or waiting out a retry.
list_workflow_definitions The workflows seen in the store and the steps their runs reached.
inspect_workflow_run One run: its journal, waits, error, and optionally payloads, timeline and graph.
inspect_workflow_step One step, sleep, wait or inbox value of a run.
search_workflows Run IDs, workflow names, attribute values, wait tokens, step names and errors.

The observation tools, list_job_history, inspect_job, list_queue_workers and inspect_run_attempts, are described in Observations.

Tool names have no spinto_ prefix, because clients already namespace tools by the server’s name.

Every tool returns two things:

  • a short text an agent can read at a glance. It names every run and entry ID it mentions, and it never contains payload values.
  • structured content with contractVersion, the tool’s name, provenance, and the spinto.v1 record in result.

provenance says where the record came from: the store, the connection, the table, the row’s key and when Spinto read it. For example:

{
    "contractVersion": "spinto.v1",
    "tool": "inspect_workflow_run",
    "provenance": {
        "source": "workflowStore",
        "store": "database",
        "connection": null,
        "table": "workflow_runs",
        "key": "id=01a234ea-2fec-7250-beb7-47d5acc45161",
        "readAt": "2026-12-02T04:03:46.272714Z"
    },
    "result": { "run": { "...": "..." }, "entries": [], "omitted": ["input", "output", "entries[].output", "timeline", "graph"] }
}

When a tool can’t answer, the result has isError: true and an error with a kind:

kind Meaning
invalidArgument An argument is out of range, such as a one-character search or an attribute filter without =.
notFound No run has that ID, or the run has no such entry.
unsupported The default store isn’t the database store, so runs can’t be listed, counted or searched. inspect_workflow_run and inspect_workflow_step still read one run through the runtime.
storeMissing WORKFLOW_STORE names a store config.workflow doesn’t define.
schemaMismatch The workflow tables lack columns Spinto reads. The message lists them.
storeError Anything else, such as a lost database connection. The details stay in the application’s log.

An unknown tool or an argument a tool doesn’t take is a protocol error (-32602), not a tool result.

Every example below is real output from the onboarding example application, read through the MCP Inspector.

get_runtime_capabilities

What this installation can read: the store and its tables, whether runs can be listed, the attempt-history model, the payload policy, and a check that the tables have every column Spinto reads. Call it first when another tool’s answer looks incomplete.

Store `database` (database driver, connection default). Contract spinto.v1.
Listing runs: true.
Step outputs: true.
Attempt history: tryCountAndLastError (a try count and the last error per step; no per-attempt records).
Payload policy: redacted. Read-only: true.
Schema check: pass. Every column Spinto reads is present: workflow_runs (14), workflow_steps (11), workflow_waits (4), workflow_resumes (4), workflow_attributes (3).

get_workflow_overview

Counts and durations for runs created in a range: 1h, 24h (the default), 7d, 30d or all. It includes the unfinished runs and what each is doing right now, steps with more than one try, p50/p95/max durations of finished runs, recent failures and a breakdown by workflow.

Runs created in the last 24h (since 2026-12-01T04:05:50Z): cancelled 0, completed 6, failed 0, pending 0, running 0, waiting 3.
Unfinished right now: awaitingResume 3, queued 0, retryScheduled 0, running 0, sleeping 0, unknown 0.
Steps with more than one try: 3.
Durations of 6 finished runs: p50 8.1s, p95 27.2s, max 27.2s.
By workflow:
- customers.onboard: completed 6, waiting 3

list_workflow_runs

Runs newest first, with the dashboard’s filters. Every argument is optional:

Argument Meaning
status pending, running, waiting, completed, failed or cancelled, as the runtime saved it.
workflow The workflow’s registered name, such as customers.onboard.
attribute name=value, such as customer=7.
search A run ID prefix, or text matched against attribute values.
range 1h, 24h, 7d, 30d or all (the default).
cursor The previous page’s nextCursor.
limit 1 to 100 runs per page. Defaults to 20.
Runs: 3 of 9 shown, newest first.
- 01a234ea-3031-7979-b04b-3dec2a0a9e7f customers.onboard completed (finished), 6.0s, at step:notify rejection (completed), 1 try
- 01a234ea-300f-7bcf-a560-d7e7d726bd22 customers.onboard waiting (awaitingResume), 2m 11s so far, at wait:customers.8.approval (pending), waiting for customers.8.approval
- 01a234ea-2fec-7250-beb7-47d5acc45161 customers.onboard completed (finished), 25.1s, at step:send welcome email (completed), 1 try
More runs: pass cursor `01a234ea-2fec-7250-beb7-47d5acc45161`.

list_workflow_failures

The Failures page: failed runs with each run’s redacted error and the entry it stopped at. It takes the same arguments as list_workflow_runs except status. A step that failed and will be tried again belongs to a run that is still waiting, so it appears in list_waiting_workflows with the activity retryScheduled.

The onboarding example’s provisioning step always succeeds on its last try, and a rejected customer completes the run, so its Failures page is empty:

Failed runs: 0 of 0 shown, newest first.
No more runs.

list_waiting_workflows

The Waiting page: runs that are sleeping, waiting for a resume (with the tokens they wait for), or waiting out a retry backoff. Same arguments as list_workflow_failures. Spinto can’t resume a run. Your application does that with laravel::workflow::resume.

Waiting runs: 3 of 3 shown, newest first.
- 01a234ea-300f-7bcf-a560-d7e7d726bd22 customers.onboard waiting (awaitingResume), 3m 30s so far, at wait:customers.8.approval (pending), waiting for customers.8.approval
- 01a234e7-226b-7ce8-b348-6f4a590c76eb customers.onboard waiting (awaitingResume), 6m 50s so far, at wait:customers.5.approval (pending), waiting for customers.5.approval
- 01a234e5-759c-7983-b613-1b72f60de7dd customers.onboard waiting (awaitingResume), 8m 40s so far, at wait:customers.2.approval (pending), waiting for customers.2.approval
No more runs.

list_workflow_definitions

The workflow names in the store, with run counts by status and the entries their runs reached, in the order runs first reached them. These are observed entries, not the workflow’s declared steps: a branch no run has taken isn’t listed.

1 workflow seen in the store:
- customers.onboard: 9 runs (completed 6, waiting 3), last seen 2026-12-02T04:01:32Z. Observed entries: validate customer → create account → create billing profile → reserve subdomain → provision workspace → notify rejection → build welcome pack → cooling-off period → send welcome email.

inspect_workflow_run

One run as the run page shows it: the summary, error, names of logged context values (never their values), waits, evidence checks, and the journal. include chooses what else to add:

include Adds
entries The journal entries. This is the default.
payloads The redacted input, output and entry outputs.
timeline Timestamped events.
graph The observed execution graph.

result.omitted lists what the answer left out, so an agent never mistakes a missing field for an empty one.

Two fields keep what applied before the run moved on, and both are absent when there is nothing to keep:

  • An abandoned entry’s lapsedWakeAt is the time the store had scheduled for it: when a sleep would wake, a wait would time out, or a failed step would retry. It no longer applies, because the run ended first, so the entry’s wakeAt is empty and nothing waits for that time.
  • A timeline event’s earlier is what the event said until earlier.until: its kind, label and detail before a later record changed it. A try a stopped worker cut short reads as started until Spinto saw its job attempt end, and an abandoned wait reads as waiting until the run ended.
01a234ea-2fec-7250-beb7-47d5acc45161 customers.onboard completed (finished), 25.1s, at step:send welcome email (completed), 1 try
Created 2026-12-02T04:01:32Z, finished 2026-12-02T04:01:57Z, last activity 2026-12-02T04:01:57Z.
Attributes: customer=7, phase=onboarded, plan=team.
Journal (9 entries, in the order the run first reached them):
- #0 step:validate customer completed, 1 try, took 1ms
- #1 step:create account completed, 1 try, took 0ms
- #2 step:create billing profile completed, 1 try, took 0ms
- #3 step:reserve subdomain completed, 1 try, took 8ms
- #4 wait:customers.7.approval completed, took 3.0s
- #5 step:provision workspace completed, 2 tries, took 6.0s
- #6 step:build welcome pack completed, 1 try, took 1.0s
- #7 sleep:cooling-off period completed, took 12.0s
- #8 step:send welcome email completed, 1 try, took 1ms
Wait `customers.7.approval`: resumed since 2026-12-02T04:01:35Z, times out 2026-12-09T04:01:35Z.
Evidence: runtime-agreement pass, schema pass.
Not included: payloads, timeline, graph (add them to `include`).

With payloads, the text names what the policy redacted, and the values stay in the structured content. The demo workflow puts a billing token in its input and an API key in a step’s output. Neither reaches the agent:

Payloads (values in the structured result): input shown with /billing_token redacted; output shown, nothing redacted; step:create account output shown with /api_key redacted.
{
    "state": "value",
    "value": {
        "json": {
            "customer_id": 7,
            "provisioning_failures": 1,
            "welcome_pack_seconds": 1,
            "billing_token": "[redacted]"
        },
        "redactedPaths": ["/billing_token"],
        "truncated": false,
        "bytes": 109
    }
}

inspect_workflow_step

One journal entry, by its ID (kind:name, such as step:provision workspace) or its index, with its last error, the wait it belongs to and its timeline events.

Run 01a234ea-2fec-7250-beb7-47d5acc45161 (customers.onboard), entry #5 step:provision workspace completed, 2 tries, took 6.0s
First reached 2026-12-02T04:01:38Z, finished 2026-12-02T04:01:44Z.
Tries recorded: 2. With Spinto's observations, including tries a stopped worker cut short:
- try 1 failed (observation), finished 2026-12-02T04:01:39Z: the provisioning API answered 503 (controlled failure 1 of 1)
- try 2 succeeded (observation), finished 2026-12-02T04:01:44Z

Without Spinto’s observations of the entry, from before its observer ran or past their retention, the last line reads “Spinto has no observation of this entry’s tries, so only the store’s count and latest error are known”.

Each attempt Spinto observed has startedAt, when its observer saw the try start. The store keeps no start time for a try, so an attempt Spinto didn’t observe has none. The entry’s lapsedWakeAt and its events’ earlier mean what they mean in inspect_workflow_run.

search_workflows

Case-insensitive keyword search across run IDs (by prefix), workflow names, attribute values, wait tokens, journal entry names and redacted error text. query is 2 to 200 characters, and limit is 1 to 50 matches (20 by default).

2 matches for `customers.8` (read 1 workflow, 9 run summaries, 9 journals; every run covered).
- entry `customers.8.approval` in run 01a234ea-300f-7bcf-a560-d7e7d726bd22 customers.onboard waiting (awaitingResume), 3m 30s so far, at wait:customers.8.approval (pending), waiting for customers.8.approval
- waitingFor `customers.8.approval` in run 01a234ea-300f-7bcf-a560-d7e7d726bd22 customers.onboard waiting (awaitingResume), 3m 30s so far, at wait:customers.8.approval (pending), waiting for customers.8.approval

Search reads a bounded amount, and result.scanned says how much:

  • the workflow list,
  • the store’s own run ID and attribute search, which covers every run,
  • the newest 500 run summaries,
  • the full journals of the newest 25 runs, for entry names and entry errors.

result.complete is true when that covered every run in the store. Search never looks inside payloads, so searching for a secret finds nothing:

0 matches for `tok_live_demo` (read 1 workflow, 9 run summaries, 9 journals; every run covered).

Resources

Each run is also a resource at spinto://runs/{run_id}, and resources/list lists the 20 newest. Reading one returns the same envelope as inspect_workflow_run with every part included, as application/json. Clients that attach resources to a conversation can use them in place of the tool.

What the records don’t hold

The workflow runtime writes a journal row when a try ends. Spinto reports only what those rows hold, and the server’s instructions and the tool descriptions tell agents the same:

  • A step that is running right now has no row until its try finishes, so the newest entry may not be the one executing.
  • The store keeps a step’s try count and its last error only, and doesn’t count a try cut short by a stopped worker. Spinto’s observations add each try, a cut-short one included, for runs its observer saw; each attempt’s source says which record it came from, and the run’s observations evidence check says what was merged.
  • Purged runs have no input, output or entry outputs.
  • Wait tokens and resume values are deleted when a run ends.
  • The graph is the order runs reached entries in, not the workflow’s declared control flow.

Security

Read-only. Every tool is marked readOnlyHint and reads through spinto::workflows::Reader, which only runs SELECT queries. There is no tool that changes a run.

Payloads. Tool results go through the same payload policy as the dashboard: SPINTO_PAYLOADS, SPINTO_REDACT_KEYS and SPINTO_PAYLOAD_LIMIT. Hidden context values are never returned, and the text part of a result never contains a payload value. When the reader fails for a reason it doesn’t put in words for a page, such as a database driver error, the agent gets storeError and the error goes to the application’s log.

Run data is untrusted text. Error messages, attribute values, wait tokens and payloads come from your application and its users. A string in a run can contain words written to steer an agent. Spinto returns those strings as data and redacts them by policy, but it doesn’t filter what they say.

stdio. spinto:mcp reads the store with the application’s own database credentials and needs no token. Whoever can start the command can already read .env. Use it on your own machine, or on a server where you have a shell.

HTTP. The endpoint exists only when SPINTO_MCP_TOKEN is set. Without the token, {SPINTO_PATH}/mcp is a 404. With it:

  • Every request must send Authorization: Bearer <token>. Spinto compares SHA-256 digests of the two tokens in constant time, so the comparison reveals neither the token nor its length. A missing or wrong token gets 401 with WWW-Authenticate: Bearer, before Spinto reads anything.
  • The dashboard’s authorize callback doesn’t apply, because the endpoint has no signed-in user. Whoever holds the token can read every run, as a dashboard viewer can. Use a long random value, such as openssl rand -hex 32, and rotate it by changing the variable and restarting.
  • The route is registered outside the web middleware group, so no session or CSRF middleware runs on it, and no CSRF exclusion is needed. CSRF protection exists for requests that a browser authenticates with cookies. This endpoint never reads a cookie or a session, and a browser can’t attach the bearer token to a cross-site request on its own.
  • To stop DNS rebinding, the Host header must be localhost, 127.0.0.1, ::1, the host in APP_URL, or one in SPINTO_MCP_ALLOWED_HOSTS. A request with an Origin header must come from APP_URL’s origin or one in SPINTO_MCP_ALLOWED_ORIGINS. Anything else gets 403.
  • Only POST is served. GET and DELETE get 405, because there are no sessions to resume or end and no server-initiated streams.
  • Every response, a 401 or 403 included, carries the dashboard pages’ headers: Cache-Control: no-store, private, Referrer-Policy: same-origin, X-Robots-Tag: noindex, nofollow, X-Content-Type-Options: nosniff, X-Frame-Options: DENY and a Content Security Policy with frame-ancestors 'none'.
$ curl -i -X POST https://your-app.example.com/spinto/mcp ...
HTTP/1.1 401 Unauthorized
www-authenticate: Bearer
{"error":"unauthorized","message":"Send the token in SPINTO_MCP_TOKEN as `Authorization: Bearer <token>`."}

Using Spinto alongside the Laravel Cloud MCP server

The Laravel Cloud MCP server manages the infrastructure your application runs on: deployments and their build logs, environment logs and metrics, queues, compute and scaling. Spinto shows the application’s view: which workflow run failed, at which step, after how many tries, with what error, and when. With both connected, an agent can work out whether a failure came from the application or from what it runs on.

Add both to your client as HTTP servers: https://cloud.laravel.com/mcp named laravel-cloud, and Spinto’s endpoint with its token, as in Over HTTP:

{
    "mcpServers": {
        "laravel-cloud": {
            "url": "https://cloud.laravel.com/mcp"
        },
        "spinto": {
            "url": "https://your-app.example.com/spinto/mcp",
            "headers": {
                "Authorization": "Bearer your-spinto-mcp-token"
            }
        }
    }
}

An investigation usually goes in three steps:

  1. Inspect the failed run in Spinto. list_workflow_failures finds the run. inspect_workflow_run shows the step it stopped at and its last error, and inspect_workflow_step gives that step’s try count and when it was first reached and when it finished.
  2. Take those times to Cloud. Ask the Cloud MCP server for the environment’s logs and metrics around the step’s finish time, and for the deployments near it. A deployment that landed between two tries, a worker that was restarted, or a database that stopped answering shows up in Cloud’s logs, metrics and deployment history, not in the workflow’s records.
  3. Decide where the cause is. An error raised by your own code, such as a validation failure or an outside API answering 422, that repeats across deployments points at the application. A refused connection, a timeout, a process that was killed, or failures that started with a deployment point at the infrastructure or the release.

Spinto never changes a run. Cloud’s tools can, and the access level you grant Cloud when you authorize it decides whether your agent may deploy, scale or touch queues. Read only access is enough to investigate.

Configuration

Variable Default Meaning
SPINTO_MCP_TOKEN unset The bearer token. Unset or empty means no HTTP endpoint.
SPINTO_PATH /spinto The dashboard’s path. The endpoint is {SPINTO_PATH}/mcp.
SPINTO_MCP_ALLOWED_HOSTS none More Host values to accept, comma-separated, such as a proxy’s internal name.
SPINTO_MCP_ALLOWED_ORIGINS none More Origin values to accept, comma-separated, such as https://admin.example.com.
SPINTO_ENABLED true false turns off the dashboard, the HTTP endpoint and the spinto:mcp command.

Protocol and implementation

Spinto uses rmcp 3.12, the official Rust SDK from the Model Context Protocol organization, rather than its own implementation of the protocol.

The protocol changed shape in revision 2026-07-28. Requests are stateless: there is no initialize handshake, each request carries its protocol version and client details in _meta, the server answers server/discover, and HTTP requests repeat the method and tool name in Mcp-Method and Mcp-Name headers that the server must check against the body. Clients from earlier revisions still send initialize and expect sessions. A server written by hand would have to implement both versions, the header checks, the error codes and the Host and Origin validation, and then follow every future revision. rmcp does that work and has a release process to follow the specification. Spinto writes only the tools, their schemas and the HTTP guard.

The HTTP endpoint is the SDK’s Streamable HTTP service in stateless mode, answering with plain JSON rather than event streams. A tool call is one request and one response, so streams and sessions would add state without adding anything. Each request runs in the request’s Laravel context, and each stdio call gets a fresh context of its own, so the reader’s configuration and database access work the same way on both transports.

Tool inputs are JSON Schemas generated from Rust types with schemars. Unknown arguments are refused, and optional arguments are simply absent, never null, which keeps the schemas portable to clients that accept only one type per property.

The mcp feature

The MCP server compiles only with the mcp cargo feature, which is on by default. Agents reading workflow runs is part of what Spinto is for, and turning the feature on exposes nothing by itself: the HTTP endpoint stays off until you set a token, and the stdio command runs only when someone starts it.

The feature adds 17 crates to the build, mostly rmcp, its macros and schemars. To leave them out:

spinto = { version = "0.1", default-features = false }

Testing

The MCP tests are in tests/mcp_http.rs, tests/mcp_stdio.rs and tests/mcp_runtime.rs. Build the workspace first, because the stdio tests start the onboarding example’s binary the way a client does:

cargo build
cargo test --test mcp_http --test mcp_stdio

tests/mcp_runtime.rs runs the demo workflow on a real queue:work: one run approved after a failed provisioning try, one left waiting and one rejected. It reads them through both transports and compares every answer with Reader and with workflow:show, and it checks that the demo’s secrets never appear in any output. It needs the example’s .env pointing at a Postgres database that migrate may set up, and it takes about half a minute:

cargo test --test mcp_runtime -- --ignored