Skip to content

Commit 08fdc67

Browse files
committed
Start adding next steps after initial getting started
1 parent 961815e commit 08fdc67

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

src/content/docs/agents/model-context-protocol/mcp-server/authorization/oauth-provider-api-reference.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ sidebar:
77
order: 5
88
head: []
99
---
10+
11+
{/* TODO: this page (or the linked docs) need to be really clear about what the defaultHandler must implement, and provide a really clear reference example */}

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

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,17 @@ sidebar:
77

88
import { Details, Render, PackageManagers } from "~/components";
99

10-
# Deploy an MCP Server to Cloudflare
11-
12-
You can build and deploy MCP servers on Cloudflare, using the `@cloudflare/model-context-protocol` package, 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/).
13-
14-
This guide and the accompanying [examples](/agents/model-context-protocol/mcp-server/examples/) will help you get started.
15-
16-
### What is the Model Context Protocol (MCP)?
17-
18-
[Model Context Protocol (MCP)](https://modelcontextprotocol.io) is an open standard that connects AI systems with external applications. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various accessories, MCP provides a standardized way to connect AI agents to different services.
19-
20-
#### MCP Terminology
21-
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-
- **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.
25-
26-
#### Remote vs. local MCP connections
27-
28-
The MCP standard supports two modes of operation:
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/).
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-
33-
Cloudflare's MCP Server SDK, is designed to support remote MCP connections. Remote MCP connections allow MCP clients that run in web browsers, mobile apps, and other environments outside of the end-user's machine to connect to your MCP server, such as [Claude.ai](https://www.anthropic.com/claude), and other AI agents.
34-
35-
### Why deploy your MCP server to Cloudflare?
36-
37-
- Define [tools](/agents/model-context-protocol/mcp-server/tools/) by just writing TypeScript methods, in the [same way you write RPC methods in Workers and Durable Objects](/workers/runtime-apis/rpc/).
38-
- Authorization is [built-in](/agents/model-context-protocol/mcp-server/authorization/). The MCP Server SDK handles the hard parts of the OAuth flow for you.
39-
- Transport over HTTP with Server-Sent Events (SSE) is [built-in](/agents/model-context-protocol/mcp-server/transport/), with automatic hibernation of idle connections to reduce costs
40-
- You can create stateful MCP Servers with the [Agents SDK](/agents/)
41-
- Your MCP server can be called by the [Agents SDK](/agents/), which is an MCP client
42-
4310
## Deploy your first MCP server
4411

45-
{/* TODO: Update deploy to Workers button */}
46-
The best way to get started is to deploy an [example MCP server](https://github.com/geelen/mcp-remote-examples/tree/main/02-user-password) to your Cloudflare account. You can then customize this example to suit your needs.
47-
48-
### Option 1: Deploy your MCP server first, then develop locally
12+
This guide will walk you through how to deploy an [example MCP server](https://github.com/geelen/mcp-remote-examples/tree/main/02-user-password) to your Cloudflare account. You will then customize this example to suit your needs.
4913

5014
{/* TODO: Update link to example */}
51-
The link below will guide you through everything you need to do to deploy an [example MCP server](https://github.com/geelen/mcp-remote-examples/tree/main/02-user-password) to your Cloudflare account:
15+
The link below will guide you through everything you need to do to deploy this [example MCP server](https://github.com/geelen/mcp-remote-examples/tree/main/02-user-password) to your Cloudflare account:
5216

5317
{/* TODO: Update deploy to Workers button */}
54-
[![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/mcp-server-example)
18+
[![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/mcp-server-example)
5519

56-
At the end of this process, you will have a new git repository on your GitHub or GitLab account for your MCP server that is 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 customize the code to suit your needs.
57-
58-
### Option 2: Create a new MCP Server via the CLI
20+
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.
5921

6022
Alternatively, you can use the command line as shown below to create a new MCP Server on your local machine.
6123

@@ -117,7 +79,45 @@ npx wrangler@latest deploy
11779

11880
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.
11981

120-
### Next Steps
82+
After deploying, take the URL of your deployed MCP server, and enter it in the MCP inspector running on `http://localhost:5173`. You now have a remote MCP server, deployed to Cloudflare, that MCP clients can connect to.
83+
84+
## Add Authentication
85+
86+
The example MCP server you just deployed above acts as an OAuth provider to MCP clients, handling authorization, but has a placeholder authentication flow. It lets you enter any username and password to log in, and doesn't actually authenticate you against any user database.
87+
88+
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.
89+
90+
We'll use GitHub as the authentication provider here, but you can use any OAuth provider that supports the OAuth 2.0 specification, and we have examples for:
91+
92+
- [Stytch](/agents/model-context-protocol/mcp-server/examples/stytch/)
93+
- [Clerk](/agents/model-context-protocol/mcp-server/examples/clerk/)
94+
- [Google](/agents/model-context-protocol/mcp-server/examples/google/)
95+
96+
### Step 1 — Update the default handler
97+
98+
In your example MCP server, open `src/index.ts`, and change the value of `defaultHandler` in to instead use the `GitHubHandler`:
99+
100+
{/* TODO: GitHub Code Component */}
101+
102+
```ts ins="OAuthProvider.GitHubHandler"
103+
export default new OAuthProvider({
104+
apiRoute: "/sse",
105+
apiHandler: MyMCP.Router,
106+
defaultHandler: OAuthProvider.GitHubHandler,
107+
authorizeEndpoint: "/authorize",
108+
tokenEndpoint: "/token",
109+
clientRegistrationEndpoint: "/register",
110+
});
111+
```
112+
113+
{/* TODO: Update code link */}
114+
This will ensure that your users are redirected to GitHub to authenticate. If you're curious to understand what the `GitHubHandler` does you can read the code [here](https://github.com/geelen/mcp-remote-examples/blob/main/04-oauth-pivot/src/index.ts#L48-L152).
115+
116+
### Step 2 — Create a GitHub OAuth App
117+
118+
{/* TODO: instructions */}
119+
120+
## Next steps
121121

122122
- Add [tools](/agents/model-context-protocol/mcp-server/tools/) to your MCP server.
123123
- Customize your MCP Server's [authentication and authorization](/agents/model-context-protocol/mcp-server/authorization/).

0 commit comments

Comments
 (0)