matchToolPattern checks if a tool name matches a glob-like pattern. Supports * as wildcard (e.g., "mcp_*", "@coder", "*").
(pattern, toolName string)
| 272 | // matchToolPattern checks if a tool name matches a glob-like pattern. |
| 273 | // Supports * as wildcard (e.g., "mcp_*", "@coder", "*"). |
| 274 | func matchToolPattern(pattern, toolName string) bool { |
| 275 | if pattern == "*" { |
| 276 | return true |
| 277 | } |
| 278 | |
| 279 | // Simple prefix match for "prefix*" patterns |
| 280 | if strings.HasSuffix(pattern, "*") { |
| 281 | prefix := strings.TrimSuffix(pattern, "*") |
| 282 | return strings.HasPrefix(toolName, prefix) |
| 283 | } |
| 284 | |
| 285 | // Exact match |
| 286 | return strings.EqualFold(pattern, toolName) |
| 287 | } |
no outgoing calls