Skip to main content
Glama

encode_point_icon

Set node icon encoding for graphs by mapping node data to specific icons or text, enabling clear visual differentiation based on categorical or continuous values in Graphistry visualizations.

Instructions

Set node icon encoding for a graph using Graphistry's encode_point_icon API. Args: graph_id (str): The ID of the graph to modify. column (str): The node column to use for icon encoding (e.g., 'type', 'origin'). categorical_mapping (dict, optional): Map of category values to icon names or URLs. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}. See FontAwesome 4 or ISO country codes for built-ins. default_mapping (str, optional): Icon to use for values not in categorical_mapping. Example: 'question'. as_text (bool, optional): If True, use text as the icon (for continuous binning or direct text display). continuous_binning (list, optional): List of [threshold, icon] pairs for binning continuous values. Example: [[33, 'low'], [66, 'mid'], [None, 'high']]. Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: encode_point_icon(graph_id, column='type', categorical_mapping={'macbook': 'laptop', 'Canada': 'flag-icon-ca'}, default_mapping='question')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
as_textNo
categorical_mappingNo
columnYes
continuous_binningNo
default_mappingNo
graph_idYes

Implementation Reference

  • The main handler function for the 'encode_point_icon' tool. It is registered via the @mcp.tool() decorator, uses type annotations and docstring for schema, and implements the logic to encode node icons on a Graphistry graph object based on a specified column and mappings.
    @mcp.tool() async def encode_point_icon( graph_id: str, column: str, categorical_mapping: Optional[dict] = None, default_mapping: Optional[str] = None, as_text: Optional[bool] = False, continuous_binning: Optional[list] = None ) -> Dict[str, Any]: """ Set node icon encoding for a graph using Graphistry's encode_point_icon API. Args: graph_id (str): The ID of the graph to modify. column (str): The node column to use for icon encoding (e.g., 'type', 'origin'). categorical_mapping (dict, optional): Map of category values to icon names or URLs. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}. See FontAwesome 4 or ISO country codes for built-ins. default_mapping (str, optional): Icon to use for values not in categorical_mapping. Example: 'question'. as_text (bool, optional): If True, use text as the icon (for continuous binning or direct text display). continuous_binning (list, optional): List of [threshold, icon] pairs for binning continuous values. Example: [[33, 'low'], [66, 'mid'], [None, 'high']]. Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: encode_point_icon(graph_id, column='type', categorical_mapping={'macbook': 'laptop', 'Canada': 'flag-icon-ca'}, default_mapping='question') """ if graph_id not in graph_cache: raise ValueError(f"Graph not found: {graph_id}") g = graph_cache[graph_id]["graph"] kwargs = {"column": column} if categorical_mapping: kwargs["categorical_mapping"] = categorical_mapping if default_mapping: kwargs["default_mapping"] = default_mapping if as_text: kwargs["as_text"] = as_text if continuous_binning: kwargs["continuous_binning"] = continuous_binning g = g.encode_point_icon(**kwargs) graph_cache[graph_id]["graph"] = g return {"graph_id": graph_id, "url": g.plot(render=False)}
  • The @mcp.tool() decorator registers the encode_point_icon function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/graphistry/graphistry-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server