GitHub MCP Server Guide: Setup, Toolsets, Read-Only Mode & Security (2026)

Learn how to configure GitHub's official MCP Server with toolsets, read-only mode, OAuth, and lockdown controls for Copilot, Claude, and production coding agents.

GitHub MCP is not just a convenient way to let an AI read a repository. It is an authority bridge to code, issues, pull requests, actions, and team data. The safe setup is therefore a security decision before it is an integration decision.

This guide uses GitHub’s official MCP Server and focuses on the configuration choices that matter: toolsets, read-only mode, OAuth, dynamic discovery, and lockdown. Verify current flags in the official repository because the server is actively evolving.

What GitHub MCP Server does

The server exposes GitHub capabilities through MCP so a compatible host can search repositories, inspect files, work with issues and pull requests, and reason over workflow context. It can be used from Copilot and other MCP hosts. MCP standardizes the tool boundary; it does not decide which repositories or mutations your agent should be allowed to use.

Start with the smallest toolset

The server has toolsets rather than one enormous undifferentiated tool list. Start with context and read-only repository access for an investigation. Add issues or pull requests only when the task needs them. Fewer tools reduce accidental calls and make approval prompts understandable.

Dynamic tool discovery can reduce initial tool noise, but discovery is not a permission grant. Keep an explicit allowlist for production and review new toolsets when upgrading the server.

Read-only mode is the right first default

The official server supports a read-only mode that removes mutation tools. It is a useful default for documentation search, code review preparation, and incident investigation. Once a workflow genuinely needs a write, create a separate configuration with explicit approvals rather than quietly enabling every tool.

For a local binary, follow the repository’s documented --read-only option. In container deployments, use the corresponding environment setting. Do not copy a token into a checked-in configuration file.

OAuth, tokens, and repository scope

Use the official OAuth flow where it fits your host and organization. If you use a personal access token, create the narrowest token that supports the task, store it in a secret manager, and rotate it. A token that can write repositories turns a prompt-injection mistake into a repository incident.

Make repository scope explicit at the host and organization level. Test the negative case: ask the agent to read a repository it should not see and confirm that the request is denied without leaking metadata.

Lockdown and public content

The server’s lockdown mode can limit public-repository content based on whether the author has push access. This is useful when an agent should not surface arbitrary public contributions as trusted project context. Read the official behavior for each tool because filtering and errors differ by operation.

GitHub MCP with Copilot and Claude

In Copilot, enable the server from the IDE’s MCP configuration and keep Agent mode scoped to the repository you intend to inspect. In Claude or another host, add the server using the host’s MCP settings and expose only the toolsets required by the task. These hosts may differ in approval UX and session handling, so do not assume a permission decision transfers between them.

For a broader protocol comparison, see MCP vs function calling. For an agent runtime that combines tools and approvals, see our Claude Agent SDK guide.

Adding a model/API gateway

GitHub MCP provides GitHub tools; it does not replace your model provider, spend controls, or application telemetry. If the same agent also needs LLM, image, video, or data APIs, a gateway such as SandBase can centralize provider routing and budgets. Keep GitHub authorization separate from model authorization, and attach one correlation ID across both tool and model calls.

GitHub MCP FAQ

Is GitHub MCP free? The official server is open source, but “free” does not mean that model calls, hosting, or API usage have no cost. Check the current repository license and provider terms.

Can I use GitHub MCP in VS Code or Claude? Yes, both are MCP hosts, but their configuration and approval flows differ. Use current host documentation and expose only the toolsets you need.

What is the GitHub MCP URL? GitHub offers remote and local deployment paths that can change. Prefer the URL and installation instructions linked from current official documentation instead of copying an old endpoint into production configuration.

Production checklist

  • Begin with read-only and the smallest toolset.
  • Scope repositories and organizations explicitly.
  • Prefer OAuth or short-lived, narrowly scoped credentials.
  • Require approval for writes, merges, releases, and workflow changes.
  • Log tool names and outcomes while redacting tokens and private content.
  • Test prompt injection, denied repositories, timeouts, and partial failures.
  • Review toolset changes when upgrading the server.
  • Separate GitHub permissions from model/API gateway permissions.

GitHub MCP is powerful because it makes real engineering context available to an agent. The production boundary is the product: make it narrow, visible, and testable before allowing mutation.

Sources