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
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.
12
12
13
13
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 <GlossaryTooltipterm="MCP client">MCP client</GlossaryTooltip>.
14
14
@@ -34,13 +34,104 @@ accTitle: Link MCP servers and self-hosted applications in Access
34
34
idp[Identity provider] <--> SaaS
35
35
```
36
36
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
+
37
39
## Prerequisites
38
40
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:
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.
0 commit comments