Skip to content

Commit cf3611b

Browse files
committed
api example
1 parent 0a8e66b commit cf3611b

File tree

1 file changed

+41
-1
lines changed
  • src/content/docs/cloudflare-one/applications/configure-apps/mcp-servers

1 file changed

+41
-1
lines changed

src/content/docs/cloudflare-one/applications/configure-apps/mcp-servers/saas-mcp.mdx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
label: Secure MCP servers with Access for SaaS
77
---
88

9-
import { Render, GlossaryTooltip } from "~/components"
9+
import { Render, GlossaryTooltip, Tabs, TabItem, APIRequest } from "~/components"
1010

1111
You can secure <GlossaryTooltip term="MCP server">Model Context Protocol (MCP) servers</GlossaryTooltip> by using Cloudflare Access as an OAuth Single Sign-On (SSO) provider.
1212

@@ -77,6 +77,9 @@ The Worker will be deployed to your `*.workers.dev` subdomain at `mcp-server-cf-
7777

7878
## 2. Create an Access for SaaS app
7979

80+
<Tabs syncKey="dashPlusAPI">
81+
<TabItem label="Dashboard">
82+
8083
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Access** > **Applications**.
8184
2. Select **SaaS**.
8285
3. In **Application**, enter a custom name (for example, `MCP server`) and select the textbox that appears below.
@@ -97,6 +100,43 @@ The Worker will be deployed to your `*.workers.dev` subdomain at `mcp-server-cf-
97100
9. Configure [Access policies](/cloudflare-one/policies/access/) to define the users who can access the MCP server.
98101
10. Save the application.
99102

103+
</TabItem>
104+
<TabItem label="API">
105+
106+
1. Make a `POST` request to the [Access applications](/api/resources/zero_trust/subresources/access/subresources/applications/methods/create/) endpoint:
107+
108+
<APIRequest
109+
path="/accounts/{account_id}/access/apps"
110+
method="POST"
111+
json={{
112+
name: "MCP server",
113+
type: "saas",
114+
saas_app: {
115+
auth_type: "oidc",
116+
redirect_uris: [
117+
"https://mcp-server-cf-access.<YOUR_SUBDOMAIN>.workers.dev/callback"
118+
],
119+
grant_type: [
120+
"authorization_code",
121+
"refresh_tokens"
122+
],
123+
refresh_token_options: {
124+
lifetime: "90d"
125+
}
126+
},
127+
policies: [
128+
"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
129+
],
130+
allowed_idps: []
131+
}}
132+
/>
133+
134+
2. Copy the `client_id` and `client_secret` returned in the response.
135+
3. To determine the OAuth endpoint URLs for the SaaS application, refer to the [generic OIDC documentation](/cloudflare-one/applications/configure-apps/saas-apps/generic-oidc-saas/#2-add-your-application-to-access).
136+
137+
</TabItem>
138+
</Tabs>
139+
100140
## 3. Configure your MCP server
101141

102142
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.

0 commit comments

Comments
 (0)