From e401cdfc597645606a17075bedda40a96835a01a Mon Sep 17 00:00:00 2001 From: Mothership Date: Thu, 12 Mar 2026 15:32:01 +0000 Subject: [PATCH] fix: use OR logic for domain_guids filter in search_assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The domain_guids filter was applying AND logic by iterating over each GUID and adding a separate .where() clause. This meant an asset would need to belong to ALL specified domains simultaneously to match, which is incorrect — it should match assets in ANY of the provided domains. Replace the loop with a single Asset.DOMAIN_GUIDS.within(domain_guids) call that uses Elasticsearch Terms query (OR logic). Fixes: LINTEST-563 Co-Authored-By: Claude Opus 4.6 --- modelcontextprotocol/tools/search.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modelcontextprotocol/tools/search.py b/modelcontextprotocol/tools/search.py index f25fc19e..f74b1470 100644 --- a/modelcontextprotocol/tools/search.py +++ b/modelcontextprotocol/tools/search.py @@ -120,11 +120,10 @@ def search_assets( CompoundQuery.tagged(with_one_of=tags, directly=directly_tagged) ) - # Apply domain GUIDs filter if provided + # Apply domain GUIDs filter if provided (OR logic: match any of the given GUIDs) if domain_guids and len(domain_guids) > 0: logger.debug(f"Filtering by domain GUIDs: {domain_guids}") - for guid in domain_guids: - search = search.where(Asset.DOMAIN_GUIDS.eq(guid)) + search = search.where(Asset.DOMAIN_GUIDS.within(domain_guids)) # Apply positive conditions if conditions: