Skip to content

Commit 6e2d74b

Browse files
committed
add API calls
1 parent cf3611b commit 6e2d74b

File tree

1 file changed

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

1 file changed

+96
-5
lines changed

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

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ sidebar:
66
label: Enable MCP OAuth to self-hosted apps
77
---
88

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

11-
Cloudflare Access can delegate access from any [self-hosted application](/cloudflare-one/applications/configure-apps/self-hosted-public-app/) to an [Access for SaaS MCP server](/cloudflare-one/applications/configure-apps/mcp-servers/saas-mcp/) via [OAuth](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization). The OAuth grant authorizes the MCP server to make requests to your self-hosted applications on behalf of the user, using the user's specific permissions and scopes.
11+
Cloudflare Access can delegate access from any [self-hosted application](/cloudflare-one/applications/configure-apps/self-hosted-public-app/) to an [Access for SaaS MCP server](/cloudflare-one/applications/configure-apps/mcp-servers/saas-mcp/) via [OAuth](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization). The OAuth access token authorizes the MCP server to make requests to your self-hosted applications on behalf of the user, using the user's specific permissions and scopes.
1212

1313
For example, your organization may wish to deploy an MCP server that helps employees interact with internal Atlassian applications. You can configure [Access policies](/cloudflare-one/policies/access/#selectors) to ensure that only authorized users can access those applications, either directly or by using an <GlossaryTooltip term="MCP client">MCP client</GlossaryTooltip>.
1414

@@ -34,13 +34,104 @@ accTitle: Link MCP servers and self-hosted applications in Access
3434
idp[Identity provider] <--> SaaS
3535
```
3636

37+
This guide covers how to use the Cloudflare API to link a self-hosted application to a remote MCP server. The core of this feature is the `linked_app_token` rule type, which allows an Access policy on one application to accept OAuth access tokens generated for another.
38+
3739
## Prerequisites
3840

39-
## 1. Create an Access policy
41+
- A [self-hosted Access application](/cloudflare-one/applications/configure-apps/self-hosted-public-app/)
42+
43+
## 1. Secure the MCP server with Access for SaaS
44+
45+
The first step is to add the MCP server to Cloudflare Access as an OIDC-based SaaS application. For step-by-step instructions on how to add an MCP server, refer to [Secure MCP servers with Access for SaaS](/cloudflare-one/applications/configure-apps/mcp-servers/saas-mcp/).
46+
47+
## 2. Get the SaaS application ID
48+
49+
Get the `id` of the MCP server SaaS application:
50+
51+
<APIRequest
52+
path="/accounts/{account_id}/access/apps"
53+
method="GET"
54+
/>
55+
56+
```json title="Response"
57+
{
58+
"id": "3537a672-e4d8-4d89-aab9-26cb622918a1",
59+
"uid": "3537a672-e4d8-4d89-aab9-26cb622918a1",
60+
"type": "saas",
61+
"name": "mcp-server-cf-access",
62+
...
63+
}
64+
```
65+
66+
## 3. Create an Access policy
67+
68+
1. Create the following Access policy, replacing the `app_uid` value with the `id` of your SaaS application:
69+
70+
<APIRequest
71+
path="/accounts/{account_id}/access/policies"
72+
method="POST"
73+
json={{
74+
name: "Allow MCP server",
75+
decision: "non_identity",
76+
include: [
77+
{
78+
linked_app_token: {
79+
app_uid: "3537a672-e4d8-4d89-aab9-26cb622918a1"
80+
}
81+
}
82+
]
83+
}}
84+
/>
85+
86+
:::note
87+
The `linked_app_token` rule type works best with `non_identity` decisions, similar to service token rules.
88+
:::
89+
90+
2. Copy the Access policy `id` returned in the response:
91+
92+
```json title="Response" {5}
93+
{
94+
"created_at": "2025-08-06T20:06:23Z",
95+
"decision": "non_identity",
96+
"exclude": [],
97+
"id": "a38ab4d4-336d-4f49-9e97-eff8550c13fa",
98+
"include": [
99+
{
100+
"linked_app_token": {
101+
"app_uid": "6cdc3892-f9f1-4813-a5ce-38c2753e1208"
102+
}
103+
}
104+
],
105+
"name": "Allow MCP server",
106+
...
107+
}
108+
```
109+
110+
This policy will allow requests if they present a valid OAuth access token that was issued for the specified SaaS application.
111+
112+
## 4. Update the self-hosted application
113+
114+
1. Get your existing self-hosted application configuration:
115+
116+
<APIRequest
117+
path="/accounts/{account_id}/access/apps/{app_id}"
118+
method="GET"
119+
/>
120+
121+
2. Add the new Access policy to the self-hosted application. To avoid overwriting your existing configuration, the `PUT` request body should contain all fields returned by the previous `GET` request.
122+
123+
<APIRequest
124+
path="/accounts/{account_id}/access/apps/{app_id}"
125+
method="PUT"
126+
json={{
127+
policies: [
128+
"a38ab4d4-336d-4f49-9e97-eff8550c13fa"
129+
],
130+
}}
131+
/>
40132

41-
## 2. Update the self-hosted app
133+
## 5. Configure the MCP server
42134

43-
## 3. Configure the MCP server
44135

45136
## Known limitations
46137

0 commit comments

Comments
 (0)