Skip to main content

Python port of jpicklyk/task-orchestrator — MCP server for AI agent work management

Project description

task-orchestrator-py

PyPI Python 3.11+ License: MIT CI

Persistent work item graph with workflow enforcement for AI agents — a Python MCP server.

Why

AI agents lose track of complex, multi-step work across sessions. They forget what was done, what's blocked, and what comes next. Prompt-based reminders don't survive context resets. File-based state has no enforcement.

task-orchestrator-py solves this with a server-enforced workflow engine:

  • Items flow through queue → work → review → done — the server rejects invalid transitions
  • Dependencies block advancement until prerequisites are satisfied
  • Note schemas act as gates — required documentation must exist before phase changes
  • Stale detection surfaces forgotten work automatically
  • Everything persists in SQLite — survives crashes, restarts, and context window resets

This started as a Python port of jpicklyk/task-orchestrator (Kotlin) but has diverged into a standalone project with its own feature set.

How It's Different

Approach Limitation task-orchestrator-py
Prompt-based tracking Lost on context reset, no enforcement Server-enforced state machine, persists across sessions
File-based state (JSON/YAML) No workflow rules, easy to corrupt SQLite with WAL, dependency cycle detection, gate checks
Original Kotlin version JVM dependency, different feature set Pure Python, pip-installable, plus features below

Python-exclusive features not in the Kotlin original:

  • Tags — comma-separated tags on items, filterable in queries
  • Batch transitions — advance multiple items in one call
  • create_work_tree — atomically create parent + children + dependencies
  • complete_tree — batch-complete all descendants in topological order
  • Short hex IDs — use a1b2 instead of full UUIDs (4+ char prefix match)
  • Stale detectionget_context() flags items stuck in queue (>7d) or work (>3d)
  • Structured errors — typed error codes (NOT_FOUND, VALIDATION, CONFLICT, DEPENDENCY_UNSATISFIED, GATE_BLOCKED) with field-level detail

Quick Start

# Run directly (no install needed)
uvx task-orchestrator-py

# Or install globally
pip install task-orchestrator-py

MCP Client Configuration

Add to your MCP client config (Claude Desktop, Kiro, etc.):

{
  "mcpServers": {
    "task-orchestrator": {
      "command": "uvx",
      "args": ["task-orchestrator-py"],
      "env": {
        "TASK_ORCHESTRATOR_DB": "/path/to/tasks.db"
      }
    }
  }
}

If TASK_ORCHESTRATOR_DB is not set, defaults to ~/.task-orchestrator/tasks.db.

Tools

Hierarchy & CRUD

Tool Description
manage_items Create, update, or delete work items. Batch create via items_json, batch delete via ids_json.
query_items List with filters (status, priority, tags, search text), get by ID, get children, overview counts.
create_work_tree Atomically create root + children + dependencies in one call using ref-based wiring.
complete_tree Batch-complete all descendants of a parent in topological order.

Workflow

Tool Description
advance_item Trigger-based transitions with dependency and gate enforcement. Supports batch via transitions_json.
get_next_status Read-only preview — check if a transition is possible before committing.
get_context Global dashboard (counts, active, blocked, stale, next action) or item detail (children, notes, gates).
get_next_item Highest-priority actionable item with no unsatisfied dependencies.
get_blocked_items All blocked items — explicit blocks and unsatisfied dependency chains.

Notes

Tool Description
manage_notes Upsert or delete notes on items. Notes are keyed, phased (queue/work/review), and gate-checked.
query_notes Get notes with optional include_body=false for token-efficient metadata checks.

Dependencies

Tool Description
manage_dependencies Add/remove edges, pattern shortcuts (linear, fan-out, fan-in), configurable unblock_at threshold.
query_dependencies Direct neighbors or full BFS graph traversal with depth control.

Schemas

Tool Description
manage_schemas List, inspect, check gate status for items, reload config.

Workflow

          start         start         start
  queue ────────→ work ────────→ review ────────→ done
    │               │               │
    │  complete      │  complete     │  complete
    └───────────────────────────────────────────→ done
    │               │               │
    │    block       │    block      │    block
    └──────→ blocked ←──────────────┘
                │
                │  resume
                └──────→ (previous status)

  done/cancelled ──reopen──→ queue

Triggers: start (next phase), complete (jump to done), block/hold (pause), resume (unblock), cancel (close), reopen (reactivate)

Enforcement: Dependencies must be satisfied before leaving queue. Note schema gates are checked on every start/complete. Reopen cascades to parent if parent is terminal.

Real Usage Example

A realistic multi-step workflow — building a feature with tracked subtasks:

# 1. Create a work tree with children and dependencies
create_work_tree(
  root_title="User authentication",
  root_description="Add JWT-based auth to the API",
  root_priority="high",
  children_json='[
    {"ref": "schema", "title": "Design auth schema", "priority": "high"},
    {"ref": "api",    "title": "Implement auth endpoints", "priority": "high"},
    {"ref": "tests",  "title": "Write auth tests", "priority": "medium"},
    {"ref": "docs",   "title": "Update API docs", "priority": "low"}
  ]',
  deps_json='[
    {"from": "schema", "to": "api"},
    {"from": "api",    "to": "tests"},
    {"from": "api",    "to": "docs"}
  ]'
)
# Returns: root item + 4 children + 3 dependency edges + ref_map for IDs

# 2. Start working — "schema" has no blockers, so it's first
get_next_item()
# → returns "Design auth schema" (highest priority, no deps)

advance_item(item_id="a1b2", trigger="start")
# → status: queue → work (short hex ID — no need for full UUID)

# 3. Add notes as you work
manage_notes(
  operation="upsert",
  item_id="a1b2",
  key="requirements",
  role="queue",
  body="JWT with RS256, refresh tokens, 15min access expiry"
)

# 4. Complete the schema task — this unblocks "api"
advance_item(item_id="a1b2", trigger="complete")
# → status: work → done
# → response includes: unblocked_items: ["Implement auth endpoints"]

# 5. Check what's blocked and what's ready
get_context()
# → Global dashboard: counts, active items, blocked items, stale items, next action

# 6. When the feature is done, batch-complete remaining items
complete_tree(parent_id="f3e4")
# → Completes all non-terminal descendants in dependency order

Note Schemas

Optional YAML config for gate enforcement. Required notes must be filled before phase transitions.

# .taskorchestrator/config.yaml
work_item_schemas:
  task:
    lifecycle: auto
    notes:
      - key: requirements
        role: queue
        required: true
        description: "Acceptance criteria before starting"
      - key: done-criteria
        role: work
        required: true
        description: "What does done look like?"
  bug:
    lifecycle: manual
    notes:
      - key: reproduction
        role: queue
        required: true
        description: "Steps to reproduce"
      - key: root-cause
        role: work
        required: true
        description: "Root cause analysis"

Lifecycle modes:

Mode Behavior
manual All phases required (default)
auto Skip review if no review-phase notes defined
auto-reopen Terminal items reopen when notes are updated
permanent Cannot be cancelled

Dependencies

Dependencies enforce ordering — blocked items cannot advance until blockers reach the unblock_at threshold.

# Linear chain: A must finish before B, B before C
manage_dependencies(operation="pattern", item_ids="id_a,id_b,id_c", pattern="linear")

# Fan-out: A blocks both B and C (parallel after A)
manage_dependencies(operation="pattern", item_ids="id_a,id_b,id_c", pattern="fan-out")

# Fan-in: both A and B must finish before C
manage_dependencies(operation="pattern", item_ids="id_a,id_b,id_c", pattern="fan-in")

# Early unblock: unblock when blocker reaches 'review' instead of 'done'
manage_dependencies(operation="add", from_id="...", to_id="...", unblock_at="review")

Cycle detection prevents circular dependencies. relates_to type creates informational links without blocking.

Environment Variables

Variable Default Description
TASK_ORCHESTRATOR_DB ~/.task-orchestrator/tasks.db SQLite database path
TASK_ORCHESTRATOR_CONFIG .taskorchestrator/config.yaml Note schema config path

MCP Prompts

7 reusable workflow prompts for AI agents: work_summary, create_item_from_context, quick_start, status_progression, dependency_manager, batch_complete, session_start.

Roadmap

Version Focus Features
v0.7.0 Scheduling Due dates, scheduled items, time-based priority boosting
v0.8.0 Observability Workflow metrics, cycle time tracking, CI pipeline

Contributing

  1. Fork and clone
  2. uv sync to install dependencies
  3. Make changes in src/task_orchestrator/
  4. Run uv run python -m task_orchestrator.server to verify
  5. Open a PR against main

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

task_orchestrator_py-0.6.0.tar.gz (64.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

task_orchestrator_py-0.6.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file task_orchestrator_py-0.6.0.tar.gz.

File metadata

  • Download URL: task_orchestrator_py-0.6.0.tar.gz
  • Upload date:
  • Size: 64.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for task_orchestrator_py-0.6.0.tar.gz
Algorithm Hash digest
SHA256 fdf0384166aefaa2afadc1560827881b8279f6b7d67db5d9d2d00f4aee065952
MD5 158e0a3e576b98ffe795ae2e03c002a5
BLAKE2b-256 26e4a68219e3948162e7e4deb051a76c431a75339f9baaf5c692b91a6878a180

See more details on using hashes here.

File details

Details for the file task_orchestrator_py-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: task_orchestrator_py-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for task_orchestrator_py-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c53fb36dec34a0bef54423e6fcbcbbe03cdedd14112695e5f3677e797736b19
MD5 bf7206cc055999d898dc09fe91c4326e
BLAKE2b-256 23911f746352093ad7196be5d5d04594558475f1cb061be96b73c65115fef749

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page