get_graph_info
Retrieve details of a stored graph visualization using its unique identifier. Use this tool within Graphistry MCP for efficient analysis and integration of complex network data.
Instructions
Get information about a stored graph visualization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes |
Implementation Reference
- The get_graph_info tool handler function. Retrieves metadata about a stored graph, including title, description, node count, and edge count from the global graph_cache. Includes error handling and logging.@mcp.tool() async def get_graph_info(graph_id: str) -> Dict[str, Any]: """Get information about a stored graph visualization.""" try: if graph_id not in graph_cache: raise ValueError(f"Graph not found: {graph_id}") graph_data = graph_cache[graph_id] edges_df = graph_data["edges_df"] source = graph_data["source"] destination = graph_data["destination"] # Get node and edge counts if edges_df is not None: node_count = len(set(edges_df[source].unique()) | set(edges_df[destination].unique())) edge_count = len(edges_df) else: node_count = 0 edge_count = 0 return { "graph_id": graph_id, "title": graph_data["title"], "description": graph_data["description"], "node_count": node_count, "edge_count": edge_count } except Exception as e: logger.error(f"Error in get_graph_info: {e}") raise
- src/graphistry_mcp_server/server.py:176-176 (registration)The @mcp.tool() decorator registers the get_graph_info function as an MCP tool.@mcp.tool()
- Global cache dictionary that stores graph data, used by get_graph_info to retrieve graph information.graph_cache: Dict[str, Any] = {}