Skip to content

Commit dab18f8

Browse files
committed
rename arguments to condition
Signed-off-by: Huabing Zhao <[email protected]>
1 parent b8e32a6 commit dab18f8

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

api/v1alpha1/mcp_route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ type ToolCall struct {
321321
// +kubebuilder:validation:Required
322322
ToolName string `json:"toolName"`
323323

324-
// Arguments is a CEL expression that must evaluate to true for the rule to match.
324+
// Condition is a CEL expression that must evaluate to true for the rule to match.
325325
// The expression is evaluated with a single variable "args" bound to the tool call arguments as a dynamic object.
326326
// Guard against missing fields with null checks (e.g., args["foo"] != null && args["foo"]["bar"] == "val").
327327
//
328328
// +kubebuilder:validation:Optional
329329
// +kubebuilder:validation:MaxLength=4096
330330
// +optional
331-
Arguments *string `json:"arguments,omitempty"`
331+
Condition *string `json:"condition,omitempty"`
332332
}
333333

334334
// JWKS defines how to obtain JSON Web Key Sets (JWKS) either from a remote HTTP/HTTPS endpoint or from a local source.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func mcpConfig(mcpRoutes []aigv1a1.MCPRoute) *filterapi.MCPConfig {
495495
tools[i] = filterapi.ToolCall{
496496
Backend: tool.Backend,
497497
ToolName: tool.ToolName,
498-
Arguments: tool.Arguments,
498+
Condition: tool.Condition,
499499
}
500500
}
501501

internal/filterapi/mcpconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type ToolCall struct {
125125
// ToolName is the name of the tool.
126126
ToolName string `json:"toolName"`
127127

128-
// Arguments is a CEL expression evaluated against the tool call arguments map.
128+
// Condition is a CEL expression evaluated against the tool call arguments map.
129129
// The expression must evaluate to true for the rule to apply.
130-
Arguments *string `json:"arguments,omitempty"`
130+
Condition *string `json:"condition,omitempty"`
131131
}

internal/mcpproxy/authorization.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ func compileAuthorization(auth *filterapi.MCPRouteAuthorization) (*compiledAutho
6969
Backend: tool.Backend,
7070
ToolName: tool.ToolName,
7171
}
72-
if tool.Arguments != nil && strings.TrimSpace(*tool.Arguments) != "" {
73-
expr := strings.TrimSpace(*tool.Arguments)
72+
if tool.Condition != nil && strings.TrimSpace(*tool.Condition) != "" {
73+
expr := strings.TrimSpace(*tool.Condition)
7474
ast, issues := env.Compile(expr)
7575
if issues != nil && issues.Err() != nil {
76-
return nil, fmt.Errorf("failed to compile arguments CEL for tool %s/%s: %w", tool.Backend, tool.ToolName, issues.Err())
76+
return nil, fmt.Errorf("failed to compile condition CEL for tool %s/%s: %w", tool.Backend, tool.ToolName, issues.Err())
7777
}
7878
program, err := env.Program(ast, cel.CostLimit(10000), cel.EvalOptions(cel.OptOptimize))
7979
if err != nil {
80-
return nil, fmt.Errorf("failed to build arguments CEL program for tool %s/%s: %w", tool.Backend, tool.ToolName, err)
80+
return nil, fmt.Errorf("failed to build condition CEL program for tool %s/%s: %w", tool.Backend, tool.ToolName, err)
8181
}
8282
ct.Expression = expr
8383
ct.program = program
@@ -207,7 +207,7 @@ func (m *MCPProxy) toolMatches(backendName, toolName string, tools []compiledToo
207207

208208
result, _, err := t.program.Eval(map[string]any{"args": args})
209209
if err != nil {
210-
m.l.Error("failed to evaluate arguments CEL", slog.String("backend", t.Backend), slog.String("tool", t.ToolName), slog.String("error", err.Error()))
210+
m.l.Error("failed to evaluate condition CEL", slog.String("backend", t.Backend), slog.String("tool", t.ToolName), slog.String("error", err.Error()))
211211
continue
212212
}
213213

@@ -221,7 +221,7 @@ func (m *MCPProxy) toolMatches(backendName, toolName string, tools []compiledToo
221221
return true
222222
}
223223
default:
224-
m.l.Error("arguments CEL did not return a boolean", slog.String("backend", t.Backend), slog.String("tool", t.ToolName), slog.String("expression", t.Expression))
224+
m.l.Error("condition CEL did not return a boolean", slog.String("backend", t.Backend), slog.String("tool", t.ToolName), slog.String("expression", t.Expression))
225225
}
226226
}
227227
// If no matching tool entry or no arguments matched, fail.

internal/mcpproxy/authorization_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestAuthorizeRequest(t *testing.T) {
8080
Tools: []filterapi.ToolCall{{
8181
Backend: "backend1",
8282
ToolName: "tool1",
83-
Arguments: strPtr(`args.mode in ["fast", "slow"] && args.user.matches("u-[0-9]+") && args.debug == true`),
83+
Condition: strPtr(`args.mode in ["fast", "slow"] && args.user.matches("u-[0-9]+") && args.debug == true`),
8484
}},
8585
},
8686
},
@@ -111,7 +111,7 @@ func TestAuthorizeRequest(t *testing.T) {
111111
Tools: []filterapi.ToolCall{{
112112
Backend: "backend1",
113113
ToolName: "tool1",
114-
Arguments: strPtr(`int(args.count) >= 40 && int(args.count) < 50`),
114+
Condition: strPtr(`int(args.count) >= 40 && int(args.count) < 50`),
115115
}},
116116
},
117117
},
@@ -138,7 +138,7 @@ func TestAuthorizeRequest(t *testing.T) {
138138
Tools: []filterapi.ToolCall{{
139139
Backend: "backend1",
140140
ToolName: "tool1",
141-
Arguments: strPtr(`args["payload"] != null && args["payload"]["kind"] == "test" && args["payload"]["value"] == 123`),
141+
Condition: strPtr(`args["payload"] != null && args["payload"]["kind"] == "test" && args["payload"]["value"] == 123`),
142142
}},
143143
},
144144
},
@@ -192,7 +192,7 @@ func TestAuthorizeRequest(t *testing.T) {
192192
Tools: []filterapi.ToolCall{{
193193
Backend: "backend1",
194194
ToolName: "tool1",
195-
Arguments: strPtr(`args.mode in ["fast", "slow"]`),
195+
Condition: strPtr(`args.mode in ["fast", "slow"]`),
196196
}},
197197
},
198198
},
@@ -221,7 +221,7 @@ func TestAuthorizeRequest(t *testing.T) {
221221
Tools: []filterapi.ToolCall{{
222222
Backend: "backend1",
223223
ToolName: "tool1",
224-
Arguments: strPtr(`args.nonExistingField in ["fast", "slow"]`),
224+
Condition: strPtr(`args.nonExistingField in ["fast", "slow"]`),
225225
}},
226226
},
227227
},
@@ -250,7 +250,7 @@ func TestAuthorizeRequest(t *testing.T) {
250250
Tools: []filterapi.ToolCall{{
251251
Backend: "backend1",
252252
ToolName: "tool1",
253-
Arguments: strPtr(`args.mode`),
253+
Condition: strPtr(`args.mode`),
254254
}},
255255
},
256256
},
@@ -279,7 +279,7 @@ func TestAuthorizeRequest(t *testing.T) {
279279
Tools: []filterapi.ToolCall{{
280280
Backend: "backend1",
281281
ToolName: "tool1",
282-
Arguments: strPtr(`invalid syntax here`),
282+
Condition: strPtr(`invalid syntax here`),
283283
}},
284284
},
285285
},
@@ -309,7 +309,7 @@ func TestAuthorizeRequest(t *testing.T) {
309309
Tools: []filterapi.ToolCall{{
310310
Backend: "backend1",
311311
ToolName: "tool1",
312-
Arguments: strPtr(`args["mode"] == "fast"`),
312+
Condition: strPtr(`args["mode"] == "fast"`),
313313
}},
314314
},
315315
},
@@ -444,7 +444,7 @@ func TestAuthorizeRequest(t *testing.T) {
444444
Tools: []filterapi.ToolCall{{
445445
Backend: "backend1",
446446
ToolName: "listFiles",
447-
Arguments: strPtr(`args.folder == "restricted"`),
447+
Condition: strPtr(`args.folder == "restricted"`),
448448
}},
449449
},
450450
},
@@ -482,7 +482,7 @@ func TestAuthorizeRequest(t *testing.T) {
482482
Tools: []filterapi.ToolCall{{
483483
Backend: "backend1",
484484
ToolName: "listFiles",
485-
Arguments: strPtr(`args.folder == "restricted"`),
485+
Condition: strPtr(`args.folder == "restricted"`),
486486
}},
487487
},
488488
},
@@ -612,7 +612,7 @@ func TestCompileAuthorizationInvalidExpression(t *testing.T) {
612612
Tools: []filterapi.ToolCall{{
613613
Backend: "backend1",
614614
ToolName: "tool1",
615-
Arguments: strPtr("args."),
615+
Condition: strPtr("args."),
616616
}},
617617
},
618618
},

manifests/charts/ai-gateway-crds-helm/templates/aigateway.envoyproxy.io_mcproutes.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,17 +651,17 @@ spec:
651651
description: ToolCall represents a tool call in
652652
the MCP authorization target.
653653
properties:
654-
arguments:
654+
backend:
655+
description: Backend is the name of the backend
656+
this tool belongs to.
657+
type: string
658+
condition:
655659
description: |-
656-
Arguments is a CEL expression that must evaluate to true for the rule to match.
660+
Condition is a CEL expression that must evaluate to true for the rule to match.
657661
The expression is evaluated with a single variable "args" bound to the tool call arguments as a dynamic object.
658662
Guard against missing fields with null checks (e.g., args["foo"] != null && args["foo"]["bar"] == "val").
659663
maxLength: 4096
660664
type: string
661-
backend:
662-
description: Backend is the name of the backend
663-
this tool belongs to.
664-
type: string
665665
toolName:
666666
description: ToolName is the name of the tool.
667667
type: string

site/docs/api/api.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,10 +1988,10 @@ ToolCall represents a tool call in the MCP authorization target.
19881988
required="true"
19891989
description="ToolName is the name of the tool."
19901990
/><ApiField
1991-
name="arguments"
1991+
name="condition"
19921992
type="string"
19931993
required="false"
1994-
description="Arguments is a CEL expression that must evaluate to true for the rule to match.<br />The expression is evaluated with a single variable `args` bound to the tool call arguments as a dynamic object.<br />Guard against missing fields with null checks (e.g., args[`foo`] != null && args[`foo`][`bar`] == `val`)."
1994+
description="Condition is a CEL expression that must evaluate to true for the rule to match.<br />The expression is evaluated with a single variable `args` bound to the tool call arguments as a dynamic object.<br />Guard against missing fields with null checks (e.g., args[`foo`] != null && args[`foo`][`bar`] == `val`)."
19951995
/>
19961996

19971997

tests/e2e/testdata/mcp_route_authorization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ spec:
6868
tools:
6969
- backend: mcp-backend-authorization
7070
toolName: echo
71-
arguments: args.text.matches("^Hello, .*!$")
71+
condition: args.text.matches("^Hello, .*!$")
7272
- source:
7373
jwt:
7474
scopes:

0 commit comments

Comments
 (0)