Skip to main content
Glama
Fervoyush

Plotnine MCP Server

by Fervoyush

import_plot_config

Load saved plot configurations to recreate visualizations quickly. Modify specific parameters like data sources while preserving the original design structure for consistent plotting.

Instructions

Import and use a saved plot configuration.

Load a previously exported plot configuration and create a plot from it. You can optionally override specific parameters (like data_source) while keeping the rest of the configuration intact.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
config_pathYesPath to the saved configuration JSON file
overridesNoOptional overrides for config parameters (e.g., new data_source)

Implementation Reference

  • Implements the core logic for the import_plot_config tool: loads JSON config from file, applies optional overrides, and creates the plot by calling create_plot_handler.
    async def import_plot_config_handler(arguments: dict[str, Any]) -> list[TextContent]:
        """Handle import_plot_config tool calls."""
        try:
            from pathlib import Path
    
            config_path = Path(arguments["config_path"])
            overrides = arguments.get("overrides", {})
    
            # Check if file exists
            if not config_path.exists():
                return [
                    TextContent(
                        type="text",
                        text=f"Configuration file not found: {config_path}\n\nPlease check the path and try again.",
                    )
                ]
    
            # Load config from file
            with open(config_path, "r") as f:
                config = json.load(f)
    
            # Apply overrides if provided
            if overrides:
                config.update(overrides)
    
            # Create plot using the loaded config
            result = await create_plot_handler(config)
    
            # Prepend info about the config source
            original_message = result[0].text if result else ""
            new_message = f"""Plot created from imported configuration!
    
    Config file: {config_path}
    Overrides applied: {len(overrides)} parameter(s)
    
    {original_message}"""
    
            return [TextContent(type="text", text=new_message)]
    
        except json.JSONDecodeError as e:
            return [
                TextContent(
                    type="text",
                    text=f"Invalid JSON in config file: {str(e)}\n\nPlease check that the file contains valid JSON.",
                )
            ]
        except Exception as e:
            return [
                TextContent(
                    type="text",
                    text=f"Error importing config: {str(e)}\n\nPlease check:\n- Config file is valid\n- All required fields are present",
                )
            ]
  • Registers the import_plot_config tool in the MCP server with its description and input schema definition.
            Tool(
                name="import_plot_config",
                description="""Import and use a saved plot configuration.
    
    Load a previously exported plot configuration and create a plot from it.
    You can optionally override specific parameters (like data_source) while
    keeping the rest of the configuration intact.""",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "config_path": {
                            "type": "string",
                            "description": "Path to the saved configuration JSON file",
                        },
                        "overrides": {
                            "type": "object",
                            "description": "Optional overrides for config parameters (e.g., new data_source)",
                        },
                    },
                    "required": ["config_path"],
                },
            ),
  • Defines the input schema for the import_plot_config tool, specifying config_path as required and overrides as optional.
    inputSchema={
        "type": "object",
        "properties": {
            "config_path": {
                "type": "string",
                "description": "Path to the saved configuration JSON file",
            },
            "overrides": {
                "type": "object",
                "description": "Optional overrides for config parameters (e.g., new data_source)",
            },
        },
        "required": ["config_path"],
    },

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/Fervoyush/plotnine-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server