Skip to content

Commit 44ecec2

Browse files
jagadeeswara-ksphernandez
authored andcommitted
test(mcp): assert tags param and tag: shorthand comma equivalence
Integration regression test for #910: the tags= parameter and the tag:alpha,beta query shorthand must return the same results for the same comma string. Cherry-picked from #918. The validator swap itself (coerce_list -> parse_tags) landed separately via #932; this carries the remaining test-only piece with original authorship. Signed-off-by: K Jagadeeswara Reddy <social@jagadeeswar.com>
1 parent 49041a5 commit 44ecec2

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

test-int/mcp/test_search_integration.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,55 @@ async def test_search_case_insensitive(mcp_server, app, test_project):
497497

498498
result_text = search_result.content[0].text
499499
assert "Machine Learning Guide" in result_text, f"Failed for search term: {search_term}"
500+
501+
502+
@pytest.mark.asyncio
503+
async def test_tags_param_vs_tag_query_comma_consistency(mcp_server, app, test_project):
504+
"""The `tags=` parameter must split comma-separated strings like the `tag:` shorthand.
505+
506+
Regression test for #910: `search_notes(tags="alpha,beta")` previously coerced the
507+
bare string into the single literal tag `["alpha,beta"]` (matching nothing), while
508+
the `tag:alpha,beta` query shorthand splits on commas. Both paths must agree.
509+
"""
510+
511+
async with Client(mcp_server) as client:
512+
# Note tagged alpha + beta
513+
await client.call_tool(
514+
"write_note",
515+
{
516+
"project": test_project.name,
517+
"title": "Tag Shorthand Note",
518+
"directory": "tag-shorthand",
519+
"content": "# Tag Shorthand Note\n\nTagShorthandToken body",
520+
"tags": ["alpha", "beta"],
521+
},
522+
)
523+
524+
# Path A: tag: query shorthand with comma list -> splits, matches
525+
via_query = await client.call_tool(
526+
"search_notes",
527+
{
528+
"project": test_project.name,
529+
"query": "tag:alpha,beta",
530+
"search_type": "text",
531+
},
532+
)
533+
query_hit = "Tag Shorthand Note" in via_query.content[0].text
534+
535+
# Path B: tags= parameter with the SAME comma string
536+
via_param = await client.call_tool(
537+
"search_notes",
538+
{
539+
"project": test_project.name,
540+
"query": "TagShorthandToken",
541+
"search_type": "text",
542+
"tags": "alpha,beta",
543+
},
544+
)
545+
param_hit = "Tag Shorthand Note" in via_param.content[0].text
546+
547+
assert query_hit, "tag: query shorthand should match (sanity)"
548+
assert param_hit == query_hit, (
549+
"tags='alpha,beta' param must behave like the tag: shorthand "
550+
f"(both split commas). query_hit={query_hit} param_hit={param_hit}"
551+
)

0 commit comments

Comments
 (0)