@@ -34,7 +34,7 @@ type compiledAuthorizationRule struct {
3434
3535type compiledToolCall struct {
3636 Backend string
37- ToolName string
37+ Tool string
3838 Expression string
3939 program cel.Program
4040}
@@ -66,18 +66,18 @@ func compileAuthorization(auth *filterapi.MCPRouteAuthorization) (*compiledAutho
6666 if rule .Target != nil {
6767 for _ , tool := range rule .Target .Tools {
6868 ct := compiledToolCall {
69- Backend : tool .Backend ,
70- ToolName : tool .ToolName ,
69+ Backend : tool .Backend ,
70+ Tool : tool .Tool ,
7171 }
7272 if tool .Condition != nil && strings .TrimSpace (* tool .Condition ) != "" {
7373 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 condition 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 .Tool , 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 condition 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 .Tool , err )
8181 }
8282 ct .Expression = expr
8383 ct .program = program
@@ -92,7 +92,7 @@ func compileAuthorization(auth *filterapi.MCPRouteAuthorization) (*compiledAutho
9292}
9393
9494// authorizeRequest authorizes the request based on the given MCPRouteAuthorization configuration.
95- func (m * MCPProxy ) authorizeRequest (authorization * compiledAuthorization , headers http.Header , backendName , toolName string , arguments any ) (bool , []string ) {
95+ func (m * MCPProxy ) authorizeRequest (authorization * compiledAuthorization , headers http.Header , backend , tool string , arguments any ) (bool , []string ) {
9696 if authorization == nil {
9797 return true , nil
9898 }
@@ -124,7 +124,7 @@ func (m *MCPProxy) authorizeRequest(authorization *compiledAuthorization, header
124124 for _ , rule := range authorization .Rules {
125125 action := rule .Action == filterapi .AuthorizationActionAllow
126126
127- if ! m .toolMatches (backendName , toolName , rule .Target , arguments ) {
127+ if ! m .toolMatches (backend , tool , rule .Target , arguments ) {
128128 continue
129129 }
130130
@@ -191,14 +191,14 @@ func extractScopes(claims jwt.MapClaims) []string {
191191 }
192192}
193193
194- func (m * MCPProxy ) toolMatches (backendName , toolName string , tools []compiledToolCall , args any ) bool {
194+ func (m * MCPProxy ) toolMatches (backend , tool string , tools []compiledToolCall , args any ) bool {
195195 // Empty tools means all tools match.
196196 if len (tools ) == 0 {
197197 return true
198198 }
199199
200200 for _ , t := range tools {
201- if t .Backend != backendName || t .ToolName != toolName {
201+ if t .Backend != backend || t .Tool != tool {
202202 continue
203203 }
204204 if t .program == nil {
@@ -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 condition 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 .Tool ), 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 ("condition 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 .Tool ), slog .String ("expression" , t .Expression ))
225225 }
226226 }
227227 // If no matching tool entry or no arguments matched, fail.
0 commit comments