Documentation/Tutorials/ Agent tools & skills

Tutorial · MCP + agents

Turn a flow into a reliable agent tool.

Build a four-node flow that runs a read-only coding agent, author it through MCP, and wrap the full run lifecycle in a reusable skill for your AI client.

01 / THE ARCHITECTURE

Keep orchestration and instructions separate

The Knodr flow is the executable graph. MCP is the control plane an AI client uses to author, validate, start, and inspect it. A client-side skill is the operating procedure that tells the AI when and how to use those tools.

AI clientSkillpreflight · inputs · reporting
Knodr.knodrflowgraph · policy · execution
ToolAgent CLICodex in read-only mode
Important boundary: the skill does not live inside the .knodrflow. Install it in the AI client that has access to the Knodr MCP server. Keep the flow in the project so people and agents can version and review it together.

02 / BUILD THE FLOW

Two inputs, one agent, one result

input.manual Taskinput.manual Working directory
agent.cliRead-only Codexstdout
output.previewResultvalue
  1. 01
    Add two Manual Input nodes

    Label them Task and Working directory. Leave their saved values empty so callers must supply them.

  2. 02
    Add Agent CLI

    Select codex, set the timeout to 600 seconds, and enter --sandbox and read-only as separate extra-argument lines.

  3. 03
    Wire the inputs

    Connect Task value to Agent CLI task, and Working directory value to workingDirectory.

  4. 04
    Expose the result

    Connect Agent CLI stdout to Preview value, then save as flows/agent-task.knodrflow.

Read-only is a flow policy here: the agent is allowed to inspect the project but not edit it. Change that policy deliberately for implementation flows, and make the skill describe the broader authority.

03 / AUTHOR WITH MCP

Let an AI client build the same graph

First call list_nodes, then get_node_schema for input.manual, agent.cli, and output.preview. That confirms the installed parameters and port names before any write.

Call scaffold_flow to create flows/agent-task.knodrflow, then make one atomic apply_flow call with this shape. Omitting coordinates lets Knodr arrange the graph left to right.

MCP · apply_flow arguments
{
  "path": "flows/agent-task.knodrflow",
  "nodes": [
    {
      "id": "task",
      "typeId": "input.manual",
      "parameters": { "label": "Task" }
    },
    {
      "id": "working_dir",
      "typeId": "input.manual",
      "parameters": { "label": "Working directory" }
    },
    {
      "id": "agent_runner",
      "typeId": "agent.cli",
      "parameters": {
        "tool": "codex",
        "extraArgs": "--sandbox\nread-only",
        "timeoutSeconds": "600",
        "failOnNonZeroExit": "true"
      }
    },
    { "id": "result", "typeId": "output.preview" }
  ],
  "connections": [
    {
      "fromNode": "task", "fromPort": "value",
      "toNode": "agent_runner", "toPort": "task"
    },
    {
      "fromNode": "working_dir", "fromPort": "value",
      "toNode": "agent_runner", "toPort": "workingDirectory"
    },
    {
      "fromNode": "agent_runner", "fromPort": "stdout",
      "toNode": "result", "toPort": "value"
    }
  ]
}

Finish authoring with validate_flow. Treat an ok: false result as a hard stop; fix the graph before starting a run. apply_flow is atomic, so an invalid authoring request does not leave a half-built graph behind.

04 / RUN & OBSERVE

Use a run ID, not hope

Call start_run with values keyed by Manual Input node ID. Capture the returned runId immediately.

MCP · start_run arguments
{
  "path": "flows/agent-task.knodrflow",
  "inputs": {
    "task": "Review the current changes for correctness.",
    "working_dir": "C:\\work\\my-project"
  },
  "timeoutSeconds": 660
}
1start_runcapture runId 2get_run_statuspoll while running 3get_run_snapshotread ports or failures

Poll until state is success, failed, or cancelled. On failure, call get_run_snapshot for the failed node and port values, then get_run_logs for the execution trail. Report the runId so another operator can inspect the same durable run.

MCP server mode: a skill that calls start_run needs the normal knodr mcp server. Starting the server with --read-only intentionally removes execution and debugging tools.

05 / CREATE AN AI-AGENT SKILL

Encode the operating procedure

A good skill defines when to use the flow, verifies prerequisites, resolves inputs explicitly, owns the complete run lifecycle, and returns durable evidence. The exact skill directory depends on your AI client; the example below shows the portable instruction pattern.

SKILL.md · compact example
---
name: review-with-knodr
description: Review a project with the Knodr agent-task flow.
---

# Review with Knodr

Use this skill when the user asks for an independent code review.

## Preconditions

- Require the Knodr MCP tools.
- Require `flows/agent-task.knodrflow`.
- Require the selected agent CLI to be authenticated.

## Procedure

1. Resolve the absolute project root. Do not guess.
2. Call `validate_flow` for the flow path. Stop on errors.
3. Call `start_run` with:
   - `task`: a precise, read-only review request
   - `working_dir`: the resolved project root
   - `timeoutSeconds`: 660
4. Save the returned `runId`.
5. Poll `get_run_status` until `success`, `failed`, or
   `cancelled`.
6. On success, call `get_run_snapshot` and read the result.
7. On failure, call `get_run_snapshot` and `get_run_logs`;
   report the failed node and actionable error.

## Response

Report findings first, then the flow path, agent used, and runId.

Why each part matters

Preflight

Fail early when tools, flow files, or agent authentication are missing.

Explicit inputs

Resolve paths and task scope before execution so the run is reproducible.

Terminal polling

A returned run ID means work started, not that it succeeded.

Failure diagnostics

Snapshots identify the failed node; logs explain the sequence that reached it.

Evidence

Return the result and run ID instead of a vague completion claim.

06 / GROW TO MULTI-AGENT REVIEW

Scale the graph, preserve the contract

The multi-agent review reference follows the same lifecycle at a larger scale: prepare one diff, fan the review prompt out to several agent.cli nodes, tolerate individual reviewer failures through explicit error outputs, aggregate the surviving reviews, then ask a final consensus agent to write the report.

Resolve inputsBuild diffParallel reviewersAggregateConsensus report

Do not start with that full graph. First make this single-agent flow reliable. Then add parallel branches, explicit fallback paths, and a final artifact. The skill still performs the same five duties: preflight, resolve inputs, start, poll, and report.