Skip to content

fix(mcp): fix silent column filter drop and bulk search sort error (AICHAT-1117)#229

Open
abhinavmathur-atlan wants to merge 2 commits into
mainfrom
abhinavmathur/aichat-1117
Open

fix(mcp): fix silent column filter drop and bulk search sort error (AICHAT-1117)#229
abhinavmathur-atlan wants to merge 2 commits into
mainfrom
abhinavmathur/aichat-1117

Conversation

@abhinavmathur-atlan
Copy link
Copy Markdown
Collaborator

Summary

Fixes two bugs reported in AICHAT-1117 where searching columns of a Databricks view via Atlan MCP returned wrong results or errored.

Bug 1 — __parentQualifiedName silently ignored → wrong columns returned

SearchUtils._get_asset_attribute("__parentQualifiedName") resolves to getattr(Asset, "__PARENTQUALIFIEDNAME", None)None. The condition was silently skipped (warning-only), so the search ran with zero filters and returned unrelated columns from across the tenant.

Fix: return an explicit error dict with actionable hints instead of silently continuing. For __parentQualifiedName specifically, the hint points the LLM to the correct fields: viewQualifiedName, tableQualifiedName, or qualifiedName with startsWith.

Bug 2 — sort_by=order triggers bulk search error (ATLAN-PYTHON-400-063)

Asset.ORDER is a valid pyatlan attribute (column ordinal), so sort was applied. When the Column result set is large, pyatlan switches to bulk/scroll mode which rejects user-defined sort orders. No guard existed between sort application and bulk-mode execution.

Fix: save pre-sort search state and catch the 400-063 exception at execution time, retrying without sort. Results are returned correctly; ordering is silently dropped. The docstring now also documents this limitation.

Files changed

  • modelcontextprotocol/tools/search.py — unknown-attr error with hints; bulk sort retry
  • modelcontextprotocol/server.py — docstring updates to guide LLM toward correct field names

Test plan

  • Search asset_type=Column with conditions: {viewQualifiedName: "<qn>"} — returns correct columns
  • Search asset_type=Column with conditions: {__parentQualifiedName: "<qn>"} — returns error with hint (not wrong columns)
  • Search asset_type=Column with sort_by=order on a large result set — returns results without error (sort silently dropped)
  • Search with valid sort_by on a small result set — sort still applied normally

Closes AICHAT-1117

🤖 Generated with Claude Code

…ICHAT-1117)

Two bugs when searching columns via MCP:

1. Unknown condition attributes (e.g. __parentQualifiedName) were silently
   dropped with a warning, causing the search to run with no filters and return
   unrelated columns. Now returns an explicit error with hints — for the
   __parentQualifiedName case, points the LLM to viewQualifiedName /
   tableQualifiedName / qualifiedName startsWith.

2. LLM-added sort_by (e.g. sort_by=order) succeeded attribute lookup but was
   rejected at execution time when pyatlan switched to bulk search mode
   (ATLAN-PYTHON-400-063). Now catches the bulk search exception and retries
   transparently without sort so results are still returned.

Also updates search_assets_tool docstring to guide the LLM toward correct
field names for column parent filtering and to document the sort_by limitation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hint

_get_asset_attribute previously did a raw .upper() on the input, so camelCase
names like 'viewQualifiedName' resolved to 'VIEWQUALIFIEDNAME' instead of
'VIEW_QUALIFIED_NAME', silently returning None for valid fields.

Now strips leading ES-internal underscores (__parentQualifiedName ->
parentQualifiedName) and converts camelCase to UPPER_SNAKE_CASE before the
getattr lookup, so both 'qualified_name' and 'qualifiedName' resolve correctly.

Also corrects the __parentQualifiedName error hint to recommend the actually-
working approach: 'qualified_name' with operator 'startsWith' and value
'<parent_qn>/' — which reliably resolves via Asset.QUALIFIED_NAME on base Asset,
unlike viewQualifiedName which is defined on Column not Asset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant