configure_preferences
Set visualization preferences for charts including output format, theme, and dimensions in the mcp-plots server.
Instructions
Interactive configuration tool for setting user preferences.
Parameters:
- output_format: "mermaid", "mcp_image", or "mcp_text"
- theme: "default", "dark", "seaborn", "minimal", etc.
- chart_width: Chart width in pixels
- chart_height: Chart height in pixels
- reset_to_defaults: Reset all preferences to system defaults
If no parameters provided, shows current configuration with sample.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_format | No | ||
| theme | No | ||
| chart_width | No | ||
| chart_height | No | ||
| reset_to_defaults | No |
Implementation Reference
- src/capabilities/tools.py:58-139 (handler)Core handler function implementing the configure_preferences tool logic: validates inputs, updates preferences via config_service, handles reset, shows current config, and formats responses.def _configure_preferences_impl( output_format: str = None, theme: str = None, chart_width: int = None, chart_height: int = None, reset_to_defaults: bool = False ) -> Dict[str, Any]: """ Interactive configuration tool for setting user preferences. Parameters: - output_format: "mermaid", "mcp_image", or "mcp_text" - theme: "default", "dark", "seaborn", "minimal", etc. - chart_width: Chart width in pixels - chart_height: Chart height in pixels - reset_to_defaults: Reset all preferences to system defaults If no parameters provided, shows current configuration with sample. """ try: config_service = get_config_service() if reset_to_defaults: prefs = config_service.reset_to_defaults() return { "content": [{ "type": "text", "text": f"β **Configuration Reset**\n\nAll preferences reset to defaults:\n{_format_preferences(prefs.to_dict())}" }] } # Validate inputs before updating updates = {} if output_format is not None: if ChartConstants.OutputFormats.validate(output_format): updates["output_format"] = output_format else: valid_formats = ", ".join(ChartConstants.OutputFormats.all()) raise ValueError(f"Invalid output format '{output_format}'. Valid options: {valid_formats}") if theme is not None: if ChartConstants.Themes.validate(theme): updates["theme"] = theme else: valid_themes = ", ".join(ChartConstants.Themes.all()) raise ValueError(f"Invalid theme '{theme}'. Valid options: {valid_themes}") if chart_width is not None: if chart_width < ChartConstants.ConfigDefaults.MIN_WIDTH or chart_width > ChartConstants.ConfigDefaults.MAX_WIDTH: raise ValueError(f"Chart width must be between {ChartConstants.ConfigDefaults.MIN_WIDTH} and {ChartConstants.ConfigDefaults.MAX_WIDTH}") updates["chart_width"] = chart_width if chart_height is not None: if chart_height < ChartConstants.ConfigDefaults.MIN_HEIGHT or chart_height > ChartConstants.ConfigDefaults.MAX_HEIGHT: raise ValueError(f"Chart height must be between {ChartConstants.ConfigDefaults.MIN_HEIGHT} and {ChartConstants.ConfigDefaults.MAX_HEIGHT}") updates["chart_height"] = chart_height # Show current config if no updates if not updates: current_prefs = config_service.get_user_preferences() return { "content": [{ "type": "text", "text": f"π **Current Configuration**\n\n{_format_preferences(current_prefs.to_dict())}\n\n{_get_config_guide()}" }] } # Update preferences updated_prefs = config_service.update_preferences(**updates) return { "content": [{ "type": "text", "text": f"β **Configuration Updated**\n\n{_format_preferences(updated_prefs.to_dict())}" }] } except Exception as e: logger.error(f"configure_preferences failed: {e}") return {"status": "error", "error": str(e)}
- src/capabilities/tools.py:243-270 (registration)MCP tool registration using @mcp_server.tool() decorator. Defines the tool name, input parameters (serving as schema), docstring, and delegates to implementation.@mcp_server.tool() def configure_preferences( output_format: str = None, theme: str = None, chart_width: int = None, chart_height: int = None, reset_to_defaults: bool = False ) -> Dict[str, Any]: """ Interactive configuration tool for setting user preferences. Parameters: - output_format: "mermaid", "mcp_image", or "mcp_text" - theme: "default", "dark", "seaborn", "minimal", etc. - chart_width: Chart width in pixels - chart_height: Chart height in pixels - reset_to_defaults: Reset all preferences to system defaults If no parameters provided, shows current configuration with sample. """ return _configure_preferences_impl( output_format=output_format, theme=theme, chart_width=chart_width, chart_height=chart_height, reset_to_defaults=reset_to_defaults )
- src/capabilities/tools.py:187-201 (helper)Helper function to format user preferences dictionary into a user-friendly markdown string with descriptions for theme and output_format.def _format_preferences(prefs: Dict[str, Any]) -> str: """Format preferences for display.""" formatted = [] for key, value in prefs.items(): # Add descriptions for better UX if key == "theme": desc = _get_theme_description(value) formatted.append(f"- **{key.replace('_', ' ').title()}**: `{value}` - {desc}") elif key == "output_format": desc = _get_format_description(value) formatted.append(f"- **{key.replace('_', ' ').title()}**: `{value}` - {desc}") else: formatted.append(f"- **{key.replace('_', ' ').title()}**: `{value}`") return "\n".join(formatted)
- src/capabilities/tools.py:203-229 (helper)Helper function providing a detailed configuration guide with descriptions of options, examples, and tips, used in current config display.def _get_config_guide() -> str: """Get user-focused configuration guide.""" return f"""## ποΈ **Available Options** ### **Output Formats** (Where will you use your charts?) - **`{ChartConstants.OutputFormats.MERMAID}`** - Shows directly in Cursor (great for quick analysis) - **`{ChartConstants.OutputFormats.MCP_IMAGE}`** - High-quality images for presentations - **`{ChartConstants.OutputFormats.MCP_TEXT}`** - Scalable graphics for web and documents ### **Visual Styles** - **`{ChartConstants.Themes.DEFAULT}`** - {_get_theme_description('default')} - **`{ChartConstants.Themes.DARK}`** - {_get_theme_description('dark')} - **`{ChartConstants.Themes.SEABORN}`** - {_get_theme_description('seaborn')} - **`{ChartConstants.Themes.MINIMAL}`** - {_get_theme_description('minimal')} ### **Chart Dimensions** - **Width**: {ChartConstants.ConfigDefaults.MIN_WIDTH}-{ChartConstants.ConfigDefaults.MAX_WIDTH} pixels (typical: 800-1200) - **Height**: {ChartConstants.ConfigDefaults.MIN_HEIGHT}-{ChartConstants.ConfigDefaults.MAX_HEIGHT} pixels (typical: 600-800) ### **Quick Setup Examples** - **For exploring data**: Use `mermaid` format with `default` theme - **For presentations**: Use `mcp_image` format with larger size (1200x800) - **For modern dashboards**: Use `mcp_image` format with `dark` theme - **To start fresh**: Reset all settings to defaults **π‘ Tip**: Mermaid format shows results instantly in Cursor - perfect for data exploration. Switch to image format when you need polished charts for presentations."""