task-graph-mcp 0.2.2

MCP server for agent task workflows with phases, prompts, gates, and multi-agent coordination
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
# Configuration Reference


Complete reference for configuring the Task Graph MCP Server.

## Configuration Files


Configuration is loaded from multiple sources with the following precedence (highest first):

1. **Environment variables** - `TASK_GRAPH_*` variables
2. **CLI arguments** - `--config`, `--database`, etc.
3. **Project-level** - `task-graph/config.yaml` or `.task-graph/config.yaml`
4. **User-level** - `~/.task-graph/config.yaml`
5. **Built-in defaults**

### File Locations


| File | Purpose |
|------|---------|
| `task-graph/config.yaml` | Main configuration |
| `task-graph/workflows.yaml` | States, phases, prompts |
| `task-graph/prompts.yaml` | Tool description overrides |
| `task-graph/workflow-{name}.yaml` | Named workflow topologies |
| `task-graph/skills/` | Custom skill definitions |

---

## config.yaml Reference


### Server Settings


```yaml
server:
  # Path to SQLite database file
  db_path: "task-graph/tasks.db"

  # Directory for file attachments
  media_dir: "task-graph/media"

  # Directory for custom skills
  skills_dir: "task-graph/skills"

  # Directory for logs
  log_dir: "task-graph/logs"

  # Maximum tasks an agent can claim simultaneously
  claim_limit: 5

  # Seconds before a worker is considered stale (default: 900 = 15 min)
  stale_timeout_seconds: 900

  # Default output format: json or markdown
  default_format: json

  # Default workflow to use when agent connects without specifying one
  default_workflow: null  # e.g., "swarm", "solo"

  # UI configuration
  ui:
    mode: none      # none (MCP only) or web (enable dashboard)
    port: 31994     # Port for web dashboard

    # Retry settings for dashboard startup
    retry_initial_ms: 15000    # Initial retry delay
    retry_jitter_ms: 5000      # Jitter range (±ms)
    retry_max_ms: 240000       # Maximum retry interval (4 min)
    retry_multiplier: 2.0      # Exponential backoff multiplier
```

### ID Generation


```yaml
ids:
  # Number of words for generated task IDs (default: 4)
  task_id_words: 4

  # Number of words for generated agent IDs (default: 4)
  agent_id_words: 4

  # Case style for generated IDs
  id_case: kebab-case  # See options below
```

**ID Case Options:**

| Value | Example |
|-------|---------|
| `kebab-case` | happy-turtle-swift-fox (default) |
| `snake_case` | happy_turtle_swift_fox |
| `camelCase` | happyTurtleSwiftFox |
| `PascalCase` | HappyTurtleSwiftFox |
| `lowercase` | happyturtleswiftfox |
| `UPPERCASE` | HAPPYTURTLESWIFTFOX |
| `Title Case` | Happy Turtle Swift Fox |

### Path Handling


```yaml
paths:
  # Root directory for sandboxing (all paths relative to this)
  root: "."

  # Path style in output: relative or project_prefixed
  style: relative

  # Auto-map single-letter Windows drives (e.g., "c:path")
  map_windows_drives: false

  # Prefix mappings (prefix -> path)
  # Values: literal path, $ENV_VAR, or ${config.path}
  mappings:
    home: "$HOME"
    project: "."
    media: "${server.media_dir}"
```

### Auto-Advance


Automatically transition unblocked tasks to a target state.

```yaml
auto_advance:
  enabled: false
  target_state: ready  # Requires this state in states config
```

---

## States Configuration


Task states define the lifecycle of tasks. Configure in `config.yaml` or `workflows.yaml`.

```yaml
states:
  # State for new tasks
  initial: pending

  # State for tasks when owner disconnects (must be untimed)
  disconnect_state: pending

  # States that block dependent tasks
  blocking_states: [pending, assigned, working]

  # Per-state definitions
  definitions:
    pending:
      exits: [assigned, working, cancelled]
      timed: false

    assigned:
      exits: [working, pending, cancelled]
      timed: false

    working:
      exits: [completed, failed, pending]
      timed: true    # Time in this state counts toward time_actual_ms

    completed:
      exits: [pending]  # Can reopen
      timed: false

    failed:
      exits: [pending]  # Can retry
      timed: false

    cancelled:
      exits: []         # Terminal state
      timed: false
```

**State Properties:**

| Property | Type | Description |
|----------|------|-------------|
| `exits` | string[] | Valid states to transition to |
| `timed` | bool | Whether time in this state is tracked |

---

## Dependencies Configuration


```yaml
dependencies:
  definitions:
    blocks:
      display: horizontal  # Same-level relationship
      blocks: start        # Blocks claiming the dependent task

    follows:
      display: horizontal
      blocks: start

    contains:
      display: vertical    # Parent-child relationship
      blocks: completion   # Blocks completing the parent

    duplicate:
      display: horizontal
      blocks: none         # Informational only

    see-also:
      display: horizontal
      blocks: none

    relates-to:
      display: horizontal
      blocks: none
```

**Dependency Properties:**

| Property | Values | Description |
|----------|--------|-------------|
| `display` | `horizontal`, `vertical` | Visual relationship type |
| `blocks` | `none`, `start`, `completion` | What the dependency blocks |

---

## Attachments Configuration


Preconfigure attachment types with default MIME types and modes.

```yaml
attachments:
  # Behavior for unknown keys: allow, warn, reject
  unknown_key: warn

  definitions:
    commit:
      mime: "text/git.hash"
      mode: append

    note:
      mime: "text/plain"
      mode: append

    meta:
      mime: "application/json"
      mode: replace

    # Gate attachments for workflow gates
    gate/tests:
      mime: "text/plain"
      mode: append

    gate/commit:
      mime: "text/plain"
      mode: append
```

**Attachment Properties:**

| Property | Values | Description |
|----------|--------|-------------|
| `mime` | MIME type | Default MIME type for this key |
| `mode` | `append`, `replace` | append keeps existing, replace overwrites |

**Built-in Attachment Types:**

| Key | MIME | Mode | Purpose |
|-----|------|------|---------|
| `commit` | text/git.hash | append | Git commit hashes |
| `checkin` | text/p4.changelist | append | Perforce changelists |
| `changelist` | text/plain | append | List of changed files |
| `meta` | application/json | replace | Structured metadata |
| `note` | text/plain | append | General notes |
| `log` | text/plain | append | Log output |
| `error` | text/plain | append | Error messages |
| `output` | text/plain | append | Command/tool output |
| `diff` | text/x-diff | append | Patches and diffs |
| `plan` | text/markdown | replace | Plans and specs |
| `result` | application/json | replace | Structured results |
| `context` | text/plain | replace | Current context/state |
| `gate/tests` | text/plain | append | Test gate satisfaction |
| `gate/commit` | text/plain | append | Commit gate satisfaction |
| `gate/review` | text/plain | append | Review gate satisfaction |

---

## Tags Configuration


Define known tags with categories and descriptions.

```yaml
tags:
  # Behavior for unknown tags: allow, warn, reject
  unknown_tag: warn

  definitions:
    rust:
      category: language
      description: "Rust programming tasks"

    python:
      category: language
      description: "Python programming tasks"

    security:
      category: domain
      description: "Security-related tasks"

    lead:
      category: role
      description: "Coordinator/lead agent"

    worker:
      category: role
      description: "Worker agent"
```

**Tag Usage:**

- **Task tags** (`tags`): Categorize tasks for discovery
- **Needed tags** (`needed_tags`): Agent must have ALL of these to claim (AND)
- **Wanted tags** (`wanted_tags`): Agent must have AT LEAST ONE of these (OR)
- **Agent tags**: Set on `connect()` to declare capabilities

---

## workflows.yaml Reference


The workflows configuration defines states, phases, prompts, and gates in a unified file.

### Basic Structure


```yaml
# Workflow metadata

name: default
description: Default workflow configuration

# Global settings

settings:
  initial_state: pending
  disconnect_state: pending
  blocking_states: [pending, assigned, working]
  unknown_phase: warn  # allow, warn, reject

# State definitions with prompts

states:
  pending:
    exits: [assigned, working, cancelled]
    timed: false

  working:
    exits: [completed, failed, pending]
    timed: true
    prompts:
      enter: |
        You are now working on this task.

        ## Valid Next States
        From `{{current_status}}` you can transition to:
        {{valid_exits}}
      exit: |
        Before leaving:
        - [ ] Attach results
        - [ ] Log costs

# Phase definitions

phases:
  explore:
    prompts:
      enter: |
        Exploration phase. Understand the problem space.
      exit: |
        Capture findings before moving on.

  implement:
    prompts:
      enter: |
        Implementation phase. Mark files before editing.

  # Phases without prompts
  test: {}
  review: {}
  deploy: {}

# State+Phase combination prompts

combos:
  working+implement:
    enter: |
      You're implementing. Focus on:
      - Follow existing patterns
      - Write tests alongside code

# Gate definitions

gates:
  status:working:
    - type: gate/tests
      enforcement: warn
      description: "Tests must pass before completing"

  phase:review:
    - type: gate/commit
      enforcement: reject
      description: "Code must be committed before review"
```

### Prompt Variables


Prompts support these template variables:

| Variable | Description |
|----------|-------------|
| `{{current_status}}` | Current task status |
| `{{valid_exits}}` | List of valid next states |
| `{{current_phase}}` | Current task phase |
| `{{valid_phases}}` | List of valid phases |

### Gates


Gates are checklists that must be satisfied before status or phase transitions.

```yaml
gates:
  # Gates for exiting a status
  status:working:
    - type: gate/tests
      enforcement: warn      # allow, warn (default), reject
      description: "Run tests before completing"

    - type: gate/commit
      enforcement: warn
      description: "Commit changes"

  # Gates for exiting a phase
  phase:implement:
    - type: gate/tests
      enforcement: reject    # Hard requirement
      description: "Tests must pass"
```

**Gate Enforcement Levels:**

| Level | Behavior |
|-------|----------|
| `allow` | Advisory only, never blocks |
| `warn` | Blocks unless `force=true` (default) |
| `reject` | Hard block, cannot be forced |

A gate is satisfied when the task has an attachment with a matching type (e.g., `gate/tests`).

---

## Named Workflows


Create workflow files for different topologies:

- `workflow-solo.yaml` - Single agent
- `workflow-swarm.yaml` - Parallel generalists
- `workflow-relay.yaml` - Sequential specialists
- `workflow-hierarchical.yaml` - Lead/worker delegation

### Using Named Workflows


```yaml
# In config.yaml

server:
  default_workflow: swarm
```

Or specify on connect:

```
connect(worker_id="agent-1", workflow="swarm")
```

### Workflow File Structure


```yaml
# workflow-swarm.yaml

name: swarm
description: Parallel generalists with fine-grained tasks

settings:
  initial_state: pending
  disconnect_state: pending
  blocking_states: [pending, assigned, working]
  unknown_phase: warn

# Override state prompts for this topology

states:
  working:
    exits: [completed, failed, pending]
    timed: true
    prompts:
      enter: |
        ## Swarm Worker Active
        Claim ONE task at a time. Complete quickly, release, repeat.

        **Coordination:**
        - Use `mark_file()` before editing shared files
        - Call `thinking()` frequently for visibility

# Phase prompts for this topology

phases:
  implement:
    prompts:
      enter: |
        In swarm topology, keep changes small and atomic.

# Topology-specific combo prompts

combos:
  working+implement:
    enter: |
      ## Swarm Implementation
      Check `mark_updates()` before touching shared files.
```

### Roles (for Hierarchical/Relay)


```yaml
# workflow-hierarchical.yaml

roles:
  lead:
    description: Coordinates work, decomposes tasks
    tags: [lead, coordinator]
    max_claims: 5
    can_assign: true
    can_create_subtasks: true

  worker:
    description: Claims and completes atomic subtasks
    tags: [worker]
    max_claims: 2
    can_assign: false
    can_create_subtasks: false
```

```yaml
# workflow-relay.yaml

roles:
  designer:
    description: Creates specifications
    tags: [designer, design]
    phases: [design, explore]
    prompts:
      claim: |
        You are taking on a design task.
      handoff: |
        Prepare handoff to implementer.

  implementer:
    description: Implements features
    tags: [implementer, code]
    phases: [implement, integrate]
```

---

## prompts.yaml Reference


Override LLM-facing instructions and tool descriptions.

```yaml
# Custom server instructions

instructions: |
  You are working on the Acme project.
  Follow these conventions:
  - Use TypeScript for all new code
  - Write tests for every feature

# Tool description overrides

tools:
  create:
    description: "Create a new task. Use parent for subtasks."

  claim:
    description: "Claim a task to start working on it."
```

**Load Locations:**

- `task-graph/prompts.yaml` (project-level)
- `~/.task-graph/prompts.yaml` (user-level)

---

## Environment Variables


| Variable | Description |
|----------|-------------|
| `TASK_GRAPH_CONFIG_PATH` | Path to config file (highest precedence) |
| `TASK_GRAPH_DB_PATH` | Database file path |
| `TASK_GRAPH_MEDIA_DIR` | Media directory for attachments |
| `TASK_GRAPH_LOG_DIR` | Log directory path |
| `TASK_GRAPH_SKILLS_DIR` | Custom skills directory |

---

## CLI Arguments


```bash
task-graph-mcp [OPTIONS]

Options:
  -c, --config <FILE>     Path to configuration file
  -d, --database <FILE>   Path to database file (overrides config)
  -v, --verbose           Enable verbose logging
  -h, --help              Print help
  -V, --version           Print version
```

---

## Complete Example


A full `config.yaml` with all sections:

```yaml
server:
  db_path: "task-graph/tasks.db"
  media_dir: "task-graph/media"
  skills_dir: "task-graph/skills"
  log_dir: "task-graph/logs"
  claim_limit: 5
  stale_timeout_seconds: 900
  default_format: json
  default_workflow: swarm
  ui:
    mode: web
    port: 31994

ids:
  task_id_words: 4
  agent_id_words: 3
  id_case: kebab-case

paths:
  root: "."
  style: relative
  mappings:
    home: "$HOME"

auto_advance:
  enabled: false
  target_state: null

states:
  initial: pending
  disconnect_state: pending
  blocking_states: [pending, assigned, working]
  definitions:
    pending:
      exits: [assigned, working, cancelled]
    assigned:
      exits: [working, pending, cancelled]
    working:
      exits: [completed, failed, pending]
      timed: true
    completed:
      exits: [pending]
    failed:
      exits: [pending]
    cancelled:
      exits: []

dependencies:
  definitions:
    blocks:
      display: horizontal
      blocks: start
    follows:
      display: horizontal
      blocks: start
    contains:
      display: vertical
      blocks: completion
    duplicate:
      display: horizontal
      blocks: none
    see-also:
      display: horizontal
      blocks: none

attachments:
  unknown_key: warn
  definitions:
    commit:
      mime: "text/git.hash"
      mode: append
    note:
      mime: "text/plain"
      mode: append

tags:
  unknown_tag: warn
  definitions:
    rust:
      category: language
      description: "Rust tasks"
    lead:
      category: role
      description: "Lead agent"
```