From a835b1bc03476012f0c49e774eb3c30c77ad01e0 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 16 Apr 2026 15:48:51 -0700 Subject: [PATCH] fix(mcp): tag MCP-originated SQL queries with origin comment for observability Prepend `/* atlan-mcp */` to all SQL queries executed via `query_asset` so they are identifiable in Heka's `db.statement` OTEL field. Without this tag, MCP queries are indistinguishable from UI-initiated queries in downstream log analysis. `QueryRequest` has no `application` or source field, making a SQL block comment the only portable origin tag that survives to the execution log without pyatlan SDK changes. Co-Authored-By: Claude Sonnet 4.6 --- modelcontextprotocol/tools/query.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modelcontextprotocol/tools/query.py b/modelcontextprotocol/tools/query.py index 951c9cdc..0322f02a 100644 --- a/modelcontextprotocol/tools/query.py +++ b/modelcontextprotocol/tools/query.py @@ -80,9 +80,14 @@ def query_asset( client = get_atlan_client() # Build query request + # Prepend an MCP origin comment so queries are identifiable in + # downstream observability logs (e.g. Heka's db.statement OTEL field). + # QueryRequest has no application/source field, so a SQL comment is + # the only portable way to tag origin without SDK changes. logger.debug("Building QueryRequest object") + tagged_sql = f"/* atlan-mcp */ {sql.strip()}" query_request = QueryRequest( - sql=sql, + sql=tagged_sql, data_source_name=connection_qualified_name, default_schema=default_schema, )