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
* Replace `_<mcp_gateway>_` with the name of your MCP gateway.
47
+
* Replace `_<gateway_system>_` with the namespace of your `Gateway` object.
48
+
* Replace `*.mcp-internal.example.com` with a wildcard hostname for your environment.
49
+
23
50
. Ensure that your identity provider includes the required `group` and `role` claims in the issued JWTs. In the following example, {keycloak} is used:
24
51
+
25
52
.Example issued OAuth token claims:
@@ -37,10 +64,15 @@ The following example demonstrates using a Kuadrant `AuthPolicy` custom resource
37
64
}
38
65
----
39
66
+
40
-
* The `"mcp-ns/arithmetic-mcp-server"` specification must match the namespaced name of the `MCPServerRegistration` CR.
67
+
* The `"mcp-ns/arithmetic-mcp-server"` specification must match the namespaced name of the `MCPServerRegistration` CR in the format `{namespace}/{name}`. For example, if your `MCPServerRegistration` is named `arithmetic-mcp-server` in the `mcp-ns` namespace, the {keycloak} client ID must be `mcp-ns/arithmetic-mcp-server`.
41
68
* The `"roles": ["add", "sum", "multiply", "divide"]` parameter and values specify the roles representing the allowed tools.
42
69
43
-
. Configure tool-level authorization by creating an `AuthPolicy` CR that enforces tool-level access control, as shown in the following example:
70
+
. Configure tool-level authorization by creating an `AuthPolicy` CR that enforces tool-level access control on the `mcps` listener, as shown in the following example:
71
+
+
72
+
[IMPORTANT]
73
+
====
74
+
The authorization `AuthPolicy` must target the `mcps` listener, not the `mcp` listener. The `mcp` listener handles public traffic (`initialize`, `tools/list`, `/.well-known`) and has the authentication-only `AuthPolicy`.
* Replace `metadata.name:` with the name of the `AuthPolicy`.
91
123
* Replace `metadata.namespace:` with the namespace where the `AuthPolicy` CR is applied.
92
124
* Replace `spec.targetRef.name:` with the name of the `Gateway` CR.
93
-
* The `spec.targetRef.sectionName:` value targets the MCP server listener.
94
-
* Authentication: Validates the JWT token using the configured issuer URL
125
+
* The `spec.targetRef.sectionName:` value must be `mcps`, the internal listener for tool-call authorization. This listener must exist on your `Gateway` object.
126
+
* Authentication: Validates the JWT token using the configured issuer URL. Replace `_<keycloak.example.com>_` with your identity provider hostname.
95
127
* Authorization Logic: CEL expression checks if user's roles allow access to the requested tool
96
128
* CEL Breakdown:
97
129
**`request.headers['x-mcp-toolname']`: The name of the requested MCP tool, stripped from prefix.
@@ -103,24 +135,24 @@ spec:
103
135
+
104
136
[source,terminal,subs="+quotes"]
105
137
----
106
-
$ oc apply -f _<mcp_tool_auth_policy.yaml>_
138
+
$ oc apply -f - <<EOF
139
+
<AuthPolicy CR from the previous step>
140
+
EOF
107
141
----
108
-
* Replace `_<mcp_tool_auth_policy.yaml>_` with the name of the `AuthPolicy` YAML filename.
109
142
110
143
.Verification
111
144
112
145
. Monitor authorization decisions by checking the `AuthPolicy` CR `status` with the following command:
113
146
+
114
-
[source,terminal]
147
+
[source,terminal,subs="+quotes"]
115
148
----
116
-
$ oc get authpolicy -A
149
+
$ oc get authpolicy _<mcp_tool_auth_policy>_ -n _<gateway_system>_ -o jsonpath='{.status.conditions[?(@.type=="Enforced")].status}'
117
150
----
118
151
+
119
152
.Example output
120
153
[source,text]
121
154
----
122
-
NAMESPACE NAME STATUS
123
-
gateway-system mcp-tool-auth-policy Enforced
155
+
True
124
156
----
125
157
126
158
. Check the authorization logs by running the following command:
0 commit comments