Skip to main content
Glama
kdqed
by kdqed

line_plot

Visualize SQL query results as line charts from CSV, Parquet, or database sources to analyze trends and patterns in data.

Instructions

Run query against specified source and make a line plot using result For both csv and parquet sources, use DuckDB SQL syntax Use 'CSV' as the table name in the SQL query for csv sources. Use 'PARQUET' as the table name in the SQL query for parquet sources.

This will return an image of the plot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_idYesThe data source to run the query on
queryYesSQL query to run on the data source
xYesColumn name from SQL result to use for x-axis
yYesColumn name from SQL result to use for y-axis
colorNoOptional; column name from SQL result to use for drawing multiple colored lines representing another dimension

Implementation Reference

  • The core handler function for the 'line_plot' MCP tool. It executes a SQL query on the specified data source, creates a line plot using Plotly Express (px.line), updates x-axis, converts the figure to a base64-encoded PNG image using _fig_to_image, and returns ImageContent or error string.
    def line_plot(self,
        source_id: Annotated[
            str, Field(description='The data source to run the query on')
        ],  
        query: Annotated[
            str, Field(description='SQL query to run on the data source')
        ],
        x: Annotated[
            str, Field(description='Column name from SQL result to use for x-axis')
        ],
        y: Annotated[
            str, Field(description='Column name from SQL result to use for y-axis')
        ],
        color: Annotated[
            str | None, Field(description='Optional; column name from SQL result to use for drawing multiple colored lines representing another dimension')
        ] = None,
    ) -> str | ImageContent:
        """
        Run query against specified source and make a line plot using result
        For both csv and parquet sources, use DuckDB SQL syntax
        Use 'CSV' as the table name in the SQL query for csv sources.
        Use 'PARQUET' as the table name in the SQL query for parquet sources.
    
        This will return an image of the plot
        """
    
        try:
            df = self._get_df_from_source(source_id, query)
            fig = px.line(df, x=x, y=y, color=color)
            fig.update_xaxes(autotickangles=[0, 45, 60, 90])
    
            return _fig_to_image(fig)
        except Exception as e:
            return str(e)
  • Registration of the line_plot method into the tools list of the Visualizations class, which is then propagated to ZaturnTools.tools and registered in MCP.
        self.scatter_plot,
        self.line_plot,
        self.histogram,
        self.strip_plot,
        self.box_plot,
        self.bar_plot,
    
        self.density_heatmap,
        self.polar_scatter,
        self.polar_line,
    ]
  • MCP server registration: Creates ZaturnTools instance (including line_plot), initializes FastMCP, and registers all tools by calling add_tool(Tool.from_function(tool_function)) in a loop.
    def ZaturnMCP(sources):
        zaturn_tools = ZaturnTools(sources)
        zaturn_mcp = FastMCP()
        for tool_function in zaturn_tools.tools:
            zaturn_mcp.add_tool(Tool.from_function(tool_function))
    
        return zaturn_mcp
  • Helper function that converts a Plotly figure to a base64 PNG ImageContent object, called by line_plot.
    def _fig_to_image(fig):
        fig_encoded = b64encode(fig.to_image(format='png')).decode()
        img_b64 = "data:image/png;base64," + fig_encoded
        
        return ImageContent(
            type = 'image',
            data = fig_encoded,
            mimeType = 'image/png',
            annotations = None,
        )
  • Helper method to fetch data source by ID and execute the SQL query using query_utils.execute_query, returning a Pandas DataFrame for plotting.
    def _get_df_from_source(self, source_id, query):
        source = self.data_sources.get(source_id)
        if not source:
            raise Exception(f"Source {source_id} Not Found")
                
        return query_utils.execute_query(source, query)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool returns 'an image of the plot,' which is useful, but lacks critical behavioral details: it doesn't specify error handling, performance characteristics, data size limits, or authentication needs. For a tool that runs queries and generates plots, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by technical details. However, the second sentence about DuckDB syntax could be more integrated, and there's minor redundancy (e.g., repeating 'SQL query' concepts). Overall, it's efficient with little waste.

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

Completeness3/5

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

Given the complexity (query execution + visualization), no annotations, and no output schema, the description is moderately complete. It covers the basic workflow and output format but lacks details on error cases, performance, or integration with siblings. For a tool with 5 parameters and no structured safety hints, it should do more to guide usage.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema: it implies 'source_id' refers to CSV/parquet sources and specifies table naming conventions, but doesn't elaborate on parameter interactions or usage examples. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Run query against specified source and make a line plot using result.' It specifies the verb ('run query' and 'make a line plot') and resource ('specified source'), but doesn't explicitly differentiate from siblings like 'run_query' (which only runs queries) or other plot types (e.g., 'scatter_plot').

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions DuckDB SQL syntax and table naming conventions for CSV/parquet sources, but doesn't explain when to choose a line plot over other visualization siblings (e.g., 'bar_plot', 'scatter_plot') or when to use 'run_query' instead. No exclusions or prerequisites are stated.

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/kdqed/zaturn'

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