Set issue state with exact precondition
gh_set_issue_stateClose or reopen a GitHub issue only if its current state matches the expected state; verifies final state and reason after the transition.
Instructions
Destructive write: close or reopen exactly one issue only when its current state matches expected_state. Pull requests are rejected. Closing requires completed, not_planned, or duplicate; reopening requires reopened. The mutation is attempted once, comments remain a separate tool, and authoritative readback verifies the final state and reason.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"owner": "<owner>",
"repo": "<repo>",
"number": "<number>",
"expected_state": "<expected_state>",
"new_state": "<new_state>",
"state_reason": "<state_reason>"
},
"name": "gh_set_issue_state"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | GitHub repository name without the owner prefix. | |
| owner | Yes | GitHub repository owner or organization login. | |
| number | Yes | Issue number to transition. | |
| new_state | Yes | Requested state after the transition. | |
| state_reason | Yes | Reason compatible with the requested issue state. | |
| expected_state | Yes | Exact current issue state required before mutation. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| number | Yes | ||
| warning | No | ||
| closed_at | No | ||
| new_state | No | ||
| request_id | No | ||
| reopened_at | No | GitHub updated_at timestamp associated with a verified reopen transition. A confirmed mutation response is preferred; authoritative readback is the fallback because GitHub issue objects expose no dedicated reopened_at field. | |
| state_reason | No | ||
| previous_state | Yes | ||
| write_completed | Yes | ||
| readback_completed | Yes | ||
| precondition_checked | Yes | ||
| state_matches_requested | Yes |