Skip to content

Commit 0fbc4f9

Browse files
committed
Merge branch 'main' into omgitsads/api-error-type
2 parents bd50a20 + 87a4770 commit 0fbc4f9

File tree

83 files changed

+5711
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5711
-360
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.3-alpine AS build
1+
FROM golang:1.24.4-alpine AS build
22
ARG VERSION="dev"
33

44
# Set the working directory

README.md

Lines changed: 303 additions & 30 deletions
Large diffs are not rendered by default.

cmd/mcpcurl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The `--stdio-server-cmd` flag is required for all commands and specifies the com
3131

3232
### Examples
3333

34-
List available tools in Anthropic's MCP server:
34+
List available tools in Github's MCP server:
3535

3636
```console
3737
% ./mcpcurl --stdio-server-cmd "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools --help

docs/host-integration.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# GitHub Remote MCP Integration Guide for MCP Host Authors
2+
3+
This guide outlines high-level considerations for MCP Host authors who want to allow installation of the Remote GitHub MCP server.
4+
5+
The goal is to explain the architecture at a high-level, define key requirements, and provide guidance to get you started, while pointing to official documentation for deeper implementation details.
6+
7+
---
8+
9+
## Table of Contents
10+
11+
- [Understanding MCP Architecture](#understanding-mcp-architecture)
12+
- [Connecting to the Remote GitHub MCP Server](#connecting-to-the-remote-github-mcp-server)
13+
- [Authentication and Authorization](#authentication-and-authorization)
14+
- [OAuth Support on GitHub](#oauth-support-on-github)
15+
- [Create an OAuth-enabled App Using the GitHub UI](#create-an-oauth-enabled-app-using-the-github-ui)
16+
- [Things to Consider](#things-to-consider)
17+
- [Initiating the OAuth Flow from your Client Application](#initiating-the-oauth-flow-from-your-client-application)
18+
- [Handling Organization Access Restrictions](#handling-organization-access-restrictions)
19+
- [Essential Security Considerations](#essential-security-considerations)
20+
- [Additional Resources](#additional-resources)
21+
22+
---
23+
24+
## Understanding MCP Architecture
25+
26+
The Model Context Protocol (MCP) enables seamless communication between your application and various external tools through an architecture defined by the [MCP Standard](https://modelcontextprotocol.io/).
27+
28+
### High-level Architecture
29+
30+
The diagram below illustrates how a single client application can connect to multiple MCP Servers, each providing access to a unique set of resources. Notice that some MCP Servers are running locally (side-by-side with the client application) while others are hosted remotely. GitHub's MCP offerings are available to run either locally or remotely.
31+
32+
```mermaid
33+
flowchart LR
34+
subgraph "Local Runtime Environment"
35+
subgraph "Client Application (e.g., IDE)"
36+
CLIENTAPP[Application Runtime]
37+
CX["MCP Client (FileSystem)"]
38+
CY["MCP Client (GitHub)"]
39+
CZ["MCP Client (Other)"]
40+
end
41+
42+
LOCALMCP[File System MCP Server]
43+
end
44+
45+
subgraph "Internet"
46+
GITHUBMCP[GitHub Remote MCP Server]
47+
OTHERMCP[Other Remote MCP Server]
48+
end
49+
50+
CLIENTAPP --> CX
51+
CLIENTAPP --> CY
52+
CLIENTAPP --> CZ
53+
54+
CX <-->|"stdio"| LOCALMCP
55+
CY <-->|"OAuth 2.0 + HTTP/SSE"| GITHUBMCP
56+
CZ <-->|"OAuth 2.0 + HTTP/SSE"| OTHERMCP
57+
```
58+
59+
### Runtime Environment
60+
61+
- **Application**: The user-facing application you are building. It instantiates one or more MCP clients and orchestrates tool calls.
62+
- **MCP Client**: A component within your client application that maintains a 1:1 connection with a single MCP server.
63+
- **MCP Server**: A service that provides access to a specific set of tools.
64+
- **Local MCP Server**: An MCP Server running locally, side-by-side with the Application.
65+
- **Remote MCP Server**: An MCP Server running remotely, accessed via the internet. Most Remote MCP Servers require authentication via OAuth.
66+
67+
For more detail, see the [official MCP specification](https://modelcontextprotocol.io/specification/draft).
68+
69+
> [!NOTE]
70+
> GitHub offers both a Local MCP Server and a Remote MCP Server.
71+
72+
---
73+
74+
## Connecting to the Remote GitHub MCP Server
75+
76+
### Authentication and Authorization
77+
78+
GitHub MCP Servers require a valid access token in the `Authorization` header. This is true for both the Local GitHub MCP Server and the Remote GitHub MCP Server.
79+
80+
For the Remote GitHub MCP Server, the recommended way to obtain a valid access token is to ensure your client application supports [OAuth 2.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13). It should be noted, however, that you may also supply any valid access token. For example, you may supply a pre-generated Personal Access Token (PAT).
81+
82+
83+
> [!IMPORTANT]
84+
> The Remote GitHub MCP Server itself does not provide Authentication services.
85+
> Your client application must obtain valid GitHub access tokens through one of the supported methods.
86+
87+
The expected flow for obtaining a valid access token via OAuth is depicted in the [MCP Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization#authorization-flow-steps). For convenience, we've embedded a copy of the authorization flow below. Please study it carefully as the remainder of this document is written with this flow in mind.
88+
89+
```mermaid
90+
sequenceDiagram
91+
participant B as User-Agent (Browser)
92+
participant C as Client
93+
participant M as MCP Server (Resource Server)
94+
participant A as Authorization Server
95+
96+
C->>M: MCP request without token
97+
M->>C: HTTP 401 Unauthorized with WWW-Authenticate header
98+
Note over C: Extract resource_metadata URL from WWW-Authenticate
99+
100+
C->>M: Request Protected Resource Metadata
101+
M->>C: Return metadata
102+
103+
Note over C: Parse metadata and extract authorization server(s)<br/>Client determines AS to use
104+
105+
C->>A: GET /.well-known/oauth-authorization-server
106+
A->>C: Authorization server metadata response
107+
108+
alt Dynamic client registration
109+
C->>A: POST /register
110+
A->>C: Client Credentials
111+
end
112+
113+
Note over C: Generate PKCE parameters
114+
C->>B: Open browser with authorization URL + code_challenge
115+
B->>A: Authorization request
116+
Note over A: User authorizes
117+
A->>B: Redirect to callback with authorization code
118+
B->>C: Authorization code callback
119+
C->>A: Token request + code_verifier
120+
A->>C: Access token (+ refresh token)
121+
C->>M: MCP request with access token
122+
M-->>C: MCP response
123+
Note over C,M: MCP communication continues with valid token
124+
```
125+
126+
> [!NOTE]
127+
> Dynamic Client Registration is NOT supported by Remote GitHub MCP Server at this time.
128+
129+
130+
#### OAuth Support on GitHub
131+
132+
GitHub offers two solutions for obtaining access tokens via OAuth: [**GitHub Apps**](https://docs.github.com/en/apps/using-github-apps/about-using-github-apps#about-github-apps) and [**OAuth Apps**](https://docs.github.com/en/apps/oauth-apps). These solutions are typically created, administered, and maintained by GitHub Organization administrators. Collaborate with a GitHub Organization administrator to configure either a **GitHub App** or an **OAuth App** to allow your client application to utilize GitHub OAuth support. Furthermore, be aware that it may be necessary for users of your client application to register your **GitHub App** or **OAuth App** within their own GitHub Organization in order to generate authorization tokens capable of accessing Organization's GitHub resources.
133+
134+
> [!TIP]
135+
> Before proceeding, check whether your organization already supports one of these solutions. Administrators of your GitHub Organization can help you determine what **GitHub Apps** or **OAuth Apps** are already registered. If there's an existing **GitHub App** or **OAuth App** that fits your use case, consider reusing it for Remote MCP Authorization. That said, be sure to take heed of the following warning.
136+
137+
> [!WARNING]
138+
> Both **GitHub Apps** and **OAuth Apps** require the client application to pass a "client secret" in order to initiate the OAuth flow. If your client application is designed to run in an uncontrolled environment (i.e. customer-provided hardware), end users will be able to discover your "client secret" and potentially exploit it for other purposes. In such cases, our recommendation is to register a new **GitHub App** (or **OAuth App**) exclusively dedicated to servicing OAuth requests from your client application.
139+
140+
#### Create an OAuth-enabled App Using the GitHub UI
141+
142+
Detailed instructions for creating a **GitHub App** can be found at ["Creating GitHub Apps"](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps#building-a-github-app). (RECOMMENDED)<br/>
143+
Detailed instructions for creating an **OAuth App** can be found ["Creating an OAuth App"](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app).
144+
145+
For guidance on which type of app to choose, see ["Differences Between GitHub Apps and OAuth Apps"](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps).
146+
147+
#### Things to Consider:
148+
- Tokens provided by **GitHub Apps** are generally more secure because they:
149+
- include an expiration
150+
- include support for fine-grained permissions
151+
- **GitHub Apps** must be installed on a GitHub Organization before they can be used.<br/>In general, installation must be approved by someone in the Organization with administrator permissions. For more details, see [this explanation](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps#who-can-install-github-apps-and-authorize-oauth-apps).<br/>By contrast, **OAuth Apps** don't require installation and, typically, can be used immediately.
152+
- Members of an Organization may use the GitHub UI to [request that a GitHub App be installed](https://docs.github.com/en/apps/using-github-apps/requesting-a-github-app-from-your-organization-owner) organization-wide.
153+
- While not strictly necessary, if you expect that a wide range of users will use your MCP Server, consider publishing its corresponding **GitHub App** or **OAuth App** on the [GitHub App Marketplace](https://github.com/marketplace?type=apps) to ensure that it's discoverable by your audience.
154+
155+
156+
#### Initiating the OAuth Flow from your Client Application
157+
158+
For **GitHub Apps**, details on initiating the OAuth flow from a client application are described in detail [here](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#using-the-web-application-flow-to-generate-a-user-access-token).
159+
160+
For **OAuth Apps**, details on initiating the OAuth flow from a client application are described in detail [here](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#web-application-flow).
161+
162+
> [!IMPORTANT]
163+
> For endpoint discovery, be sure to honor the [`WWW-Authenticate` information provided](https://modelcontextprotocol.io/specification/draft/basic/authorization#authorization-server-location) by the Remote GitHub MCP Server rather than relying on hard-coded endpoints like `https://github.com/login/oauth/authorize`.
164+
165+
166+
### Handling Organization Access Restrictions
167+
Organizations may block **GitHub Apps** and **OAuth Apps** until explicitly approved. Within your client application code, you can provide actionable next steps for a smooth user experience in the event that OAuth-related calls fail due to your **GitHub App** or **OAuth App** being unavailable (i.e. not registered within the user's organization).
168+
169+
1. Detect the specific error.
170+
2. Notify the user clearly.
171+
3. Depending on their GitHub organization privileges:
172+
- Org Members: Prompt them to request approval from a GitHub organization admin, within the organization where access has not been approved.
173+
- Org Admins: Link them to the corresponding GitHub organization’s App approval settings at `https://github.com/organizations/[ORG_NAME]/settings/oauth_application_policy`
174+
175+
176+
## Essential Security Considerations
177+
- **Token Storage**: Use secure platform APIs (e.g. keytar for Node.js).
178+
- **Input Validation**: Sanitize all tool arguments.
179+
- **HTTPS Only**: Never send requests over plaintext HTTP. Always use HTTPS in production.
180+
- **PKCE:** We strongly recommend implementing [PKCE](https://datatracker.ietf.org/doc/html/rfc7636) for all OAuth flows to prevent code interception, to prepare for upcoming PKCE support.
181+
182+
## Additional Resources
183+
- [MCP Official Spec](https://modelcontextprotocol.io/specification/draft)
184+
- [MCP SDKs](https://modelcontextprotocol.io/sdk/java/mcp-overview)
185+
- [GitHub Docs on Creating GitHub Apps](https://docs.github.com/en/apps/creating-github-apps)
186+
- [GitHub Docs on Using GitHub Apps](https://docs.github.com/en/apps/using-github-apps/about-using-github-apps)
187+
- [GitHub Docs on Creating OAuth Apps](https://docs.github.com/en/apps/oauth-apps)
188+
- GitHub Docs on Installing OAuth Apps into a [Personal Account](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/installing-an-oauth-app-in-your-personal-account) and [Organization](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/installing-an-oauth-app-in-your-organization)
189+
- [Managing OAuth Apps at the Organization Level](https://docs.github.com/en/organizations/managing-oauth-access-to-your-organizations-data)
190+
- [Managing Programmatic Access at the GitHub Organization Level](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization)
191+
- [Building Copilot Extensions](https://docs.github.com/en/copilot/building-copilot-extensions)
192+
- [Managing App/Extension Visibility](https://docs.github.com/en/copilot/building-copilot-extensions/managing-the-availability-of-your-copilot-extension) (including GitHub Marketplace information)
193+
- [Example Implementation in VS Code Repository](https://github.com/microsoft/vscode/blob/main/src/vs/workbench/api/common/extHostMcp.ts#L313)

0 commit comments

Comments
 (0)