mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
fix(tools): exempt MCP discovery tools from agent allowlists
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user