> ## Documentation Index
> Fetch the complete documentation index at: https://darwin.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Mastra

> Add Darwin tools and durable Action state to a Mastra workflow.

Create typed Mastra tools around the Darwin SDK or use remote MCP where supported. Keep discovery and mutation tools separate.

[Copy the Mastra MCP recipe](https://github.com/darwin-studios/darwin-integrations/blob/main/frameworks/mastra.md).

Persist the selected capability revision, `actionId`, and mutation request IDs in workflow state. Use Get action after process restarts, delayed providers, or browser-based interactions.

Treat `availableActions` as the router for valid next steps and surface approval or payment review to the user instead of automatically continuing.

## Suggested workflow data

```typescript theme={null}
type DarwinWorkflowState = {
  capabilityId?: string;
  capabilityRevision?: number;
  actionId?: string;
  mutationRequestIds: Record<string, string>;
  latestAction?: unknown;
};
```

Checkpoint before and after each mutation. After a process restart, load `actionId` and call Get action before choosing a node.
