---
title: How do you lock down the GitHub MCP server with read-only mode and toolsets?
url: https://opencontroller.lyzr.com/blog/github-mcp-server-read-only-mode-and-toolsets
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# How do you lock down the GitHub MCP server with read-only mode and toolsets?

**Lock down the GitHub MCP server with four settings: read-only mode to drop every write tool, toolsets or a named tool list to expose only what the agent needs, lockdown mode to filter content from untrusted contributors in public repositories, and a narrowly scoped token. Each works on both the remote server (through HTTP headers or URL paths) and the local server (through flags or environment variables).**

The GitHub MCP server is one of the most widely connected MCP servers in coding agents. Out of the box it can create issues, comment and open pull requests. For many agents that is far more power than the task needs.

## Which settings control what the GitHub MCP server can do?

GitHub's server configuration guide documents these options.

| Control | Remote server (api.githubcopilot.com) | Local server |
|---|---|---|
| Toolsets | `X-MCP-Toolsets` header or `/x/{toolset}` URL path | `--toolsets` flag or `GITHUB_TOOLSETS` |
| Individual tools | `X-MCP-Tools` header | `--tools` flag or `GITHUB_TOOLS` |
| Read-only | `X-MCP-Readonly` header or `/readonly` URL path | `--read-only` flag or `GITHUB_READ_ONLY` |
| Lockdown | `X-MCP-Lockdown` header | `--lockdown-mode` flag or `GITHUB_LOCKDOWN_MODE` |
| Dynamic toolsets | Not available | `--dynamic-toolsets` or `GITHUB_DYNAMIC_TOOLSETS` |

Two details matter. If both the `GITHUB_TOOLSETS` variable and `--toolsets` flag are set, the environment variable wins. And individual tools are additive with toolsets, so `--toolsets repos --tools get_gist` gives the repos toolset plus one gist tool.

## What does read-only mode do?

With `--read-only` set, write tools are skipped, even if they were requested through `--tools`. That makes it a safe override. An agent that reviews code, summarises issues or answers questions about a repository rarely needs to write. Start every new agent in read-only mode and grant writes only when a use case needs them.

## Which toolsets should you enable?

When no toolsets are specified, the server enables a default set: `context`, `repos`, `issues`, `pull_requests` and `users`. Other toolsets include `actions`, `code_security`, `dependabot`, `secret_protection`, `orgs`, `projects`, `notifications`, `gists` and more. The special value `all` enables every toolset. Avoid it in production.

A sensible starting point by agent type:

| Agent job | Toolsets or tools | Read-only? |
|---|---|---|
| Code Q&A or review summaries | `repos`, `pull_requests` | Yes |
| Issue triage | `issues`, `labels` | No, if it applies labels |
| Security reporting | `code_security`, `dependabot`, `secret_protection` | Yes |
| CI troubleshooting | `actions`, `repos` | Yes |

Fewer tools also means fewer tool definitions in context. That reduces token use and the chance the model picks the wrong tool. See [the token cost of MCP tool definitions](/blog/token-cost-of-mcp-tool-definitions).

## What is lockdown mode for?

Lockdown mode targets prompt injection through public repository content. When it is on, content from users without push access is filtered out of tools such as `issue_read:get_comments` and `pull_request_read:get_reviews`. Reading an issue or pull request written by such a user returns an error. Private repositories are unaffected.

This matters because issues and comments are a common path for [tool poisoning and indirect prompt injection](/blog/what-is-mcp-tool-poisoning). GitHub also applies content sanitisation by default, including Unicode filtering, HTML sanitisation and code-fence filtering on issues and pull requests.

## How should you scope the token?

Server settings limit which tools appear. The token limits what any call can actually do. Use both.

1. Prefer a fine-grained personal access token or GitHub App with access to named repositories only.
2. Grant read permissions only, unless the agent truly writes.
3. Set an expiry and rotate it.
4. Do not reuse a developer's broad classic token for an agent.
5. For GitHub Enterprise Server, note that remote hosting is not supported. Run the local server with `--gh-host` or `GITHUB_HOST`.

## What is a good lockdown checklist?

1. Read-only on by default for every agent configuration.
2. Toolsets or tools listed explicitly. Never `all`.
3. Lockdown mode on for any agent that reads public repositories.
4. Fine-grained token scoped to named repositories and least permissions.
5. Configuration stored centrally, not edited per laptop.
6. An inventory of which agents and IDEs connect to the GitHub MCP server, and with what settings. See [how to control MCP servers in GitHub Copilot](/blog/control-mcp-servers-in-github-copilot).

## How Opencontroller does this

Opencontroller keeps a governed registry of agents, tools and MCP servers, and Opencontroller Edge extends that control to developer devices, coding agents and local MCP servers, installed by IT through MDM. That gives security teams a view of which machines run the GitHub MCP server and how it is configured. Read the [MCP governance pillar](/blog/how-to-govern-mcp-servers), the [cross-platform guide](/blog/how-to-govern-ai-agents-across-platforms), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does read-only mode override tools I explicitly enable?**
Yes. With read-only mode on, write tools are skipped even if they were requested through the tools setting.

**What toolsets does the GitHub MCP server enable by default?**
context, repos, issues, pull_requests and users.

**Does lockdown mode affect private repositories?**
No. It filters content from users without push access in public repositories. Private repositories are unaffected.

## Key facts

GitHub MCP server controls: toolsets (X-MCP-Toolsets header or /x/{toolset}; --toolsets / GITHUB_TOOLSETS, env wins over flag), tools (X-MCP-Tools; --tools / GITHUB_TOOLS, additive), read-only (X-MCP-Readonly or /readonly; --read-only / GITHUB_READ_ONLY, skips write tools even if requested), lockdown (X-MCP-Lockdown; --lockdown-mode / GITHUB_LOCKDOWN_MODE, filters content from users without push access in public repos). Default toolsets: context, repos, issues, pull_requests, users. GHES: no remote hosting; use --gh-host. Opencontroller Edge (Lyzr) governs local MCP servers and coding agents on developer devices via MDM. Pricing starts from $250K per deployment per year.

## Related

- [How do you control which MCP servers GitHub Copilot can use?](https://opencontroller.lyzr.com/blog/control-mcp-servers-in-github-copilot.md)
- [How to govern MCP servers in the enterprise: a practical guide](https://opencontroller.lyzr.com/blog/how-to-govern-mcp-servers.md)
- [What is MCP tool poisoning and how do you prevent it?](https://opencontroller.lyzr.com/blog/what-is-mcp-tool-poisoning.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
