Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions modelcontextprotocol/tools/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@ def update_assets(
f"Successfully updated {result['readme_updated']} readme assets: {result['updated_readme_assets']}"
)

# Proces response
# Process response
if len(assets) > 0:
response = client.asset.save(assets)
result["updated_count"] = len(response.guid_assignments)
logger.info(f"Successfully updated {result['updated_count']} assets")

return result
# Apply TOON formatting for token optimization
from utils.formatting import format_update_results

return format_update_results(result)

except Exception as e:
error_msg = f"Error updating assets: {str(e)}"
Expand Down
4 changes: 3 additions & 1 deletion modelcontextprotocol/tools/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def get_assets_by_dsl(dsl_query: Union[str, Dict[str, Any]]) -> Dict[str, Any]:
logger.info("Executing DSL search request")
client = get_atlan_client()
search_response = client.asset.search(index_request)
processed_results = SearchUtils.process_results(search_response)

# Process results with TOON formatting enabled by default
processed_results = SearchUtils.process_results(search_response, use_toon=True)
return processed_results
except Exception as e:
logger.error(f"Error in DSL search: {str(e)}")
Expand Down
8 changes: 7 additions & 1 deletion modelcontextprotocol/tools/lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ def traverse_lineage(
logger.info(
f"Lineage traversal completed, returned {len(results_list)} results"
)
return {"assets": results_list, "error": None}

lineage_results = {"assets": results_list, "error": None}

# Apply TOON formatting for token optimization
from utils.formatting import format_lineage_results

return format_lineage_results(lineage_results)

except Exception as e:
logger.error(f"Error traversing lineage: {str(e)}")
Expand Down
18 changes: 14 additions & 4 deletions modelcontextprotocol/tools/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,20 @@ def search_assets(
logger.info("Executing search request")
client = get_atlan_client()
search_response = client.asset.search(request)
processed_results = SearchUtils.process_results(search_response)
logger.info(
f"Search completed, returned {len(processed_results['results'])} results"
)

# Process results with TOON formatting enabled by default
processed_results = SearchUtils.process_results(search_response, use_toon=True)

# Log result count (handle both TOON string and dict formats)
if isinstance(processed_results, str):
logger.info(
"Search completed, results formatted as TOON for token optimization"
)
else:
logger.info(
f"Search completed, returned {len(processed_results.get('results', []))} results"
)

return processed_results

except Exception as e:
Expand Down
25 changes: 25 additions & 0 deletions modelcontextprotocol/toon_config_example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TOON Optimization Configuration Example
# Copy this to .env and adjust values as needed

# Enable/disable TOON formatting globally
TOON_ENABLED=true

# Minimum token savings percentage to use TOON (default: 5.0)
TOON_MIN_SAVINGS=5.0

# Enable TOON for specific data types
TOON_SEARCH_RESULTS=true
TOON_LINEAGE_RESULTS=true
TOON_DSL_QUERIES=false # Complex nested structures often don't compress well
TOON_UPDATE_RESULTS=true
TOON_ASSET_LISTS=true

# TOON Encoding Options
# Delimiter: comma, tab, or pipe
TOON_DELIMITER=comma

# Indentation spaces (default: 2)
TOON_INDENT=2

# Length marker prefix (empty to disable, "#" to enable)
TOON_LENGTH_MARKER=
Loading