Skip to content

Commit 927219b

Browse files
Document MCP workflow tool contracts
1 parent 303a2ec commit 927219b

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

docs/mcp-workflows.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,44 @@ Call `list_workflows` before any start. It is the agent's compatibility check:
6363
the response tells the client which workflow keys exist and whether a workflow
6464
can run in the current environment.
6565

66+
## Tool Input Contract
67+
68+
The MCP tool schemas intentionally use Durable Workflow terms instead of
69+
Laravel internals. Keep these fields stable when extending the sample app
70+
server:
71+
72+
| Tool | Stable inputs |
73+
| --- | --- |
74+
| `list_workflows` | `show_recent`, `limit`, and optional `status` for recent-run discovery. |
75+
| `start_workflow` | `workflow`, ordered `arguments`, optional `instance_id`, `business_key`, `visibility_labels`, `memo`, `search_attributes`, and `duplicate_start_policy`. |
76+
| `get_workflow_result` | `workflow_id`, optional `run_id`, `include_recent_history`, and `history_limit`. |
77+
| `get_workflow_history` | `workflow_id` or `run_id`, `limit`, and `include_payloads`. |
78+
79+
Prefer `arguments` over the legacy `args` input for new agents. `arguments`
80+
maps directly to the workflow `handle()` argument order, while `args` exists
81+
only for older object-shaped callers.
82+
83+
Use caller-supplied `instance_id` only when an agent needs idempotency. Pair it
84+
with `duplicate_start_policy=return_existing_active` when a repeated smoke run
85+
should attach to the active workflow instead of failing as a duplicate.
86+
87+
## Tool Result Contract
88+
89+
Agents should treat the following result fields as the durable handles for
90+
cross-tool correlation:
91+
92+
| Tool | Stable result fields |
93+
| --- | --- |
94+
| `list_workflows` | `available_workflows`, `allow_fqcn`, `workflow_id_kind`, `run_id_kind`, `status_values`, and optional `recent_workflows`. |
95+
| `start_workflow` | `workflow_id`, `run_id`, `workflow`, `workflow_class`, `workflow_type`, `status`, `running`, `business_key`, `duplicate_start_policy`, and `command`. |
96+
| `get_workflow_result` | `found`, `workflow_id`, `run_id`, `current_run_id`, `current_run_is_selected`, `status`, `running`, `output`, `error`, visibility metadata, and timestamps. |
97+
| `get_workflow_history` | `found`, `workflow_id`, `run_id`, `current_run_id`, `status`, `history_event_count`, `returned_event_count`, `events_are_most_recent`, `payloads_included`, `events`, and `failures`. |
98+
99+
History payload previews are intentionally bounded. When `include_payloads` is
100+
true, each event preview reports `payload_preview_limit_bytes`, `size_bytes`,
101+
`preview_bytes`, and `truncated` so an agent can cite whether it saw the full
102+
payload or only a preview.
103+
66104
## Safe Agent Loop
67105

68106
Use no-credential workflows first:

scripts/check-llms-ai-surfaces.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function main() {
6464
'start_workflow',
6565
'get_workflow_result',
6666
'get_workflow_history',
67+
'## Tool Input Contract',
68+
'## Tool Result Contract',
69+
'duplicate_start_policy=return_existing_active',
70+
'payload_preview_limit_bytes',
6771
'CLI reference',
6872
'CLI and Python Parity',
6973
'workflow-start-parity.json',

scripts/discoverability-contract.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"query": "mcp ai client llms.txt",
193193
"target": "mcp-workflows.md",
194194
"related": ["ai-assisted-development.md", "sample-app.md"],
195-
"aliases": ["/mcp/workflows", "llms-2.0.txt", "agents", "list_workflows"]
195+
"aliases": ["/mcp/workflows", "llms-2.0.txt", "agents", "list_workflows", "payload_preview_limit_bytes"]
196196
},
197197
{
198198
"query": "agent loop ai debugging structured diagnosis",

0 commit comments

Comments
 (0)