feat: a tool that takes its search term as q also takes it as query
CI & Build / TypeScript typecheck (push) Successful in 14s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 20s
CI & Build / Python tests (push) Successful in 1m58s
CI & Build / integration (push) Successful in 2m45s
CI & Build / Build & push image (push) Successful in 44s

query was the most common misnamed argument in the live logs, and on a
tool that declares q it cannot mean anything else. Passing both is still
refused by the unknown-argument check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-06 00:21:20 -05:00
co-authored by Claude Opus 5.5
parent 58991038d8
commit 9cfa07a884
2 changed files with 56 additions and 0 deletions
+38
View File
@@ -44,6 +44,44 @@ async def test_unknown_argument_is_an_error_not_a_silent_drop():
assert "Nothing was created or changed" in msg
def _query_server() -> StrictArgsMCPServer:
mcp = StrictArgsMCPServer("alias-test")
@mcp.tool()
def find(q: str = "") -> str:
return f"found:{q}"
@mcp.tool()
def own(query: str = "") -> str:
return f"own:{query}"
return mcp
async def test_query_is_taken_as_q_by_a_tool_that_declares_q():
mcp = _query_server()
assert "found:backups" in str(await mcp.call_tool("find", {"query": "backups"}))
# A tool that declares `query` itself keeps it.
assert "own:backups" in str(await mcp.call_tool("own", {"query": "backups"}))
async def test_query_beside_q_is_still_refused():
mcp = _query_server()
with pytest.raises(ToolError) as exc:
await mcp.call_tool("find", {"q": "a", "query": "b"})
assert "'query'" in str(exc.value)
async def test_the_real_search_tool_takes_query():
"""Against the REAL server: search declares `q`, so `query` is renamed
before the unknown-argument check rather than refused by it."""
from grimoire.mcp.server import _with_aliases, build_mcp_server
tool = build_mcp_server()._tool_manager.get_tool("search")
declared = set(tool.parameters["properties"])
assert _with_aliases({"query": "x"}, declared) == {"q": "x"}
async def test_empty_arguments_pass():
mcp = _echo_server()
assert await mcp.call_tool("echo", {}) is not None