Skip to content

Commit 022fef5

Browse files
committed
parent d122674
author Bala <[email protected]> 1757908811 +0530 committer Bala <[email protected]> 1758000441 +0530 Add support to update_Assets_tool with update classifications update Args instructions remove unused imports updated review comments Reverted all changes to uv lock
1 parent d122674 commit 022fef5

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

modelcontextprotocol/server.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,13 @@ def update_assets_tool(
478478
assets (Union[Dict[str, Any], List[Dict[str, Any]]]): Asset(s) to update.
479479
Can be a single UpdatableAsset or a list of UpdatableAsset objects.
480480
attribute_name (str): Name of the attribute to update.
481-
Supports "user_description", "certificate_status", "readme", and "term".
481+
Supports "user_description", "certificate_status", "readme", "classifications" and "term".
482482
attribute_values (List[Union[str, Dict[str, Any]]]): List of values to set for the attribute.
483483
For certificateStatus, only "VERIFIED", "DRAFT", or "DEPRECATED" are allowed.
484484
For readme, the value must be a valid Markdown string.
485485
For term, the value must be a dict with "operation" and "term_guids" keys.
486+
For classifications, the value must already exist in Atlan.
487+
486488
487489
Returns:
488490
Dict[str, Any]: Dictionary containing:
@@ -502,6 +504,17 @@ def update_assets_tool(
502504
attribute_name="certificate_status",
503505
attribute_values=["VERIFIED"]
504506
)
507+
# Update classification for a single asset
508+
result = update_assets_tool(
509+
assets={
510+
"guid": "asset-guid-here",
511+
"name": "Asset Name",
512+
"type_name": "Asset Type Name",
513+
"qualified_name": "Asset Qualified Name"
514+
},
515+
attribute_name="classifications",
516+
attribute_values=["P0"]
517+
)
505518
506519
# Update user description for multiple assets
507520
result = update_assets_tool(
@@ -602,6 +615,7 @@ def update_assets_tool(
602615
)
603616
"""
604617
try:
618+
605619
# Parse JSON parameters
606620
parsed_assets = parse_json_parameter(assets)
607621
parsed_attribute_values = parse_list_parameter(attribute_values)

modelcontextprotocol/tools/assets.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def update_assets(
2727
updatable_assets (Union[UpdatableAsset, List[UpdatableAsset]]): Asset(s) to update.
2828
Can be a single UpdatableAsset or a list of UpdatableAssets.
2929
attribute_name (UpdatableAttribute): Name of the attribute to update.
30-
Supports userDescription, certificateStatus, readme, and term.
30+
Supports userDescription, certificateStatus, readme, classifications and term.
3131
attribute_values (List[Union[str, CertificateStatus, TermOperations]]): List of values to set for the attribute.
3232
For certificateStatus, only VERIFIED, DRAFT, or DEPRECATED are allowed.
3333
For readme, the value must be a valid Markdown string.
@@ -155,6 +155,21 @@ def update_assets(
155155
error_msg = f"Error updating terms on asset {updatable_asset.qualified_name}: {str(e)}"
156156
logger.error(error_msg)
157157
result["errors"].append(error_msg)
158+
elif attribute_name == UpdatableAttribute.CLASSIFICATIONS:
159+
tag_names = attribute_values[index] if isinstance(attribute_values[index], list) else [
160+
attribute_values[index]]
161+
162+
try:
163+
client.asset.add_atlan_tags(
164+
asset_type=asset_cls,
165+
qualified_name=asset.qualified_name,
166+
atlan_tag_names=tag_names,
167+
)
168+
result["updated_count"] += 1
169+
except Exception as e:
170+
error_msg = f"Error updating tags on asset {updatable_asset.qualified_name}: {str(e)}"
171+
logger.error(error_msg)
172+
result["errors"].append(error_msg)
158173
else:
159174
# Regular attribute update flow
160175
setattr(asset, attribute_name.value, attribute_values[index])
@@ -172,7 +187,6 @@ def update_assets(
172187
f"Successfully updated {result['readme_updated']} readme assets: {result['updated_readme_assets']}"
173188
)
174189

175-
# Proces response
176190
if len(assets) > 0:
177191
response = client.asset.save(assets)
178192
result["updated_count"] = len(response.guid_assignments)

modelcontextprotocol/tools/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class UpdatableAttribute(str, Enum):
1919
CERTIFICATE_STATUS = "certificate_status"
2020
README = "readme"
2121
TERM = "term"
22+
CLASSIFICATIONS ="classifications"
23+
2224

2325

2426
class TermOperation(str, Enum):
@@ -45,6 +47,7 @@ class UpdatableAsset(BaseModel):
4547
type_name: str
4648
user_description: Optional[str] = None
4749
certificate_status: Optional[CertificateStatus] = None
50+
classifications: Optional[List[str]] = None
4851

4952

5053
class Glossary(BaseModel):

modelcontextprotocol/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)