github-ruleset-mcp
Allows managing GitHub branch protection rulesets programmatically, including applying templates, checking protection, listing, deleting rulesets, and listing templates.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@github-ruleset-mcpProtect myorg/api with standard rules"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
github-ruleset-mcp
Branch protection as code. 4 templates, 5 tools, 2-minute setup.
An MCP server that lets Claude (or any MCP client) manage GitHub branch protection rulesets programmatically.
Why?
Setting up branch protection manually is tedious. This MCP server lets you say:
Protect myorg/api with standard rulesAnd Claude handles the rest—validating, previewing, and applying the ruleset via GitHub's API.
Related MCP server: GitHub MCP Server
Installation
Prerequisites
Node.js 18.0.0 or higher
npm or yarn
GitHub Personal Access Token with appropriate scopes
1. Clone and Build
git clone https://github.com/wilsonhj/github-ruleset-mcp.git
cd github-ruleset-mcp
npm install
npm run build2. Configure GitHub Token
Choose one of these secure methods:
Option A: Environment Variable (Recommended)
Add to your shell profile (~/.zshrc, ~/.bashrc, etc.):
export GITHUB_TOKEN="ghp_your_token_here"Then reload: source ~/.zshrc
Option B: macOS Keychain (Most Secure)
# Store token in Keychain
security add-generic-password -a "$USER" -s "github_personal_access_token" -w "ghp_your_token_here"
# Add to ~/.zshrc
echo 'export GITHUB_TOKEN=$(security find-generic-password -a "$USER" -s "github_personal_access_token" -w 2>/dev/null)' >> ~/.zshrc
source ~/.zshrc3. Add to Claude Desktop
Edit your Claude Desktop config:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"github-ruleset": {
"command": "node",
"args": ["/absolute/path/to/github-ruleset-mcp/dist/index.js"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}Important: Replace /absolute/path/to/github-ruleset-mcp with the actual path.
4. Restart Claude Desktop
Close and reopen Claude Desktop to load the MCP server.
5. Verify Installation
Ask Claude: "List available GitHub ruleset templates"
If you see 4 templates (standard, strict, relaxed, controlled), it's working! ✅
Testing (Optional)
Test the server before adding to Claude Desktop:
# Install MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.jsThis opens a web UI where you can interactively test all 5 tools.
Templates
Template | When to Use | What It Does |
| Most repos | 1 approval, CI required, no force push |
| Production | 2 approvals, signed commits, code scanning |
| Dev branches | PR required, no approval needed |
| Releases | Team-gated, staging deploy required |
Tools
Tool | Description |
| Apply branch protection (dry-run by default) |
| Verify a branch is protected |
| Show all rulesets in a repo |
| Remove a ruleset (requires confirmation) |
| Show available templates |
Examples
Protect a new repo:
Apply standard branch protection to myorg/new-servicePre-deployment check:
Verify myorg/api has branch protection before I deployCustom ruleset:
Protect myorg/api main branch requiring 3 approvals and signed commitsToken Scopes
Creating a Fine-Grained Token (Recommended)
Click "Generate new token"
Configure:
Token name:
github-ruleset-mcpExpiration: 90 days (or custom)
Repository access: "Only select repositories" or "All repositories"
Set Repository permissions:
Administration: Read and write ✅
Contents: Read-only ✅
Generate and copy the token immediately
Classic Token (Alternative)
If using classic tokens, you need:
repo— Full repository accessadmin:org_hook— Organization ruleset access (if managing org-level rulesets)
Troubleshooting
"GITHUB_TOKEN environment variable is required"
The token isn't set in your environment. Verify:
echo $GITHUB_TOKENIf empty, check that:
You added the token to your shell profile (
~/.zshrc)You ran
source ~/.zshrcto reloadClaude Desktop was restarted after setting the token
"GraphQL: Could not resolve to a Repository"
Check that:
Repository owner/name are correct
Your token has access to the repository
The repository exists
MCP Server Not Showing in Claude Desktop
Verify the config file path is correct
Check the
argspath points to the compileddist/index.jsRestart Claude Desktop completely (quit and reopen)
Check Claude Desktop logs for errors
Tools Execute But Nothing Happens
If using apply_ruleset, remember it defaults to dry-run mode. Set dry_run: false to actually apply changes.
Advanced
See docs/ADVANCED.md for:
Custom ruleset JSON
Multi-agent integration
CI/CD pipeline integration
Contributing
PRs welcome! Please open an issue first for major changes.
License
MIT
Available Tools
5 toolsapply_rulesetA
Apply a branch protection ruleset to a GitHub repository. Use dry_run=true (default) to preview changes.
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | Repository name | |
| owner | Yes | Repository owner (user or org) | |
| dry_run | No | Preview changes without applying (default: true) | |
| template | No | Template name: standard, strict, relaxed, or controlled | |
| custom_ruleset | No | Custom ruleset JSON (overrides template if provided) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Since no annotations are provided, the description carries the burden. It discloses the dry_run preview behavior and implies actual application when dry_run is false. However, it does not mention permissions, overwrite behavior, or error outcomes, which leaves potential side effects undisclosed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences that immediately convey the action and the dry_run option. There is no wasted phrasing, though the second sentence could be integrated.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the core purpose and preview capability, but with no output schema or annotations, it omits details like response format, prerequisites, or whether the ruleset replaces existing ones. Adequate for a straightforward tool but not comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
All parameter descriptions are already present in the input schema (100% coverage). The description adds no extra parameter semantics beyond what the schema provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: 'Apply a branch protection ruleset to a GitHub repository.' It uses a specific verb and resource, and given sibling tools (list_rulesets, delete_ruleset, check_protection), this tool uniquely performs the apply action.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives a usage hint about dry_run for previewing, but it does not explicitly state when to use this tool versus alternatives like check_protection or list_rulesets. Usage is implied from the verb 'apply' rather than explicitly contrasted with siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
check_protectionB
Check if a branch has protection rules applied
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | Repository name | |
| owner | Yes | Repository owner | |
| branch | No | Branch name (default: main) | main |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It only states the action without indicating return value, error behavior (e.g., branch missing, no protection rules), or read-only nature. This is a significant gap for a tool with no output schema.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence, front-loaded with the verb and resource. It contains zero wasted words and is easy to scan.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is relatively simple with well-documented parameters, but the lack of an output schema and behavioral details (e.g., what a positive vs negative result looks like) makes the description incomplete for full context. It is adequate for a minimal check tool but could be richer.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema descriptions cover 100% of the parameters, so the baseline is 3. The description adds no extra semantic detail beyond what the schema already provides, but it doesn't need to because the schema is already clear.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'check' and the resource 'branch protection rules', making the tool's purpose evident. However, it does not explicitly differentiate this from sibling tools like list_rulesets or apply_ruleset, which could also be related to protection concepts, leaving minor ambiguity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus the alternatives. There is no mention of scenarios where check_protection is preferred over list_rulesets or apply_ruleset, nor any exclusions or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
delete_rulesetA
Delete a ruleset from a repository by its ID
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | Repository name | |
| owner | Yes | Repository owner | |
| ruleset_id | Yes | Ruleset ID to delete |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The tool has no annotations, so the description carries full responsibility for behavioral disclosure. It only says 'Delete' without mentioning that the action is irreversible, may require specific permissions, or could fail if the ruleset is in use. For a destructive operation, this lack of warning is a notable gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that directly states the action and object. It contains no filler words and clearly communicates the tool's primary function without unnecessary detail.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple with complete parameter coverage and no output schema, so the description doesn't need to explain return values. However, it lacks crucial behavioral context for a delete operation, such as irreversibility or permission requirements. The core action is clear, but the absence of annotations makes the description only partially complete for an agent to use safely.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already covers all three parameters (owner, repo, ruleset_id) with descriptions, and schema coverage is 100%. The description adds no extra meaning to the parameters, such as how to obtain the ruleset_id. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'Delete' with a clear resource 'a ruleset from a repository' and identifies the lookup key ('by its ID'). This clearly distinguishes it from sibling tools like list_rulesets or apply_ruleset, which serve different actions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage through the action 'Delete'—an agent would know to use this when a ruleset needs to be removed. However, it provides no explicit context about when not to use it, prerequisites (e.g., the ruleset must exist), or alternatives (e.g., checking protection first). This is a basic implied-usage case, not a clearly guided one.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_rulesetsA
List all rulesets configured for a repository
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | Repository name | |
| owner | Yes | Repository owner |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It discloses only the basic action and does not mention side effects, permissions, pagination, or return format. This is a thin disclosure for a read operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no redundant words. It earns its place and communicates the core purpose efficiently.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple list operation with two fully described parameters, the description is adequate but lacks output schema or behavioral details. It doesn't mention what the returned list contains, pagination, or any access requirements, leaving some context gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema descriptions cover both parameters (owner and repo) with basic descriptions. The tool description adds no additional meaning beyond that, so it meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'List' and resource 'rulesets' with scope 'configured for a repository'. This clearly distinguishes it from siblings like apply_ruleset, delete_ruleset, and list_templates.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The usage is implied by the action 'List all rulesets', but there is no explicit guidance on when to use this tool versus siblings or any prerequisites. No alternatives are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_templatesA
List available branch protection templates with descriptions
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden. It uses 'List' which implies read-only, and adds that results include descriptions, but does not explicitly state side effects, permissions, or other behavioral traits.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One sentence, direct, and front-loaded. No unnecessary information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple 0-parameter list tool, the description adequately explains the purpose and return content. It could mention the specific fields returned or differentiate from list_rulesets, but it's sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the schema covers everything. Baseline is 4, and the description doesn't need to add parameter semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific action ('List') on a specific resource ('branch protection templates') and mentions output detail ('with descriptions'), distinguishing it from sibling tools like list_rulesets (rulesets vs templates).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives like list_rulesets. The usage is implied by the verb and resource, but no context or exclusions are provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- First observed
apply_ruleset - First observed
check_protection - First observed
delete_ruleset - First observed
list_rulesets - First observed
list_templates
TDQS
Each tool targets a distinct operation: applying a ruleset, checking protection status, listing rulesets, deleting a ruleset, and listing templates. The purposes are clearly separated and descriptions reinforce the differences. No two tools appear to perform the same function.
All tool names follow a consistent verb_noun snake_case pattern (apply_ruleset, check_protection, list_rulesets, delete_ruleset, list_templates). The verbs clearly indicate the action, and there are no stylistic deviations or mixed conventions.
With exactly 5 tools, the server is well-scoped for managing GitHub rulesets and branch protection. Each tool serves a distinct purpose without redundancy, and the count is neither too small nor too large for the domain.
The tool set covers the full lifecycle: apply (create/update), check (read status), list (read all), delete (remove), and list_templates (discover available templates). There are no obvious missing operations for the stated purpose, and agents can accomplish all core ruleset management tasks.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
An MCP server that gives your AI access to the source code and docs of all public github repos
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Create, deploy, and operate MCP servers directly from your GitHub repositories.
Related MCP Servers
- FlicenseBqualityDmaintenanceAn MCP server that enables Claude and other compatible LLMs to interact with the GitHub API, supporting features like creating issues, retrieving repository information, listing issues, and searching repositories.4-
- FlicenseBqualityDmaintenanceAn MCP server that allows Claude and other MCP-compatible LLMs to interact with the GitHub API, supporting features like creating issues, getting repository information, listing issues, and searching repositories.4-
- AlicenseAqualityCmaintenancePython MCP server for GitHub operations, providing native tool integration with Claude Code and other MCP clients. It enables managing issues, pull requests, CI status, milestones, and batch operations via natural language.15MIT
- AlicenseNot gradedqualityBmaintenanceA self-hosted MCP server that gives Claude access to your GitHub account — read files, browse repos, commit changes, and manage issues and pull requests, all from a conversation.467ISC
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/wilsonhj/github-ruleset-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server