mirror of
https://github.com/usestrix/strix.git
synced 2026-10-12 03:47:56 +00:00
fix(mcp): limit active tool fallback
This commit is contained in:
parent
5126f51f5f
commit
009d8ce116
2 changed files with 6 additions and 2 deletions
|
|
@ -138,7 +138,7 @@ def _search_score(tool: MCPTool, query_terms: list[str], active: bool) -> tuple[
|
|||
elif term in description:
|
||||
score += 10
|
||||
matched_terms += 1
|
||||
if matched_terms == 0 and not active:
|
||||
if matched_terms == 0:
|
||||
return (-1, name)
|
||||
return (score + (matched_terms * 5), name)
|
||||
|
||||
|
|
@ -178,6 +178,10 @@ async def search_mcp_tools(
|
|||
for tool in tools
|
||||
if (score := _search_score(tool, terms, tool.name in entry.active_tools))[0] >= 0
|
||||
]
|
||||
if not ranked:
|
||||
ranked = [
|
||||
((100, tool.name.lower()), tool) for tool in tools if tool.name in entry.active_tools
|
||||
]
|
||||
ranked.sort(key=lambda item: (-item[0][0], item[0][1]))
|
||||
return {
|
||||
"connection": connection,
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ async def test_search_matches_any_query_term_and_prioritizes_active_tools() -> N
|
|||
[
|
||||
MCPTool(
|
||||
name="fetch_page",
|
||||
description="Fetch page content",
|
||||
description="Read page content",
|
||||
inputSchema={"type": "object"},
|
||||
),
|
||||
MCPTool(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue