You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/mcp-server/getting-started.mdx
+55-4Lines changed: 55 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ The example MCP server you just deployed above acts as an OAuth provider to MCP
83
83
84
84
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.
85
85
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.
87
87
88
88
### Step 1 — Create and deploy a new MCP server
89
89
@@ -92,13 +92,15 @@ Run the following command to create a new MCP server:
Now, you have the MCP server setup, with dependencies installed. Move into that project folder:
99
101
100
102
```sh
101
-
cd my-mcp-server
103
+
cd my-mcp-server-github-auth
102
104
```
103
105
104
106
Then, run the following command to deploy the MCP server:
@@ -122,7 +124,7 @@ export default new OAuthProvider({
122
124
});
123
125
```
124
126
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.
126
128
127
129
### Step 2 — Create a GitHub OAuth App
128
130
@@ -136,6 +138,15 @@ Navigate to [github.com/settings/developers](https://github.com/settings/develop
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/).
Run the following command to start the development server:
@@ -144,14 +155,54 @@ Run the following command to start the development server:
144
155
npm start
145
156
```
146
157
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
+
147
176
#### Second — create a new OAuth App for production
148
177
178
+
You'll need to repeat these steps to create a new OAuth App for production.
179
+
149
180
Navigate to [github.com/settings/developers](https://github.com/settings/developers) to create a new OAuth App with the following settings:
150
181
151
182
-**Application name**: `My MCP Server (production)`
152
183
-**Homepage URL**: Enter the workers.dev URL of your deployed MCP server (ex: `worker-name.account-name.workers.dev`)
153
184
-**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`)
154
185
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
+
155
206
## Next steps
156
207
157
208
- Add [tools](/agents/model-context-protocol/mcp-server/tools/) to your MCP server.
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/mcp-server/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ sidebar:
7
7
hideIndex: false
8
8
---
9
9
10
-
# Deploy an MCP Server to Cloudflare
10
+
# Deploy MCP Servers to Cloudflare
11
11
12
12
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/).
0 commit comments