Skip to content

Commit 752b9ac

Browse files
committed
Complete docs for GitHub auth
1 parent 1f8cca2 commit 752b9ac

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

src/content/docs/agents/model-context-protocol/mcp-server/getting-started.mdx

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The example MCP server you just deployed above acts as an OAuth provider to MCP
8383

8484
In the next section, you will add a real authentication provider to your MCP server. Even if you already have an authentication provider in place, following these steps will show you more clearly how to integrate it with your MCP server.
8585

86-
We'll use GitHub as the authentication provider here, but you can use any OAuth provider that supports the OAuth 2.0 specification.
86+
We'll use GitHub as the authentication provider here, but you can use any OAuth provider that supports the OAuth 2.0 specification, including Google, Slack, Stytch, Auth0, and more.
8787

8888
### Step 1 — Create and deploy a new MCP server
8989

@@ -92,13 +92,15 @@ Run the following command to create a new MCP server:
9292
<PackageManagers
9393
type="create"
9494
pkg="cloudflare@latest"
95-
args={"my-mcp-server --template=cloudflare/ai/demos/remote-mcp-server-github"}
95+
args={
96+
"my-mcp-server-github-auth --template=cloudflare/ai/demos/remote-mcp-server-github"
97+
}
9698
/>
9799

98100
Now, you have the MCP server setup, with dependencies installed. Move into that project folder:
99101

100102
```sh
101-
cd my-mcp-server
103+
cd my-mcp-server-github-auth
102104
```
103105

104106
Then, run the following command to deploy the MCP server:
@@ -122,7 +124,7 @@ export default new OAuthProvider({
122124
});
123125
```
124126

125-
This will ensure that your users are redirected to GitHub to authenticate.
127+
This will ensure that your users are redirected to GitHub to authenticate. To get this working though, you need to create OAuth client apps in the steps below.
126128

127129
### Step 2 — Create a GitHub OAuth App
128130

@@ -136,6 +138,15 @@ Navigate to [github.com/settings/developers](https://github.com/settings/develop
136138
- **Homepage URL**: `http://localhost:8787`
137139
- **Authorization callback URL**: `http://localhost:8787/callback`
138140

141+
For the OAuth app you just created, add the client ID of the OAuth app as `GITHUB_CLIENT_ID` and generate a client secret, adding it as `GITHUB_CLIENT_SECRET` to a `.dev.vars` file in the root of your project, which [will be used to set secrets in local development](/workers/configuration/secrets/).
142+
143+
```sh
144+
touch .dev.vars
145+
echo 'GITHUB_CLIENT_ID="your-client-id"' >> .dev.vars
146+
echo 'GITHUB_CLIENT_SECRET="your-client-secret"' >> .dev.vars
147+
cat .dev.vars
148+
```
149+
139150
#### Next, run your MCP server locally
140151

141152
Run the following command to start the development server:
@@ -144,14 +155,54 @@ Run the following command to start the development server:
144155
npm start
145156
```
146157

158+
Your MCP server is now running on `http://localhost:8787/sse`.
159+
160+
In a new terminal, run the [MCP inspector](https://github.com/modelcontextprotocol/mcp-inspector). The MCP inspector is an interactive MCP client that allows you to connect to your MCP server and invoke tools from a web browser.
161+
162+
```sh
163+
npx @modelcontextprotocol/inspector@latest
164+
```
165+
166+
Open the MCP inspector in your web browser:
167+
168+
```sh
169+
open http://localhost:5173
170+
```
171+
172+
In the inspector, enter the URL of your MCP server, `http://localhost:8787/sse`, and click **Connect**:
173+
174+
You should be redirected to a GitHub login or authorization page. After authorizing the MCP Client (the inspector) access to your GitHub account, you will be redirected back to the inspector. You should see the "List Tools" button, which will list the tools that your MCP server exposes.
175+
147176
#### Second — create a new OAuth App for production
148177

178+
You'll need to repeat these steps to create a new OAuth App for production.
179+
149180
Navigate to [github.com/settings/developers](https://github.com/settings/developers) to create a new OAuth App with the following settings:
150181

151182
- **Application name**: `My MCP Server (production)`
152183
- **Homepage URL**: Enter the workers.dev URL of your deployed MCP server (ex: `worker-name.account-name.workers.dev`)
153184
- **Authorization callback URL**: Enter the `/callback` path of the workers.dev URL of your deployed MCP server (ex: `worker-name.account-name.workers.dev/callback`)
154185

186+
For the OAuth app you just created, add the client ID and client secret, using Wrangler CLI:
187+
188+
```sh
189+
wrangler secret put GITHUB_CLIENT_ID
190+
```
191+
192+
```sh
193+
wrangler secret put GITHUB_CLIENT_SECRET
194+
```
195+
196+
#### Finally, deploy your MCP server
197+
198+
Run the following command to deploy your MCP server:
199+
200+
```sh
201+
npm run deploy
202+
```
203+
204+
You should now be able to connect to your MCP server using the MCP inspector, and authenticate with GitHub.
205+
155206
## Next steps
156207

157208
- Add [tools](/agents/model-context-protocol/mcp-server/tools/) to your MCP server.

src/content/docs/agents/model-context-protocol/mcp-server/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77
hideIndex: false
88
---
99

10-
# Deploy an MCP Server to Cloudflare
10+
# Deploy MCP Servers to Cloudflare
1111

1212
You can build and deploy MCP servers on Cloudflare, using the [`workers-mcp` package](https://github.com/cloudflare/workers-mcp), which provides an SDK for [authorization](/agents/model-context-protocol/mcp-server/authorization/), [transport](/agents/model-context-protocol/mcp-server/transport/), and [tool definition and discovery](/agents/model-context-protocol/mcp-server/tools/).
1313

0 commit comments

Comments
 (0)