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
- For _Do you want to add an AGENTS.md file to help AI coding tools understand
45
+
Cloudflare APIs?_, choose `No`.
46
+
- For _Do you want to use git for version control?_, choose `No`.
47
+
- For _Do you want to deploy your application?_, choose `No` (we will be testing the server before deploying).
48
+
43
49
Now, you have the MCP server setup, with dependencies installed.
44
50
45
51
2. Move into the project folder:
@@ -59,22 +65,29 @@ You can use the [Wrangler CLI](/workers/wrangler) to create a new MCP Server on
59
65
[wrangler:info] Ready on http://localhost:8788
60
66
```
61
67
62
-
Your MCP server is now running on `http://localhost:8788/mcp`.
68
+
Check the command output for the local port. In this example, the MCP server runs on port `8788`, and the MCP endpoint URL is `http://localhost:8788/mcp`.
69
+
:::note
70
+
You cannot interact with the MCP server by opening the `/mcp` URL directly in a web browser. The `/mcp` endpoint expects an MCP client to send MCP protocol messages, which a browser does not do by default. In the next step, we will demonstrate how to connect to the server using an MCP client.
71
+
:::
63
72
64
73
4. To test the server locally:
74
+
65
75
1. In a new terminal, run the [MCP inspector](https://github.com/modelcontextprotocol/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.
3. In the MCP inspector, enter the URL of your MCP server: `http://localhost:8788/mcp`, and select **Connect**. Select **List Tools** to show the tools that your MCP server exposes.
88
+
The MCP inspector will launch in your web browser. You can also launch it manually by opening a browser and going to `https://localhost:<PORT>`. Check the command output for the local port where MCP Inspector is running. In this example, the MCP server is served on port `5173`.
89
+
90
+
3. In the MCP inspector, enter the URL of your MCP server (`http://localhost:8788/mcp`), and select **Connect**. Select **List Tools** to show the tools that your MCP server exposes.
78
91
79
92
5. You can now deploy your MCP server to Cloudflare. From your project directory, run:
80
93
@@ -84,8 +97,7 @@ You can use the [Wrangler CLI](/workers/wrangler) to create a new MCP Server on
84
97
85
98
If you have already [connected a git repository](/workers/ci-cd/builds/) to the Worker with your MCP server, you can deploy your MCP server by pushing a change or merging a pull request to the main branch of the repository.
86
99
87
-
The MCP server will be deployed to your `*.workers.dev` subdomain at `remote-mcp-server-authless.your-account.workers.dev/mcp`.
88
-
100
+
The MCP server will be deployed to your `*.workers.dev` subdomain at `https://remote-mcp-server-authless.your-account.workers.dev/mcp`.
89
101
90
102
6. To test the remote MCP server, take the URL of your deployed MCP server (`https://remote-mcp-server-authless.your-account.workers.dev/mcp`) and enter it in the MCP inspector running on `http://localhost:5173`.
The MCP inspector will launch in your web browser. You can also launch it manually by opening a browser and going to `https://localhost:<PORT>`. Check the command output for the local port where MCP Inspector is running. In this example, the MCP server is served on port `5173`.
25
34
26
-
Then, enter the URL of your remote MCP server. You can use an MCP server running on your local machine on localhost, or you can use a remote MCP server running on Cloudflare.
35
+
2. In the MCP inspector, enter the URL of your MCP server (for example, `http://localhost:8788/mcp`). Select **Connect**.
You can connect to an MCP server running on your local machine or a remote MCP server running on Cloudflare.
29
38
30
-
Once you have authenticated, 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.
39
+
3. If your server requires authentication, the connection will fail. To authenticate:
40
+
1. In MCP Inspector, select **Open Auth settings**.
41
+
2. Select **Quick OAuth Flow**.
42
+
3. Once you have authenticated with the OAuth provider, you will be redirected back to MCP Inspector. Select **Connect**.
When asked if you want to deploy to Cloudflare, select **No**.
70
+
During setup, select the following options:
71
+
- For _Do you want to add an AGENTS.md file to help AI coding tools understand
72
+
Cloudflare APIs?_, choose `No`.
73
+
- For _Do you want to use git for version control?_, choose `No`.
74
+
- For _Do you want to deploy your application?_, choose `No` (we will be making some changes before deploying).
71
75
72
76
2. Go to the project directory:
73
77
@@ -137,7 +141,8 @@ The Worker will be deployed to your `*.workers.dev` subdomain at `mcp-server-cf-
137
141
138
142
9. (Optional) Under **Advanced settings**, turn on [**Refresh tokens**](/cloudflare-one/access-controls/applications/http-apps/saas-apps/generic-oidc-saas/#advanced-settings) if you want to reduce the number of times a user needs to log in to the identity provider.
139
143
10. Configure [Access policies](/cloudflare-one/access-controls/policies/) to define the users who can access the MCP server.
@@ -166,14 +171,20 @@ The Worker will be deployed to your `*.workers.dev` subdomain at `mcp-server-cf-
166
171
/>
167
172
168
173
2. Copy the `client_id` and `client_secret` returned in the response.
169
-
3. To determine the OAuth endpoint URLs for the SaaS application, refer to the [generic OIDC documentation](/cloudflare-one/access-controls/applications/http-apps/saas-apps/generic-oidc-saas/#2-add-your-application-to-access).
174
+
3. Build the OAuth endpoint URLs using your <GlossaryTooltipterm="team name">team name</GlossaryTooltip> and the `client_id` returned in the response:
Your MCP server needs to perform an OAuth 2.0 authorization flow to get an `access_token` from the SaaS app created in [Step 1](#1-create-an-access-for-saas-app). When setting up the OAuth client on your MCP server, you will need to paste in the OAuth endpoints and credentials from the SaaS app.
187
+
Your MCP server needs to perform an OAuth 2.0 authorization flow to get an `access_token` from the SaaS app created in [Step 1](#1-create-an-access-for-saas-app). When setting up the OAuth client on your MCP server, you will need to paste in the OAuth endpoints and credentials from the Access for SaaS app.
177
188
178
189
To add OAuth endpoints and credentials to our [example MCP server](#1-deploy-an-example-mcp-server):
179
190
@@ -185,7 +196,7 @@ To add OAuth endpoints and credentials to our [example MCP server](#1-deploy-an-
4. Under **Variables and Secrets**, update each secret with the corresponding value from your SaaS app:
199
+
4. Under **Variables and Secrets**, update each secret with the corresponding value obtained from the [Access for SaaS app](#2-create-an-access-for-saas-app).
Use the Client ID, Client secret, and OAuth endpoints copied from the Cloudflare One dashboard. Do not use the OAuth values from your [third-party identity provider](/cloudflare-one/integrations/identity-providers/generic-oidc/).
211
+
:::
212
+
198
213
5. For `COOKIE_ENCRYPTION_KEY`, you can use the following command to generate a random string:
199
214
200
215
```sh
@@ -208,14 +223,14 @@ To add OAuth endpoints and credentials to our [example MCP server](#1-deploy-an-
208
223
1. Create the following [Workers secrets](/workers/configuration/secrets/):
209
224
210
225
```sh
211
-
wrangler secret put ACCESS_CLIENT_ID
212
-
wrangler secret put ACCESS_CLIENT_SECRET
213
-
wrangler secret put ACCESS_TOKEN_URL
214
-
wrangler secret put ACCESS_AUTHORIZATION_URL
215
-
wrangler secret put ACCESS_JWKS_URL
226
+
npx wrangler secret put ACCESS_CLIENT_ID
227
+
npx wrangler secret put ACCESS_CLIENT_SECRET
228
+
npx wrangler secret put ACCESS_TOKEN_URL
229
+
npx wrangler secret put ACCESS_AUTHORIZATION_URL
230
+
npx wrangler secret put ACCESS_JWKS_URL
216
231
```
217
232
218
-
2. When prompted to enter a secret value, paste the corresponding values from your SaaS app:
233
+
2. When prompted to enter a secret value, paste the corresponding values obtained from the [Access for SaaS app](#2-create-an-access-for-saas-app).
Use the Client ID, Client secret, and OAuth endpoints copied from the Cloudflare One dashboard. Do not use the OAuth values from your [third-party identity provider](/cloudflare-one/integrations/identity-providers/generic-oidc/).
245
+
:::
246
+
228
247
3. Generate a random string for the cookie encryption key:
229
248
230
249
```sh
@@ -234,14 +253,14 @@ To add OAuth endpoints and credentials to our [example MCP server](#1-deploy-an-
234
253
Store the output of this command in a Workers secret:
235
254
236
255
```sh
237
-
wrangler secret put COOKIE_ENCRYPTION_KEY
256
+
npx wrangler secret put COOKIE_ENCRYPTION_KEY
238
257
```
239
258
</TabItem>
240
259
</Tabs>
241
260
242
261
## 4. Test the connection
243
262
244
-
You should now be able to connect to your MCP server using [Workers AI Playground](https://playground.ai.cloudflare.com/), [MCP inspector](https://github.com/modelcontextprotocol/inspector), or [other MCP clients](/agents/guides/remote-mcp-server/#connect-your-mcp-server-to-claude-and-other-mcp-clients) that support remote MCP servers. The demo MCP server [supports connections](https://github.com/cloudflare/ai/blob/main/demos/remote-mcp-cf-access/src/index.ts#L63-L69) via either `https://mcp-server-cf-access.<YOUR_SUBDOMAIN>.workers.dev/mcp` or `https://mcp-server-cf-access.<YOUR_SUBDOMAIN>.workers.dev/sse`.
263
+
You can now connect to your MCP server at `https://mcp-server-cf-access.<YOUR_SUBDOMAIN>.workers.dev/mcp`using [Workers AI Playground](https://playground.ai.cloudflare.com/), [MCP inspector](https://github.com/modelcontextprotocol/inspector), or [other MCP clients](/agents/guides/remote-mcp-server/#connect-your-mcp-server-to-claude-and-other-mcp-clients) that support remote MCP servers.
0 commit comments