Skip to main content
Glama

apply_time_ring_layout

Arrange graph nodes in circular rings based on timestamp data to visualize temporal patterns and relationships over time.

Instructions

Apply a time ring layout to the graph using Graphistry's time_ring_layout API. Args: graph_id (str): The ID of the graph to modify. time_col (str): The node column to use for determining ring position (should be a datetime or timestamp attribute, e.g., 'created_at'). Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: apply_time_ring_layout(graph_id, time_col='created_at')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes
time_colYes

Implementation Reference

  • This is the main handler function for the 'apply_time_ring_layout' tool, decorated with @mcp.tool() which registers it in the MCP server. It applies a time ring layout to a graph using Graphistry's API, handling datetime coercion if necessary, and returns the updated graph ID and visualization URL.
    @mcp.tool() async def apply_time_ring_layout(graph_id: str, time_col: str) -> Dict[str, Any]: """ Apply a time ring layout to the graph using Graphistry's time_ring_layout API. Args: graph_id (str): The ID of the graph to modify. time_col (str): The node column to use for determining ring position (should be a datetime or timestamp attribute, e.g., 'created_at'). Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: apply_time_ring_layout(graph_id, time_col='created_at') """ if graph_id not in graph_cache: raise ValueError(f"Graph not found: {graph_id}") g = graph_cache[graph_id]["graph"] # Ensure the time_col is datetime64 for Graphistry nodes_df = graph_cache[graph_id].get("nodes_df") if nodes_df is not None and time_col in nodes_df.columns: if not pd.api.types.is_datetime64_any_dtype(nodes_df[time_col]): # Coerce to datetime64 nodes_df[time_col] = pd.to_datetime(nodes_df[time_col], errors="coerce") # Update the graph's nodes table g = g.nodes(nodes_df) g = g.time_ring_layout(time_col) graph_cache[graph_id]["graph"] = g return {"graph_id": graph_id, "url": g.plot(render=False)}
  • The @mcp.tool() decorator registers the apply_time_ring_layout function as an MCP tool with that name.
    @mcp.tool()
  • The function signature and docstring define the input schema (graph_id: str, time_col: str) and output (Dict[str, Any] with graph_id and url).
    async def apply_time_ring_layout(graph_id: str, time_col: str) -> Dict[str, Any]: """ Apply a time ring layout to the graph using Graphistry's time_ring_layout API. Args: graph_id (str): The ID of the graph to modify. time_col (str): The node column to use for determining ring position (should be a datetime or timestamp attribute, e.g., 'created_at'). Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: apply_time_ring_layout(graph_id, time_col='created_at')

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