Skip to content

Commit df3e9e3

Browse files
committed
updated, addressed comments
1 parent 60edf1c commit df3e9e3

File tree

3 files changed

+8
-78
lines changed

3 files changed

+8
-78
lines changed

modelcontextprotocol/server.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,7 @@ def query_asset_tool(
720720

721721
@mcp.tool()
722722
def get_asset_history_tool(
723-
guid=None,
724-
qualified_name=None,
725-
type_name=None,
726-
size=10,
727-
sort_order="DESC",
728-
include_attributes=None,
723+
guid=None, qualified_name=None, type_name=None, size=10, sort_order="DESC"
729724
):
730725
"""
731726
Get the audit history of an asset by GUID or qualified name.
@@ -740,8 +735,6 @@ def get_asset_history_tool(
740735
size (int): Number of history entries to return. Defaults to 10.
741736
sort_order (str): Sort order for results. "ASC" for oldest first, "DESC" for newest first.
742737
Defaults to "DESC".
743-
include_attributes (List[Union[str, AtlanField]], optional): List of additional attributes to include in results.
744-
Can be string attribute names or AtlanField objects. These will be added to the default set.
745738
746739
Returns:
747740
Dict[str, Any]: Dictionary containing:
@@ -756,7 +749,6 @@ def get_asset_history_tool(
756749
guid="6fc01478-1263-42ae-b8ca-c4a57da51392",
757750
size=20,
758751
sort_order="DESC",
759-
include_attributes=["owner_users", "description"]
760752
)
761753
762754
# Get history by qualified name
@@ -773,7 +765,6 @@ def get_asset_history_tool(
773765
type_name=type_name,
774766
size=size,
775767
sort_order=sort_order,
776-
include_attributes=include_attributes,
777768
)
778769

779770

modelcontextprotocol/tools/assets.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
)
1111
from pyatlan.model.assets import Readme, AtlasGlossaryTerm
1212
from pyatlan.model.fluent_search import CompoundQuery, FluentSearch
13-
from pyatlan.model.fields.atlan_fields import AtlanField
1413
from utils.asset_history import (
1514
validate_asset_history_params,
1615
create_audit_search_request,
1716
process_audit_result,
1817
create_sort_item,
19-
convert_attributes_to_camel_case,
2018
)
2119

2220
# Initialize logging
@@ -200,7 +198,6 @@ def get_asset_history(
200198
type_name: Optional[str] = None,
201199
size: int = 10,
202200
sort_order: str = "DESC",
203-
include_attributes: Optional[List[Union[str, AtlanField]]] = None,
204201
) -> Dict[str, Any]:
205202
"""
206203
Get the audit history of an asset by GUID or qualified name.
@@ -215,8 +212,6 @@ def get_asset_history(
215212
size (int): Number of history entries to return. Defaults to 10.
216213
sort_order (str): Sort order for results. "ASC" for oldest first, "DESC" for newest first.
217214
Defaults to "DESC".
218-
include_attributes (List[Union[str, AtlanField]], optional): List of additional attributes to include in results.
219-
Can be string attribute names or AtlanField objects. These will be added to the default set.
220215
221216
Returns:
222217
Dict[str, Any]: Dictionary containing:
@@ -252,20 +247,15 @@ def get_asset_history(
252247
# Create sort item
253248
sort_item = create_sort_item(sort_order)
254249

255-
# Convert include_attributes from snake_case to camelCase if needed
256-
if include_attributes:
257-
include_attributes = convert_attributes_to_camel_case(include_attributes)
258-
259250
# Create and execute audit search request
260251
request = create_audit_search_request(
261-
guid, qualified_name, type_name, size, sort_item, include_attributes
252+
guid, qualified_name, type_name, size, sort_item
262253
)
263254
response = client.audit.search(criteria=request, bulk=False)
264255

265256
# Process audit results - use current_page() to respect size parameter
266257
entity_audits = [
267-
process_audit_result(result, include_attributes)
268-
for result in response.current_page()
258+
process_audit_result(result) for result in response.current_page()
269259
]
270260

271261
result_data = {

modelcontextprotocol/utils/asset_history.py

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,15 @@
55
"""
66

77
import logging
8-
from typing import List, Union, Dict, Any, Optional
8+
from typing import Dict, Any, Optional
99
from pyatlan.client.audit import AuditSearchRequest
1010
from pyatlan.model.search import DSL, Bool, SortItem, Term
1111
from pyatlan.model.enums import SortOrder
12-
from pyatlan.model.fields.atlan_fields import AtlanField
1312

1413
# Initialize logging
1514
logger = logging.getLogger(__name__)
1615

1716

18-
def snake_to_camel(s: str) -> str:
19-
"""
20-
Convert a snake_case string to camelCase.
21-
22-
Args:
23-
s (str): The snake_case string.
24-
25-
Returns:
26-
str: The camelCase string.
27-
"""
28-
parts = s.split("_")
29-
return (
30-
parts[0] + "".join(word.capitalize() for word in parts[1:])
31-
if len(parts) > 1
32-
else s
33-
)
34-
35-
3617
def validate_asset_history_params(
3718
guid: Optional[str],
3819
qualified_name: Optional[str],
@@ -69,7 +50,6 @@ def create_audit_search_request(
6950
type_name: Optional[str],
7051
size: int,
7152
sort_item: SortItem,
72-
include_attributes: Optional[List[Union[str, AtlanField]]],
7353
) -> AuditSearchRequest:
7454
"""
7555
Create an AuditSearchRequest based on the provided parameters.
@@ -80,7 +60,6 @@ def create_audit_search_request(
8060
type_name: Asset type name
8161
size: Number of results to return
8262
sort_item: Sort configuration
83-
include_attributes: Attributes to include in results
8463
8564
Returns:
8665
Configured AuditSearchRequest
@@ -107,11 +86,7 @@ def create_audit_search_request(
10786
f"Created audit search request by qualified name: {qualified_name}"
10887
)
10988

110-
# Only pass attributes if they are provided
111-
if include_attributes:
112-
return AuditSearchRequest(dsl=dsl, attributes=include_attributes)
113-
else:
114-
return AuditSearchRequest(dsl=dsl)
89+
return AuditSearchRequest(dsl=dsl)
11590

11691

11792
def extract_basic_audit_info(result) -> Dict[str, Any]:
@@ -135,29 +110,21 @@ def extract_basic_audit_info(result) -> Dict[str, Any]:
135110
}
136111

137112

138-
def process_audit_result(
139-
result, include_attributes: Optional[List[Union[str, AtlanField]]]
140-
) -> Dict[str, Any]:
113+
def process_audit_result(result) -> Dict[str, Any]:
141114
"""
142115
Process a single audit result into a formatted dictionary.
143116
144117
Args:
145118
result: Audit result object
146-
include_attributes: List of attributes to include
147119
148120
Returns:
149121
Formatted audit entry dictionary
150122
"""
151123
try:
152124
# Extract basic audit information
153125
audit_entry = extract_basic_audit_info(result)
154-
155-
# Add requested attributes if specified
156-
if include_attributes:
157-
requested_attrs = result.detail.attributes.dict(
158-
exclude_unset=True, by_alias=True
159-
)
160-
audit_entry.update(requested_attrs)
126+
updates = result.detail.dict(exclude_unset=True)
127+
audit_entry.update(updates)
161128

162129
return audit_entry
163130

@@ -184,21 +151,3 @@ def create_sort_item(sort_order: str) -> SortItem:
184151
"created",
185152
order=SortOrder.DESCENDING if sort_order == "DESC" else SortOrder.ASCENDING,
186153
)
187-
188-
189-
def convert_attributes_to_camel_case(
190-
include_attributes: List[Union[str, AtlanField]],
191-
) -> List[Union[str, AtlanField]]:
192-
"""
193-
Convert string attributes from snake_case to camelCase.
194-
195-
Args:
196-
include_attributes: List of attributes to convert
197-
198-
Returns:
199-
List with string attributes converted to camelCase
200-
"""
201-
return [
202-
snake_to_camel(attr) if isinstance(attr, str) else attr
203-
for attr in include_attributes
204-
]

0 commit comments

Comments
 (0)