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/guides/build-mcp-server.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
@@ -37,7 +37,7 @@ Below we will run you through an example of building an MCP server that fetches
37
37
Follow these steps to create and deploy your own MCP server on Cloudflare Workers.
38
38
39
39
:::note
40
-
Looking to deploy a MCP server that supports _remote_ connections over the Internet, with authentication and authorization? Check out our [guide](/docs/agents/model-context-protocol/getting-started) for building and deploying remote MCP servers to Cloudflare.
40
+
Looking to deploy a MCP server that supports _remote_ connections over the Internet, with authentication and authorization? Check out our [guide](/agents/model-context-protocol/getting-started) for building and deploying remote MCP servers to Cloudflare.
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/authorization.mdx
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,12 @@ When building a [Model Context Protocol (MCP)](https://modelcontextprotocol.io)
16
16
17
17
The Model Context Protocol uses [a subset of OAuth 2.1 for authorization](https://spec.modelcontextprotocol.io/specification/draft/basic/authorization/). OAuth allows your users to grant limited access to resources, without them having to share API keys or other credentials.
18
18
19
-
Cloudflare provides an [OAuth Provider Library](https://github.com/cloudflare/ai/demos/remote-mcp-server/lib/workers-oauth-provider) that implements the provider side of the OAuth 2.1 protocol, allowing you to easily add authorization to your MCP server.
19
+
Cloudflare provides an [OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider) that implements the provider side of the OAuth 2.1 protocol, allowing you to easily add authorization to your MCP server.
20
20
21
21
You can use the OAuth Provider Library in three ways:
22
22
23
-
1.**Your Worker handles authorization itself.** Your MCP server, running on Cloudflare, handles the complete OAuth flow. ([Example](/agents/model-context-protocol/mcp-server/getting-started/))
24
-
2.**Integrate directly with a third-party OAuth provider**, such as GitHub or Google. ([Example](/agents/model-context-protocol/mcp-server/examples/github/))
23
+
1.**Your Worker handles authorization itself.** Your MCP server, running on Cloudflare, handles the complete OAuth flow. ([Example](/agents/model-context-protocol/getting-started/))
24
+
2.**Integrate directly with a third-party OAuth provider**, such as GitHub or Google. ([Example](/agents/guides/remote-mcp-server-github/))
25
25
3.**Integrate with your own OAuth provider**, including authorization-as-a-service providers you might already rely on, such as Stytch and Auth0.
26
26
27
27
The following sections describe each of these options and link to runnable code examples for each.
@@ -30,9 +30,9 @@ The following sections describe each of these options and link to runnable code
30
30
31
31
### (1) Your MCP Server handles authorization and authentication itself
32
32
33
-
Your MCP Server, using the [OAuth Provider Library](https://github.com/cloudflare/ai/demos/remote-mcp-server/lib/workers-oauth-provider), can handle the complete OAuth authorization flow, without any third-party involvement.
33
+
Your MCP Server, using the [OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider), can handle the complete OAuth authorization flow, without any third-party involvement.
34
34
35
-
The [Workers OAuth Provider Library](https://github.com/cloudflare/ai/demos/remote-mcp-server/lib/workers-oauth-provider) is a Cloudflare Worker that implements a [`fetch()` handler](/workers/runtime-apis/handlers/fetch/), and handles incoming requests to your MCP server.
35
+
The [Workers OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider) is a Cloudflare Worker that implements a [`fetch()` handler](/workers/runtime-apis/handlers/fetch/), and handles incoming requests to your MCP server.
36
36
37
37
You provide your own handlers for your MCP Server's API, and autentication and authorization logic, and URI paths for the OAuth endpoints, as shown below:
38
38
@@ -49,7 +49,7 @@ export default new OAuthProvider({
49
49
});
50
50
```
51
51
52
-
Refer to the [getting started example](/agents/model-context-protocol/mcp-server/getting-started/) for a complete example of the `OAuthProvider` in use, with a mock authentication flow.
52
+
Refer to the [getting started example](/agents/model-context-protocol/getting-started/) for a complete example of the `OAuthProvider` in use, with a mock authentication flow.
53
53
54
54
The authorization flow in this case works like this:
55
55
@@ -73,11 +73,11 @@ sequenceDiagram
73
73
Note over C,M: Begin standard MCP message exchange
74
74
```
75
75
76
-
Remember — [authentication is different from authorization](https://www.cloudflare.com/learning/access-management/authn-vs-authz/). Your MCP Server can handle authorization itself, while still relying on an external authentication service to first authenticate users. The [example](/agents/model-context-protocol/mcp-server/getting-started) in getting started provides a mock authentdcation flow. You will need to implement your own authentication handler — either handling authentication yourself, or using an external authentication services.
76
+
Remember — [authentication is different from authorization](https://www.cloudflare.com/learning/access-management/authn-vs-authz/). Your MCP Server can handle authorization itself, while still relying on an external authentication service to first authenticate users. The [example](/agents/model-context-protocol/getting-started) in getting started provides a mock authentdcation flow. You will need to implement your own authentication handler — either handling authentication yourself, or using an external authentication services.
77
77
78
78
### (2) Third-party OAuth Provider
79
79
80
-
The [OAuth Provider Library](https://github.com/cloudflare/ai/demos/remote-mcp-server/lib/workers-oauth-provider) can be configured to use a third-party OAuth provider, such as GitHub or Google. You can see a complete example of this in the [GitHub example](/agents/guides/remote-mcp-server-github).
80
+
The [OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider) can be configured to use a third-party OAuth provider, such as GitHub or Google. You can see a complete example of this in the [GitHub example](/agents/guides/remote-mcp-server-github).
81
81
82
82
When you use a third-party OAuth provider, you must provide a handler to the `OAuthProvider` that implements the OAuth flow for the third-party provider.
83
83
@@ -120,13 +120,13 @@ sequenceDiagram
120
120
M->>C: MCP access token
121
121
```
122
122
123
-
Read the docs for the [Workers oAuth Provider Library](https://github.com/cloudflare/ai/demos/remote-mcp-server/lib/workers-oauth-provider) for more details.
123
+
Read the docs for the [Workers oAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider) for more details.
124
124
125
125
### (3) Bring your own OAuth Provider
126
126
127
127
If your application already implements an Oauth Provider itself, or you use Stytch, Auth0, or authorization-as-a-service provider, you can use this in the same way that you would use a third-party OAuth provider, described above in (2).
128
128
129
129
## Next steps
130
130
131
-
-[Learn how to use the OAuth Provider SDK](/agents/model-context-protocol/mcp-server/authorization/oauth-provider-api-reference/)
132
-
- Learn how to use a third-party OAuth provider, using the [GitHub](/agents/model-context-protocol/mcp-server/examples/github/)and [Slack](/agents/model-context-protocol/mcp-server/examples/slack/) examples.
131
+
-[Learn how to use the Workers OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider)
132
+
- Learn how to use a third-party OAuth provider, using the [GitHub](/agents/guides/remote-mcp-server-github/)example MCP server.
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/getting-started.mdx
+12-19Lines changed: 12 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ You can build both local and remote [Model Context Protocol (MCP)](https://model
11
11
12
12
Local MCP servers rely on running a local proxy on the same machine as your application. Remote MCP servers run on Cloudflare and support remote, authenticated connections over the Internet.
13
13
14
-
This guide will teach you how to build and deploy your first remote MCP server to Cloudflare. If you want to build a local MCP server, see the [build a local MCP server](/agents/guides/build-mcp-server/) guide.
14
+
This guide will teach you how to build and deploy your first remote MCP server to Cloudflare. If you want to build a local MCP server, see the [build a local MCP server](/agents/guides/build-mcp-server/) guide instead.
15
15
16
16
### What is the Model Context Protocol (MCP)?
17
17
@@ -21,24 +21,24 @@ This guide will teach you how to build and deploy your first remote MCP server t
21
21
22
22
-**MCP Hosts**: AI assistants (like [Claude](http://claude.ai) or [Cursor](http://cursor.com)), AI agents, or applications that need to access external capabilities.
23
23
-**MCP Clients**: Clients embedded within the MCP hosts that connect to MCP servers and invoke tools. Each MCP client instance has a single connection to an MCP server.
24
-
-**MCP Servers**: Applications that expose [tools](/agents/model-context-protocol/mcp-server/tools/), [prompts](https://modelcontextprotocol.io/docs/concepts/prompts), and [resources](https://modelcontextprotocol.io/docs/concepts/resources) that MCP clients can use.
24
+
-**MCP Servers**: Applications that expose [tools](/agents/model-context-protocol/tools/), [prompts](https://modelcontextprotocol.io/docs/concepts/prompts), and [resources](https://modelcontextprotocol.io/docs/concepts/resources) that MCP clients can use.
25
25
26
26
#### Remote vs. local MCP connections
27
27
28
28
The MCP standard supports two modes of operation:
29
29
30
-
-**Remote MCP connections**: MCP clients connect to MCP servers over the Internet, establishing a [long-lived connection using HTTP and Server-Sent Events (SSE)](/agents/model-context-protocol/mcp-server/transport/), and authorizing the MCP client access to resources on the user's account using [OAuth](/agents/model-context-protocol/mcp-server/authorization/).
30
+
-**Remote MCP connections**: MCP clients connect to MCP servers over the Internet, establishing a [long-lived connection using HTTP and Server-Sent Events (SSE)](/agents/model-context-protocol/transport/), and authorizing the MCP client access to resources on the user's account using [OAuth](/agents/model-context-protocol/authorization/).
31
31
-**Local MCP connections**: MCP clients connect to MCP servers on the same machine, using [stdio](https://spec.modelcontextprotocol.io/specification/draft/basic/transports/#stdio) as a local transport method.
32
32
33
33
## Deploy your first MCP server
34
34
35
-
This guide will walk you through how to deploy an [example MCP server](https://github.com/cloudflare/ai/demos/remote-mcp-server) to your Cloudflare account. You will then customize this example to suit your needs.
35
+
This guide will walk you through how to deploy an [example MCP server](https://github.com/cloudflare/ai/tree/main/demos/remote-mcp-server) to your Cloudflare account. You will then customize this example to suit your needs.
36
36
37
-
The link below will guide you through everything you need to do to deploy this [example MCP server](https://github.com/cloudflare/ai/demos/remote-mcp-server) to your Cloudflare account:
37
+
The link below will guide you through everything you need to do to deploy this [example MCP server](https://github.com/cloudflare/ai/tree/main/demos/remote-mcp-server) to your Cloudflare account:
38
38
39
-
[](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/ai/demos/remote-mcp-server)
39
+
[](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/ai/tree/main/demos/remote-mcp-server)
40
40
41
-
At the end of this process, you will have a new git repository on your GitHub or GitLab account for your MCP server, configured to automatically deploy Cloudflare each time you push a change or merge a pull request to the main branch of the repository. You can then clone this repository, [develop locally](/agents/model-context-protocol/mcp-server/getting-started/#local-development), and start writing code and building.
41
+
At the end of this process, you will have a new git repository on your GitHub or GitLab account for your MCP server, configured to automatically deploy Cloudflare each time you push a change or merge a pull request to the main branch of the repository. You can then clone this repository, [develop locally](/agents/model-context-protocol/getting-started/#local-development), and start writing code and building.
42
42
43
43
Alternatively, you can use the command line as shown below to create a new MCP Server on your local machine.
44
44
@@ -80,7 +80,7 @@ In the inspector, enter the URL of your MCP server, `http://localhost:8787/sse`,
80
80
81
81

82
82
83
-
You will be redirected to an example OAuth login page. Enter any username and password and click "Log in and approve" to continue. (you can add your own authentication and/or authorization provider to replace this. Refer to the [authorization](/agents/model-context-protocol/mcp-server/authorization/) section for details on how to do this.)
83
+
You will be redirected to an example OAuth login page. Enter any username and password and click "Log in and approve" to continue. (you can add your own authentication and/or authorization provider to replace this. Refer to the [authorization](/agents/model-context-protocol/authorization/) section for details on how to do this.)
@@ -277,18 +277,11 @@ wrangler secret put GITHUB_CLIENT_ID
277
277
wrangler secret put GITHUB_CLIENT_SECRET
278
278
```
279
279
280
-
#### Finally, deploy your MCP server
280
+
#### Finally, connect to your MCP server
281
281
282
-
Run the following command to deploy your MCP server:
283
-
284
-
```sh
285
-
npm run deploy
286
-
```
287
-
288
-
You should now be able to connect to your MCP server using the MCP Inspector or other MCP clients ([as shown above](/agents/model-context-protocol/getting-started/#connect-your-mcp-server-to-claude-and-other-mcp-clients)) and allow the user to authenticate with GitHub.
282
+
Now that you've added the ID and secret of your production OAuth app, you should now be able to connect to your MCP server running at `worker-name.account-name.workers.dev/sse` using the MCP inspector or ([other MCP clients](/agents/model-context-protocol/getting-started/#connect-your-mcp-server-to-claude-and-other-mcp-clients)), and authenticate with GitHub.
289
283
290
284
## Next steps
291
285
292
-
- Add [tools](/agents/model-context-protocol/mcp-server/tools/) to your MCP server.
293
-
- Customize your MCP Server's [authentication and authorization](/agents/model-context-protocol/mcp-server/authorization/).
294
-
- Try other [example MCP servers](/agents/model-context-protocol/mcp-server/examples/)
286
+
- Add [tools](/agents/model-context-protocol/tools/) to your MCP server.
287
+
- Customize your MCP Server's [authentication and authorization](/agents/model-context-protocol/authorization/).
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/tools.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ sidebar:
7
7
8
8
import { Render } from"~/components";
9
9
10
-
Model Context Protocol (MCP) tools are functions that a [MCP Server](/agents/model-context-protocol/mcp-server) provides and MCP clients can call.
10
+
Model Context Protocol (MCP) tools are functions that a [MCP Server](/agents/model-context-protocol) provides and MCP clients can call.
11
11
12
12
When you build MCP Servers with the `@cloudflare/model-context-protocol` package, you can define tools the [same way as shown in the `@modelcontextprotocol/typescript-sdk` package's examples](https://github.com/modelcontextprotocol/typescript-sdk?tab=readme-ov-file#tools).
13
13
14
-
For example, the following code from [this example MCP server](https://github.com/cloudflare/ai/demos/remote-mcp-server) defines a simple MCP server that adds two numbers together:
14
+
For example, the following code from [this example MCP server](https://github.com/cloudflare/ai/tree/main/demos/remote-mcp-server) defines a simple MCP server that adds two numbers together:
Copy file name to clipboardExpand all lines: src/content/docs/agents/model-context-protocol/transport.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
@@ -12,7 +12,7 @@ The Model Context Protocol (MCP) specification defines [two standard transport m
12
12
1.**stdio, communication over standard in and standard out** — designed for local MCP connections
13
13
2.**HTTP with Server-Sent Events (SSE)** — designed for remote MCP connections
14
14
15
-
The [remote MCP examples](/agents/model-context-protocol/mcp-server/getting-started/) support remote MCP connections, using HTTP with Server-Sent Events (SSE) as transport. SSE requires a persistent HTTP connection, which is supported by Cloudflare [Durable Objects](/durable-objects/). Transport is configured and handled automatically. You don't need to configure anything — it just works.
15
+
The [remote MCP examples](/agents/model-context-protocol/getting-started/) support remote MCP connections, using HTTP with Server-Sent Events (SSE) as transport. SSE requires a persistent HTTP connection, which is supported by Cloudflare [Durable Objects](/durable-objects/). Transport is configured and handled automatically. You don't need to configure anything — it just works.
16
16
17
17
:::note
18
18
If you are looking to deploy a MCP server that supports _local_ MCP connections, you should follow the [guide](/agents/guides/build-mcp-server/) for building local MCP servers using Cloudflare Workers.
0 commit comments