fix(tools): exempt MCP discovery tools from agent allowlists

This commit is contained in:
afjcjsbx
2026-05-08 09:18:14 +02:00
parent b8f4257cee
commit 871892ff15
3 changed files with 39 additions and 2 deletions
+13 -2
View File
@@ -14,6 +14,8 @@ import (
const (
MaxRegexPatternLength = 200
RegexSearchToolName = "tool_search_tool_regex"
BM25SearchToolName = "tool_search_tool_bm25"
)
type RegexSearchTool struct {
@@ -27,7 +29,7 @@ func NewRegexSearchTool(r *ToolRegistry, ttl int, maxSearchResults int) *RegexSe
}
func (t *RegexSearchTool) Name() string {
return "tool_search_tool_regex"
return RegexSearchToolName
}
func (t *RegexSearchTool) Description() string {
@@ -96,7 +98,7 @@ func NewBM25SearchTool(r *ToolRegistry, ttl int, maxSearchResults int) *BM25Sear
}
func (t *BM25SearchTool) Name() string {
return "tool_search_tool_bm25"
return BM25SearchToolName
}
func (t *BM25SearchTool) Description() string {
@@ -294,6 +296,15 @@ func (t *BM25SearchTool) getOrBuildEngine() *bm25CachedEngine {
return cached
}
func isToolDiscoveryToolName(name string) bool {
switch strings.ToLower(strings.TrimSpace(name)) {
case BM25SearchToolName, RegexSearchToolName:
return true
default:
return false
}
}
// SearchBM25 ranks hidden tools against query using BM25 via utils.BM25Engine.
// This non-cached variant rebuilds the engine on every call. Used by tests
// and any code that doesn't hold a BM25SearchTool instance.