batch_create_plots
Generate multiple publication-quality statistical graphics in a single batch operation for data visualization tasks like pairwise comparisons, categorical analysis, and numeric column plotting.
Instructions
Create multiple plots in one batch operation.
Useful for:
Creating plots for all numeric columns in a dataset
Generating pairwise scatter plots
Creating plots for each category separately
Comparing different plot types
Each plot configuration is processed independently, and all plots are created in sequence.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| plots | Yes | Array of plot configurations (same structure as create_plot) |
Implementation Reference
- src/plotnine_mcp/server.py:499-521 (registration)Registration of the batch_create_plots tool, including name, description, and input schema defining an array of plot configurations.Tool( name="batch_create_plots", description="""Create multiple plots in one batch operation. Useful for: - Creating plots for all numeric columns in a dataset - Generating pairwise scatter plots - Creating plots for each category separately - Comparing different plot types Each plot configuration is processed independently, and all plots are created in sequence.""", inputSchema={ "type": "object", "properties": { "plots": { "type": "array", "description": "Array of plot configurations (same structure as create_plot)", "items": {"type": "object"}, }, }, "required": ["plots"], }, ),
- src/plotnine_mcp/server.py:1130-1196 (handler)The handler function that implements batch_create_plots by iterating over the provided list of plot configurations and delegating to create_plot_handler for each, collecting results and providing a summary.async def batch_create_plots_handler(arguments: dict[str, Any]) -> list[TextContent]: """Handle batch_create_plots tool calls.""" try: plots = arguments.get("plots", []) if not plots: return [ TextContent( type="text", text="No plots provided. Please include an array of plot configurations in the 'plots' parameter.", ) ] message = f"Batch Plot Creation\n" + "=" * 60 + "\n\n" message += f"Creating {len(plots)} plot(s)...\n\n" results = [] successful = 0 failed = 0 for i, plot_config in enumerate(plots, 1): try: # Create plot using existing handler result = await create_plot_handler(plot_config) if result and "successfully" in result[0].text: successful += 1 # Extract filename from result result_text = result[0].text if "Output file:" in result_text: filename_line = [ line for line in result_text.split("\n") if "Output file:" in line ][0] filename = filename_line.split(": ")[1] message += f"{i}. ✓ {filename}\n" else: message += f"{i}. ✓ Plot created\n" else: failed += 1 error_msg = result[0].text if result else "Unknown error" message += f"{i}. ✗ Failed: {error_msg[:100]}...\n" results.append({"index": i, "success": successful > failed, "result": result}) except Exception as e: failed += 1 message += f"{i}. ✗ Error: {str(e)[:100]}...\n" results.append({"index": i, "success": False, "error": str(e)}) message += "\n" + "=" * 60 + "\n" message += f"Summary:\n" message += f" • Total: {len(plots)}\n" message += f" • Successful: {successful}\n" message += f" • Failed: {failed}\n" if successful > 0: message += f"\n✓ {successful} plot(s) created successfully!" return [TextContent(type="text", text=message)] except Exception as e: return [ TextContent( type="text", text=f"Batch creation error: {str(e)}\n\nPlease check your plot configurations.", ) ]
- src/plotnine_mcp/server.py:510-520 (schema)Input schema definition for batch_create_plots, specifying an array of plot configuration objects.inputSchema={ "type": "object", "properties": { "plots": { "type": "array", "description": "Array of plot configurations (same structure as create_plot)", "items": {"type": "object"}, }, }, "required": ["plots"], },