Branch protection rules prevent direct pushes to protected branches, enforce code review,
and require CI to pass. Essential for any repository with a development workflow.
Endpoints to implement
Method
Path
Tool name
Description
GET
/repos/{owner}/{repo}/branch_protections
list_branch_protections
List all branch protection rules
POST
/repos/{owner}/{repo}/branch_protections
create_branch_protection
Create a new rule
GET
/repos/{owner}/{repo}/branch_protections/{name}
get_branch_protection
Get a specific rule
PATCH
/repos/{owner}/{repo}/branch_protections/{name}
edit_branch_protection
Update a rule
DELETE
/repos/{owner}/{repo}/branch_protections/{name}
delete_branch_protection
Delete a rule
Acceptance Criteria
list_branch_protections(owner, repo) returns all rules
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Context
Branch protection rules prevent direct pushes to protected branches, enforce code review,
and require CI to pass. Essential for any repository with a development workflow.
Endpoints to implement
/repos/{owner}/{repo}/branch_protectionslist_branch_protections/repos/{owner}/{repo}/branch_protectionscreate_branch_protection/repos/{owner}/{repo}/branch_protections/{name}get_branch_protection/repos/{owner}/{repo}/branch_protections/{name}edit_branch_protection/repos/{owner}/{repo}/branch_protections/{name}delete_branch_protectionAcceptance Criteria
list_branch_protections(owner, repo)returns all rulescreate_branch_protection(owner, repo, branch_name, ...)creates rule; key params:required_approvals,enable_push,require_signed_commitsget_branch_protection(owner, repo, name)fetches single rule by branch name patternedit_branch_protection(owner, repo, name, ...)updates rule fields via PATCHdelete_branch_protection(owner, repo, name)removes rule, returns{"success": true}_b()helperTechnical Notes
namefield is the branch name pattern (e.g.main,release/*)create/editbody fields:branch_name,enable_push,enable_push_whitelist,push_whitelist_usernames,required_approvals,enable_approvals_whitelist,approvals_whitelist_usernames,require_signed_commits,block_on_outdated_branch_strip()to omit unset optional fields