Skip to main content
Glama

encode_point_badge

Set visual badges on graph nodes to highlight categories or values using column data, improving data interpretation in Graphistry visualizations.

Instructions

Set node badge encoding for a graph using Graphistry's encode_point_badge API.

Args:
    graph_id (str): The ID of the graph to modify.
    column (str): The node column to use for badge encoding (e.g., 'type', 'origin').
    position (str, optional): Badge position on the node. Example: 'TopRight', 'BottomLeft', etc.
    categorical_mapping (dict, optional): Map of category values to badge icons or images. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}.
    default_mapping (str, optional): Badge to use for values not in categorical_mapping. Example: 'question'.
    as_text (bool, optional): If True, use text as the badge (for continuous binning or direct text display).
    continuous_binning (list, optional): List of [threshold, badge] pairs for binning continuous values. Example: [[33, None], [66, 'info-circle'], [None, 'exclamation-triangle']].

Returns:
    dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.

Example:
    encode_point_badge(graph_id, column='type', position='TopRight', categorical_mapping={'macbook': 'laptop'}, default_mapping='question')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes
columnYes
positionNoTopRight
categorical_mappingNo
default_mappingNo
as_textNo
continuous_binningNo

Implementation Reference

  • The encode_point_badge tool handler: registers the tool via @mcp.tool(), defines input parameters with type hints and comprehensive docstring schema, and implements the logic by calling Graphistry's encode_point_badge method on the cached graph object.
    @mcp.tool()
    async def encode_point_badge(
        graph_id: str,
        column: str,
        position: str = "TopRight",
        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 badge encoding for a graph using Graphistry's encode_point_badge API.
    
        Args:
            graph_id (str): The ID of the graph to modify.
            column (str): The node column to use for badge encoding (e.g., 'type', 'origin').
            position (str, optional): Badge position on the node. Example: 'TopRight', 'BottomLeft', etc.
            categorical_mapping (dict, optional): Map of category values to badge icons or images. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}.
            default_mapping (str, optional): Badge to use for values not in categorical_mapping. Example: 'question'.
            as_text (bool, optional): If True, use text as the badge (for continuous binning or direct text display).
            continuous_binning (list, optional): List of [threshold, badge] pairs for binning continuous values. Example: [[33, None], [66, 'info-circle'], [None, 'exclamation-triangle']].
    
        Returns:
            dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
    
        Example:
            encode_point_badge(graph_id, column='type', position='TopRight', categorical_mapping={'macbook': 'laptop'}, 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, "position": position}
        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_badge(**kwargs)
        graph_cache[graph_id]["graph"] = g
        return {"graph_id": graph_id, "url": g.plot(render=False)}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the action as modifying a graph and specifies the return format, but lacks details on permissions, side effects (e.g., whether changes are reversible), rate limits, or error handling. The description adds some context (e.g., 'updated visualization URL') but is incomplete for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, args, returns, example) and uses bullet-like formatting for parameters. However, it includes some redundancy (e.g., repeating 'Example' in the example section) and could be more front-loaded; the core purpose is stated first, but the parameter details are lengthy yet necessary given the low schema coverage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (7 parameters, mutation tool, no annotations, no output schema), the description is fairly complete. It explains all parameters thoroughly, provides an example, and specifies the return format. However, it lacks information on behavioral aspects like error conditions or integration with sibling tools, leaving some gaps in contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must fully compensate. It provides detailed explanations for all 7 parameters, including examples and optional/default behaviors (e.g., 'position' defaults to 'TopRight', 'categorical_mapping' maps categories to icons). This adds significant meaning beyond the basic schema, clarifying how each parameter influences badge encoding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Set node badge encoding for a graph') using the exact API name ('Graphistry's encode_point_badge API'), which distinguishes it from sibling tools like encode_point_color or encode_point_size that handle different visual encodings. The verb 'set' and resource 'graph' are precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the example and parameter explanations (e.g., using 'column' for badge encoding), but does not explicitly state when to use this tool versus alternatives like encode_point_icon or encode_point_color. No guidance is provided on prerequisites, such as needing an existing graph, or exclusions for when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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