# Configure the GitHub MCP Server

Connect GitHub's official hosted MCP server to a Dtwo gateway via OAuth.

## Overview

GitHub operates an official hosted MCP server at `api.githubcopilot.com` for repositories, issues, pull requests, and Actions. Access is authorized through OAuth via a GitHub OAuth App you register yourself.

## 1. Configure GitHub

1. In GitHub, go to **Settings → Developer settings → OAuth Apps** and register a new app for your Dtwo gateway. The **Homepage URL** is just shown to users on the consent screen — any public, non-sensitive URL (like your company's website) works. Set the **Authorization callback URL** to your gateway's OAuth callback URL — found in the Overview tab for your gateway in the Dtwo UI.
2. If your organization restricts OAuth App access, go to **Organization settings → Third-party Access → OAuth app policy** (visible to organization owners only) and approve the app so member accounts can authorize it.

## 2. Add the MCP server to your gateway config

Go to your gateway in the Dtwo UI and open **Configuration → Advanced**. In the `mcp_servers` section add the following entry:

```yaml
  - name: github
    description: "GitHub's official hosted MCP server for repositories, issues, pull requests, and Actions."
    url: https://api.githubcopilot.com/mcp/
    transport_type: streamablehttp
    authentication:
      type: oauth
      grant_type: authorization_code
      scopes:
        - repo
        - read:user
        - read:org
      client_id: "<CLIENT_ID>"
      client_secret: "<CLIENT_SECRET>"
      authorization_url: "https://github.com/login/oauth/authorize"
      token_url: "https://github.com/login/oauth/access_token"
      redirect_uri: "<CALLBACK_URL>"
```

Replace the placeholder values:

- `<CLIENT_ID>` and `<CLIENT_SECRET>` — come from the OAuth App you created in step 1.
- `<CALLBACK_URL>` — the same OAuth callback URL you set in step 1, found in the Overview tab for your gateway in the Dtwo UI.

## 3. Deploy and verify

Save the configuration and deploy the gateway.

Then, in your AI client, ask it to authorize GitHub via the gateway. This opens the GitHub login screen — sign in as the user whose permissions the agent should inherit, and approve the consent prompt. Once authorized, confirm the server's tools appear and run a quick call to make sure the connection works.

If the tools don't appear after you authorize, refresh the tool list in your AI client — some clients don't pick it up automatically.

---

Having trouble? Email [support@dtwo.ai](mailto:support@dtwo.ai).