GitHub’s official MCP server gives an AI agent the same reach a developer has through the GitHub API: read files,
search code, open and comment on issues and pull requests, create branches, push files, and merge. GitHub runs it as a
hosted service (https://api.githubcopilot.com/mcp/), and you can also run it yourself. That makes it one of the most
useful servers to give an agent, and one of the riskiest.
What can go wrong
The agent can do more than its task needs. The server’s tools range from read-only (get_file_contents,
search_code, list_issues) to changes (create_pull_request, push_files, create_or_update_file) to the
high-impact (merge_pull_request, delete_file, create_repository, delete_repository, and running Actions
workflows). An agent that triages issues needs a handful of those, not all of them.
What it reads can steer it. Issues, pull-request descriptions and comments are written by anyone who can open them, including people outside your organisation on a public repository. In May 2025 Invariant Labs showed a “toxic agent flow”: a crafted issue on a public repository led an agent with access to private repositories to copy their contents into a public pull request. GitHub’s own lockdown mode filters some of that content, and its README is explicit that lockdown is “not an authorization boundary”.
It returns sensitive data. Private code, CI logs and security alerts — including secret-scanning alerts — come back to the agent, and from there into whatever the agent does next.
Narrow the server itself
Start at GitHub, because that is the last line of defence:
- Use a credential made for the agent. A fine-grained personal access token or a GitHub App installation token, limited to the repositories the agent needs and the narrowest permissions. Read-only if it only reads. Never a person’s own token.
- Turn off what you don’t use. The server exposes groups of tools (toolsets) and a read-only mode; the default set is broader than most agents need.
- Keep private and public work apart. An agent that reads public issues should not also hold write access to private repositories — that pairing is what made the toxic flow possible.
These limits apply to every agent that uses the credential, the same way. They can’t tell one agent’s job from another’s, and they can’t ask a person before a merge.
Govern each agent’s calls
That is what an MCP gateway is for: a checkpoint between the agents and the server that decides each tool call, per agent, before it reaches GitHub (what is an MCP gateway?). For GitHub, the decisions that matter most:
- A grant per agent. The triage agent gets the issue tools; the release agent gets branches and pull requests;
nobody gets
delete_repository. - A person before the irreversible. Hold
merge_pull_request,push_filesto a protected branch, and workflow runs for approval, and record who approved. - Watch what crosses servers. Content an agent just read from GitHub should not flow, unexamined, into a call to another system.
- Notice when a tool changes. If the server’s tool list or a tool’s description changes, review it before agents use it — a changed description is how a poisoned tool gets in.
- One record. Every call — allowed, refused or held — with the agent, the tool and the decision.
How AtmanID approaches it
AtmanID’s gateway speaks the standard MCP protocol on both sides, so the hosted GitHub server sits behind it unchanged:
- Register the server with GitHub’s MCP endpoint as its upstream and the protocol set to Standard MCP, then save a fine-grained token as its stored credential. AtmanID keeps it encrypted, never shows it again, and sends it only on calls it has allowed (put a hosted MCP server behind AtmanID).
- AtmanID reads the server’s tools and holds any tool whose definition later changes until its owner approves it.
- Grant each agent only the tools it needs, and add intent policies that hold merges and pushes for a person (MCP gateway policy engine).
- Run in Shadow first to see what would be refused, then switch to Enforce.
- Point Claude Code, Cursor or your agent SDK at the server’s AtmanID endpoint (connect any MCP client). A refused or held call comes back to the model with the reason.
Checklist
- A fine-grained token or GitHub App for the agents, scoped to named repositories, never a person’s token
- Toolsets limited, read-only where possible
- Each agent granted only its tools; destructive tools granted to none
- Merges, pushes to protected branches and workflow runs held for a person
- Tool changes reviewed before use
- Agents use the gateway’s endpoint; the GitHub credential is not in any agent’s configuration
Related: What is an MCP gateway? · AI agent security · How to govern AI agents