Back to Home
· product · apflow
apflow logo

apflow

Durable, distributed workflow orchestration with REST, MCP, A2A, and CLI interfaces

apflow is a Python orchestration engine for building, running, and governing dependable task workflows. It separates workflow structure from execution dependencies and records accepted Runs with frozen definitions, completed-result snapshots, and retry lineage. Durable background submission, shared token budgets, invocation-level usage records, recurring schedules, and coordinated workers support embedded SQLite deployments and distributed PostgreSQL services. Register capabilities once for REST/OpenAPI, MCP, A2A, and CLI, with service identity, ownership, and executor permission checks at authenticated boundaries.

· 01

Get Started

CLI · Interface

Command-line interface built on apcore-cli: serve REST, MCP and A2A, then create, submit and inspect Runs from the terminal.

Install
$ pip install apflow
Quick Start
shell
# Serve REST + A2A + MCP together on one port (/, /a2a, /mcp)
apflow serve --all

# A2A only, with the Explorer UI at http://localhost:8000/explorer
apflow serve --explorer

# MCP server on stdio for Claude/Cursor
apflow mcp

# Inspect version, config and every registered module
apflow info

# Module commands use the local database, not the HTTP server
export APFLOW_DATABASE_URL=sqlite:////tmp/apflow.db
apflow dispatcher --db "$APFLOW_DATABASE_URL"   # skip if REST/unified serve runs

# Create a draft, accept it for execution, then inspect the Run
apflow task create --name example --idempotency-key demo-1 --input - <<'JSON'
{"params":{"executor_id":"aggregate_results_executor"}}
JSON

apflow task submit --task-id ROOT_ID
apflow run get --run-id ROOT_ID

# Retries create a new Run; retry creation alone does not execute it
apflow run retry --run-id ROOT_ID --idempotency-key demo-retry-1
· 02

Features

01Task orchestration: Structure trees organize workflows; dependency DAGs coordinate parallel steps, fan-in, fan-out, and dependency results
02Workflow reuse: Create new workflows, copy for re-runs, link completed results, archive in place, or mix copying and linking
03Run history and retry: Execute accepted trees once from their root; run.retry creates a new Run with new task IDs, source lineage, and frozen reusable results
04Durable background submission: task.submit persists acceptance and a submission receipt; a dispatcher executes accepted work after the request ends. Acceptance does not mean execution has completed
05Custom executors: Register sync or async Python functions with @function_executor, or implement executor classes for stateful work
06Execution resilience: Classified retries with backoff and per-executor circuit breakers; executor-specific checkpoints restore progress within an active Run. Unknown remote outcomes require verification and explicit replay authorization
07Scheduling and history: Poll-based scheduling or webhook triggers create isolated run instances with their own status, results, and usage
08Embedded to distributed: SQLite by default; PostgreSQL enables coordinated workers, task leases, leader election, and distributed schedule dispatch
09Shared token budgets: Atomic pre-execution reservations, per-invocation retry settlement, evidenced reconciliation, and block/notify/model-downgrade policies; missing usage remains an unknown liability
10Invocation-level usage: Immutable usage events support at-least-once delivery through usage.events and explicit acknowledgement through usage.ack; consumers persist and deduplicate receipts before acknowledgement. Monetary costs, pricing, and billing remain application-owned
11Governed multi-protocol access: REST/OpenAPI, MCP, A2A, and CLI share module contracts; authenticated services enforce task ownership and executor permissions, use credential references, and gate new work on required capabilities
12Live execution progress: Stream task lifecycle events and final results over REST SSE, with task.execute streaming also available through MCP and A2A
· related

Related Products

apcore logo

apcore

The governed capability runtime used by apflow module surfaces.

View Product
apcore-mcp logo

apcore-mcp

MCP and OpenAI Tools adapter for registered apcore modules.

View Product
apcore-a2a logo

apcore-a2a

A2A adapter for projecting modules to Agent Card and task interfaces.

View Product
apcore-cli logo

apcore-cli

Terminal adapter for registered apcore modules.

View Product