Skip to main content
Glama

encode_point_color

Set node colors in a graph visualization based on column values, using categorical mapping or continuous gradients to highlight patterns in network data.

Instructions

Set node color encoding for a graph using Graphistry's encode_point_color API.

Args:
    graph_id (str): The ID of the graph to modify (from visualize_graph).
    column (str): The node column to use for color encoding (e.g., 'type', 'score').
    categorical_mapping (dict, optional): Map of category values to color codes. Example: {'mac': '#F99', 'macbook': '#99F'}. If not provided, Graphistry will auto-assign colors.
    default_mapping (str, optional): Color code to use for values not in categorical_mapping. Example: 'silver'.
    as_continuous (bool, optional): If True, treat the column as continuous and use a gradient palette. Example: True for numeric columns like 'score'.

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

Example:
    encode_point_color(graph_id, column='type', categorical_mapping={'mac': '#F99', 'macbook': '#99F'}, default_mapping='silver')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes
columnYes
categorical_mappingNo
default_mappingNo
as_continuousNo

Implementation Reference

  • The main handler function for the 'encode_point_color' tool, decorated with @mcp.tool() for registration in the FastMCP server. It modifies the graph's node colors based on a specified column and mappings using Graphistry's encode_point_color method.
    @mcp.tool()
    async def encode_point_color(
        graph_id: str,
        column: str,
        categorical_mapping: Optional[dict] = None,
        default_mapping: Optional[str] = None,
        as_continuous: Optional[bool] = False
    ) -> Dict[str, Any]:
        """
        Set node color encoding for a graph using Graphistry's encode_point_color API.
    
        Args:
            graph_id (str): The ID of the graph to modify (from visualize_graph).
            column (str): The node column to use for color encoding (e.g., 'type', 'score').
            categorical_mapping (dict, optional): Map of category values to color codes. Example: {'mac': '#F99', 'macbook': '#99F'}. If not provided, Graphistry will auto-assign colors.
            default_mapping (str, optional): Color code to use for values not in categorical_mapping. Example: 'silver'.
            as_continuous (bool, optional): If True, treat the column as continuous and use a gradient palette. Example: True for numeric columns like 'score'.
    
        Returns:
            dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
    
        Example:
            encode_point_color(graph_id, column='type', categorical_mapping={'mac': '#F99', 'macbook': '#99F'}, default_mapping='silver')
        """
        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_continuous:
            kwargs["as_continuous"] = as_continuous
        g = g.encode_point_color(**kwargs)
        graph_cache[graph_id]["graph"] = g
        return {"graph_id": graph_id, "url": g.plot(render=False)}
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explaining key behaviors: it modifies an existing graph (implied by 'graph_id' from visualize_graph), describes what happens when categorical_mapping isn't provided (auto-assign colors), and specifies the return format. However, it doesn't mention error conditions, rate limits, or authentication requirements.

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

Conciseness5/5

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

The description is efficiently structured with a clear purpose statement, organized parameter explanations with examples, return format specification, and a complete usage example. Every sentence adds value without redundancy, and information is appropriately front-loaded with the core functionality stated first.

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?

For a 5-parameter mutation tool with no annotations and no output schema, the description provides substantial context: clear purpose, parameter semantics, return format, and examples. The main gap is lack of explicit error handling or permission requirements, but it covers most essential aspects given the complexity.

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?

With 0% schema description coverage, the description fully compensates by providing clear semantic explanations for all 5 parameters: graph_id's source, column's purpose with examples, categorical_mapping's format and default behavior, default_mapping's role, and as_continuous's effect with usage examples. Each parameter's meaning is explained beyond basic type information.

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 color encoding for a graph') and identifies the exact resource ('using Graphistry's encode_point_color API'). It distinguishes from sibling tools like encode_point_badge and encode_point_size by focusing specifically on color encoding rather than other visual attributes.

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 context through examples (e.g., 'for numeric columns like 'score'') but doesn't explicitly state when to use this tool versus alternatives like encode_point_badge or encode_point_icon. No explicit exclusions or prerequisites are mentioned, leaving usage guidance at an implied level.

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