MCP: Smart routing for lifecycle status changes in update tool

- update(status="closed") now routes to close() tool
- update(status="open") now routes to reopen() tool
- Respects Claude Code approval workflows for lifecycle events
- Prevents bypass of approval settings
- bd CLI remains unopinionated; routing only in MCP layer
- Users can safely auto-approve benign updates without exposing closure bypass

Fixes #123

Amp-Thread-ID: https://ampcode.com/threads/T-8b85a68e-7e06-460e-9840-9c6b6a6b7e85
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-23 14:10:33 -07:00
parent 68071df49a
commit feac3f86e7
4 changed files with 74 additions and 2 deletions

View File

@@ -180,11 +180,27 @@ async def beads_update_issue(
acceptance_criteria: Annotated[str | None, "Acceptance criteria"] = None,
notes: Annotated[str | None, "Additional notes"] = None,
external_ref: Annotated[str | None, "External reference (e.g., gh-9, jira-ABC)"] = None,
) -> Issue:
) -> Issue | list[Issue]:
"""Update an existing issue.
Claim work by setting status to 'in_progress'.
Note: Setting status to 'closed' or 'open' will automatically route to
beads_close_issue() or beads_reopen_issue() respectively to ensure
proper approval workflows are followed.
"""
# Smart routing: intercept lifecycle status changes and route to dedicated tools
if status == "closed":
# Route to close tool to respect approval workflows
reason = notes if notes else "Completed"
return await beads_close_issue(issue_id=issue_id, reason=reason)
if status == "open":
# Route to reopen tool to respect approval workflows
reason = notes if notes else "Reopened"
return await beads_reopen_issue(issue_ids=[issue_id], reason=reason)
# Normal attribute updates proceed as usual
client = await _get_client()
params = UpdateIssueParams(
issue_id=issue_id,