mpl_mcp_plot_barchart
Create bar charts from numerical data using Matplotlib within Fermat MCP for mathematical visualization and analysis.
Instructions
Plots barchart of given datavalues
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| values | Yes | ||
| labels | No | ||
| title | No | ||
| xlabel | No | ||
| ylabel | No | ||
| color | No | skyblue | |
| save | No | ||
| dpi | No | ||
| orientation | No | vertical |
Implementation Reference
- fmcp/mpl_mcp/core/bar_chart.py:8-54 (handler)The handler function that executes the barchart plotting logic using matplotlib, with type-annotated parameters serving as input schema.def plot_barchart( values: List[Union[float, int]], labels: Optional[List[str]] = None, title: str = "", xlabel: str = "", ylabel: str = "", color: str = "skyblue", save: bool = False, dpi: int = 200, orientation: Literal["vertical", "horizontal"] = "vertical", ) -> Image: """ Plot a bar chart (vertical or horizontal) with optional labels (defaults to empty strings). Args: values: List of bar heights (values: float or int) labels: List of bar labels (categories) or None for empty labels title: Plot title xlabel: Label for the x-axis ylabel: Label for the y-axis color: Color for the bars (default: "skyblue") save: If True, save the figure to a buffer dpi: Output image resolution (dots per inch, default: 100) orientation: "vertical" or "horizontal" (default: "vertical") Returns: FastMCP Image object with the plotted chart """ plt.figure(dpi=dpi) if labels is None: labels = [""] * len(values) if orientation == "vertical": plt.bar(labels, values, color=color) else: plt.barh(labels, values, color=color) plt.title(title) plt.xlabel(xlabel) plt.ylabel(ylabel) plt.xticks(rotation=45) plt.tight_layout() buf = io.BytesIO() plt.savefig(buf, format="png", dpi=dpi) plt.close() buf.seek(0) return Image(data=buf.read(), format="png")
- fmcp/mpl_mcp/server.py:19-19 (registration)Registers the plot_barchart handler as a tool in the FastMCP server named 'mpl_mcp', resulting in the tool name 'mpl_mcp_plot_barchart'.mpl_mcp.tool(plot_barchart, description="Plots barchart of given datavalues")
- fmcp/mpl_mcp/server.py:2-2 (registration)Imports the plot_barchart function into the server module for registration.from .core.bar_chart import plot_barchart