Skip to main content
Glama

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
NameRequiredDescriptionDefault
valuesYes
labelsNo
titleNo
xlabelNo
ylabelNo
colorNoskyblue
saveNo
dpiNo
orientationNovertical

Implementation Reference

  • 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")
  • 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")
  • Imports the plot_barchart function into the server module for registration.
    from .core.bar_chart import plot_barchart
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. The description reveals nothing about whether this creates visual output, saves files, requires specific dependencies, has performance characteristics, or what happens when invoked. 'Plots' is the only behavioral clue, which is insufficient for a tool with 9 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 5 words. While this represents under-specification rather than ideal conciseness, it contains zero wasted words and is front-loaded with the core action. Every word earns its place, even if more content is needed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter plotting tool with no annotations, no output schema, and multiple sibling tools, the description is completely inadequate. It doesn't explain what the tool produces (visual display? file output?), how to interpret parameters, when to use it, or any behavioral characteristics. The agent would struggle to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 9 parameters (8 optional), the description provides no information about any parameters. It doesn't mention the required 'values' array, optional labels, title, axis labels, color, save option, DPI, or orientation. The schema must carry all parameter documentation burden.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Plots barchart of given datavalues' states the basic action (plots) and resource (barchart), but is vague about scope and lacks differentiation from sibling tools like 'mpl_mcp_plot_chart' or 'mpl_mcp_plot_stack'. It doesn't specify what makes this barchart tool unique among the various plotting tools available.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With multiple sibling plotting tools (plot_chart, plot_scatter, plot_stack, plot_stem), the description offers no context about when a barchart is appropriate or when other chart types might be better suited.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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