@@ -245,23 +245,68 @@ type MCPRouteAuthorization struct {
245245// MCPRouteAuthorizationRule defines an authorization rule for MCPRoute based on the MCP authorization spec.
246246// Reference: https://modelcontextprotocol.io/specification/draft/basic/authorization#scope-challenge-handling
247247type MCPRouteAuthorizationRule struct {
248- // Tools defines the list of tool names this rule applies to. The name must be a fully qualified tool name including the backend name.
249- // For example, "mcp-backend-name__tool-name".
248+ // Source defines the authorization source for this rule.
249+ //
250+ // +kubebuilder:validation:Required
251+ Source MCPAuthorizationSource `json:"source"`
252+
253+ // Target defines the authorization target for this rule.
250254 //
251- // If a request calls a tool in this list, this rule is considered a match.
252- // If this request has a valid JWT token that contains all the required scopes defined in this rule,
253- // the request will be allowed. If not, the request will be denied.
255+ // +kubebuilder:validation:Required
256+ Target MCPAuthorizationTarget `json:"target"`
257+ }
258+
259+ type MCPAuthorizationTarget struct {
260+ // Tools defines the list of tools this rule applies to.
254261 //
255262 // +kubebuilder:validation:MinItems=1
256263 // +kubebuilder:validation:MaxItems=16
257- Tools []string `json:"tools"`
264+ Tools []ToolCall `json:"tools"`
258265
266+ // TODO: we can add resources, prompts, etc. in the future.
267+ }
268+
269+ type MCPAuthorizationSource struct {
270+ // JWTSource defines the JWT scopes required for this rule to match.
271+ //
272+ // +kubebuilder:validation:Optional
273+ JWTSource * JWTSource `json:"jwtSource,omitempty"`
274+ }
275+
276+ type JWTSource struct {
259277 // Scopes defines the list of JWT scopes required for the rule.
260278 // If multiple scopes are specified, all scopes must be present in the JWT for the rule to match.
261279 //
262280 // +kubebuilder:validation:MinItems=1
263281 // +kubebuilder:validation:MaxItems=16
264282 Scopes []egv1a1.JWTScope `json:"scopes"`
283+
284+ //TODO : we can add more fields in the future, e.g., audiences, claims, etc.
285+ }
286+
287+ type ToolCall struct {
288+ // Tools defines the list of tool names this rule applies to. The name must be a fully qualified tool name including the backend name.
289+ // For example, "mcp-backend-name__tool-name".
290+ Name string `json:"name"`
291+
292+ // Arguments defines the arguments that must be present in the tool call for this rule to match.
293+ //
294+ // +optional
295+ Arguments map [string ]string `json:"arguments,omitempty"`
296+ }
297+
298+ type ToolArgument struct {
299+ // Name is the name of the argument.
300+ Name string `json:"name"`
301+
302+ // Value is the value of the argument.
303+ Value ArgumentValues `json:"value"`
304+ }
305+
306+ type ArgumentValues struct {
307+ Include []string `json:"include,omitempty"`
308+
309+ IncludeRegex []string `json:"includeRegex,omitempty"`
265310}
266311
267312// JWKS defines how to obtain JSON Web Key Sets (JWKS) either from a remote HTTP/HTTPS endpoint or from a local source.
0 commit comments