---
name: Agent Completion Report via MCP
---

# Story 44: Agent Completion Report via MCP

## User Story

As an agent finishing work on a story, I want to report my completion status via an MCP tool, so that the system can deterministically advance the workflow without relying on prompt compliance.

## Acceptance Criteria

- [ ] MCP tool report_completion(story_id, agent_name, summary) allows agents to signal they are done
- [ ] Server rejects the report if the agent's worktree has uncommitted changes
- [ ] Server runs acceptance gates (clippy, tests) automatically on report
- [ ] Completion status and results are stored on the agent record for retrieval by wait_for_agent or the supervisor
- [ ] Agent prompts are updated to call report_completion as their final action

## Test Plan

### Unit Tests (agents.rs)
- `report_completion_rejects_nonexistent_agent` — calling on a non-existent agent returns Err
- `report_completion_rejects_non_running_agent` — calling on an already-Completed agent returns Err
- `report_completion_rejects_dirty_worktree` — calling with uncommitted changes returns Err containing "uncommitted"
- `report_completion_stores_result_and_transitions_status` — with a clean real git worktree, completes and stores a CompletionReport

### Unit Tests (mcp.rs)
- `report_completion_in_tools_list` — tool appears in handle_tools_list output
- `report_completion_tool_missing_story_id` — returns Err mentioning "story_id"
- `report_completion_tool_missing_agent_name` — returns Err mentioning "agent_name"
- `report_completion_tool_missing_summary` — returns Err mentioning "summary"
- `report_completion_tool_nonexistent_agent` — isError response for unknown agent
- `wait_for_agent_includes_completion_field` — wait_for_agent JSON output has "completion" key

## Out of Scope

- Frontend UI for displaying completion reports
- Persisting completion reports to disk across server restarts
- Running biome/frontend checks in the acceptance gates (Rust only for now)
