Skip to content

Commit 41f189a

Browse files
committed
update API
Signed-off-by: Huabing Zhao <[email protected]>
1 parent 269a927 commit 41f189a

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

api/v1alpha1/mcp_route.go

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,68 @@ type MCPRouteAuthorization struct {
250250
// MCPRouteAuthorizationRule defines an authorization rule for MCPRoute based on the MCP authorization spec.
251251
// Reference: https://modelcontextprotocol.io/specification/draft/basic/authorization#scope-challenge-handling
252252
type MCPRouteAuthorizationRule struct {
253-
// Tools defines the list of tool names this rule applies to. The name must be a fully qualified tool name including the backend name.
254-
// For example, "mcp-backend-name__tool-name".
253+
// Source defines the authorization source for this rule.
254+
//
255+
// +kubebuilder:validation:Required
256+
Source MCPAuthorizationSource `json:"source"`
257+
258+
// Target defines the authorization target for this rule.
255259
//
256-
// If a request calls a tool in this list, this rule is considered a match.
257-
// If this request has a valid JWT token that contains all the required scopes defined in this rule,
258-
// the request will be allowed. If not, the request will be denied.
260+
// +kubebuilder:validation:Required
261+
Target MCPAuthorizationTarget `json:"target"`
262+
}
263+
264+
type MCPAuthorizationTarget struct {
265+
// Tools defines the list of tools this rule applies to.
259266
//
260267
// +kubebuilder:validation:MinItems=1
261268
// +kubebuilder:validation:MaxItems=16
262-
Tools []string `json:"tools"`
269+
Tools []ToolCall `json:"tools"`
263270

271+
// TODO: we can add resources, prompts, etc. in the future.
272+
}
273+
274+
type MCPAuthorizationSource struct {
275+
// JWTSource defines the JWT scopes required for this rule to match.
276+
//
277+
// +kubebuilder:validation:Optional
278+
JWTSource *JWTSource `json:"jwtSource,omitempty"`
279+
}
280+
281+
type JWTSource struct {
264282
// Scopes defines the list of JWT scopes required for the rule.
265283
// If multiple scopes are specified, all scopes must be present in the JWT for the rule to match.
266284
//
267285
// +kubebuilder:validation:MinItems=1
268286
// +kubebuilder:validation:MaxItems=16
269287
Scopes []egv1a1.JWTScope `json:"scopes"`
288+
289+
//TODO : we can add more fields in the future, e.g., audiences, claims, etc.
290+
}
291+
292+
type ToolCall struct {
293+
// Tools defines the list of tool names this rule applies to. The name must be a fully qualified tool name including the backend name.
294+
// For example, "mcp-backend-name__tool-name".
295+
Name string `json:"name"`
296+
297+
// Arguments defines the arguments that must be present in the tool call for this rule to match.
298+
//
299+
// +optional
300+
Arguments map[string]string `json:"arguments,omitempty"`
301+
}
302+
303+
type ToolArgument struct {
304+
// Name is the name of the argument.
305+
Name string `json:"name"`
306+
307+
// Value is the value of the argument.
308+
Value ArgumentValues `json:"value"`
309+
}
310+
311+
type ArgumentValues struct {
312+
Include []string `json:"include,omitempty"`
313+
314+
IncludeRegex []string `json:"includeRegex,omitempty"`
270315
}
271316

272317
// 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

Comments
 (0)