Statewright

MCP Tool Reference

All 7 Statewright MCP tools — parameters, return values, examples

MCP Tool Reference

Statewright exposes 7 tools via the MCP protocol. These tools are always available regardless of allowed_tools restrictions (workflow control tools are never gated).


statewright_get_state

Get the current state machine state, available tools, transitions, and iteration count.

Parameters

None.

Return Value

{
  "state": "planning",
  "is_final": false,
  "allowed_tools": ["Read", "Grep", "Glob"],
  "transitions": [
    { "event": "READY", "target": "implementing" },
    { "event": "FAIL", "target": "failed" }
  ],
  "iteration": 3,
  "max_iterations": 10,
  "instructions": "Read and understand the code. Do not modify files.",
  "transition_count": 0,
  "blocked_env": null,
  "env_overrides": null,
  "context": { "test_result": null },
  "guards": {
    "tests_passed": { "field": "test_result", "op": "eq", "value": "pass" }
  }
}
FieldTypeDescription
statestringCurrent state name
is_finalbooleanWhether the current state is terminal
allowed_toolsstring[]Tools available in the current state
transitionsarrayAvailable transitions with event names and targets
iterationintegerTool calls made in the current state
max_iterationsinteger | nullIteration limit for the current state
instructionsstring | nullState-specific instructions
transition_countintegerTotal transitions since workflow was loaded
blocked_envstring[] | nullBlocked environment variables
env_overridesobject | nullEnvironment variable overrides
contextobjectCurrent state machine context
guardsobject | nullGuard definitions relevant to current transitions

Example

statewright_get_state()

statewright_transition

Transition the state machine to a new state by emitting an event.

Parameters

ParameterTypeRequiredDescription
eventstringYesThe transition event name (e.g., DONE, FAIL, PLAN_READY)
dataobjectNoContext data to merge into the state machine context. Used for guard evaluation on conditional transitions.

Return Value (Success)

{
  "transitioned": true,
  "from": "planning",
  "to": "implementing",
  "requires_approval": false,
  "transition_count": 1,
  "usage": {
    "transitions": 1,
    "limit": 50,
    "remaining": 49
  }
}
FieldTypeDescription
transitionedbooleanAlways true on success
fromstringPrevious state
tostringNew state
requires_approvalbooleanWhether human approval is needed before proceeding
transition_countintegerTotal transitions in this session
usage.transitionsintegerTransitions used
usage.limitinteger | nullTransition limit (null if unlimited)
usage.remaininginteger | nullTransitions remaining
usage.warningstringPresent when approaching the limit

Error Cases

  • Guard blocked: "Transition 'DEPLOY' from state 'testing' was blocked by a guard condition."
  • No matching event: "No transition for event 'UNKNOWN' in state 'planning': ..."
  • Final state: "Cannot transition: state machine is in final state 'completed'."

Examples

Simple transition:

statewright_transition(event="READY")

Transition with context data for guard evaluation:

statewright_transition(
  event="DEPLOY",
  data={"test_result": "pass", "coverage": 92}
)

statewright_load_workflow

Load a named workflow, resetting the state machine to the workflow's initial state.

Parameters

ParameterTypeRequiredDescription
namestringYesWorkflow name to load (e.g., bugfix, etl-pipeline)
session_idstringNoClient session identifier for per-session state isolation
project_idstringNoProject identifier (cwd hash) for per-project run scoping

Example

statewright_load_workflow(name="bugfix")

With session isolation:

statewright_load_workflow(
  name="deploy-pipeline",
  session_id="abc123",
  project_id="proj_9f8e7d"
)

statewright_list_workflows

List all available named workflows and which one is currently active.

Parameters

None.

Example

statewright_list_workflows()

Returns the names of all workflows registered with the gateway and indicates which (if any) is currently loaded.


statewright_get_status

Get gateway status: active workflow, current state, available workflows.

Parameters

None.

Example

statewright_get_status()

Returns a summary combining the active workflow name, current state, and the full list of available workflows. Use this for a quick overview without the full detail of statewright_get_state.


statewright_deactivate

Deactivate workflow enforcement. All tools pass through without restriction.

Parameters

None.

Example

statewright_deactivate()

After deactivation, tool calls are no longer gated. The agent has unrestricted access to all tools. Use this to exit a workflow early without reaching a final state.


statewright_create_workflow

Create a new workflow from a JSON definition.

Parameters

ParameterTypeRequiredDescription
namestringYesWorkflow name (lowercase, hyphens, e.g., data-pipeline)
definitionobjectYesFull workflow definition matching the schema

Example

statewright_create_workflow(
  name="code-review",
  definition={
    "id": "code-review",
    "initial": "reading",
    "states": {
      "reading": {
        "allowed_tools": ["Read", "Grep", "Glob"],
        "instructions": "Read the PR diff. Identify issues.",
        "max_iterations": 15,
        "on": {
          "DONE": "reporting"
        }
      },
      "reporting": {
        "allowed_tools": ["Read", "Write"],
        "instructions": "Write the review summary.",
        "on": {
          "DONE": "complete"
        }
      },
      "complete": { "type": "final" }
    }
  }
)

The definition must conform to the workflow schema at https://statewright.ai/workflow-schema.json. See the Schema Reference for field documentation.


Tool Call Flow

A typical workflow session follows this sequence:

1. statewright_load_workflow(name="bugfix")
2. statewright_get_state()                        # check initial state
3. [agent works within allowed tools]
4. statewright_transition(event="READY")           # advance to next phase
5. statewright_get_state()                        # check new state
6. [agent works within new allowed tools]
7. statewright_transition(event="DONE")            # advance again
8. [repeat until final state]

The agent calls statewright_get_state to understand what tools are available and what transitions exist. It calls statewright_transition to move forward. The gateway enforces allowed_tools on every other tool call in between.

On this page