Skip to main content
Glama

mpl_mcp_plot_barchart

Generate bar charts by plotting numerical data with customizable labels, titles, axis labels, colors, and orientation on the Fermat MCP server.

Instructions

Plots barchart of given datavalues

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
colorNoskyblue
dpiNo
labelsNo
orientationNovertical
saveNo
titleNo
valuesYes
xlabelNo
ylabelNo

Implementation Reference

  • The main handler function plot_barchart that generates vertical or horizontal bar charts using matplotlib and returns a PNG image via FastMCP Image object.
    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")
  • Registers the plot_barchart function as the MCP tool 'mpl_mcp_plot_barchart' using FastMCP's tool decorator with a description.
    mpl_mcp.tool(plot_barchart, description="Plots barchart of given datavalues")
  • Imports the plot_barchart handler into the server for registration.
    from .core.bar_chart import plot_barchart

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/abhiphile/fermat-mcp'

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