Skip to main content
Glama
kdqed
by kdqed

polar_line

Create polar line plots from SQL queries on CSV or Parquet data sources. Visualize radial and angular coordinates with optional color coding for multi-dimensional analysis.

Instructions

Run query against specified source and make a polar 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
rYesColumn name from SQL result to use as radial coordinate
thetaYesColumn name from SQL result to use as angular coordinate
colorNoOptional; column name from SQL result to use for drawing multiple colored lines representing another dimension

Implementation Reference

  • Handler function implementing the polar_line tool logic: executes SQL query on specified data source, generates polar line plot with Plotly Express (px.line_polar), converts to base64 PNG image, or returns error.
    def polar_line(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')
        ],
        r: Annotated[
            str, Field(description='Column name from SQL result to use as radial coordinate')
        ],
        theta: Annotated[
            str, Field(description='Column name from SQL result to use as angular coordinate')
        ],
        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 polar 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_polar(df, r=r, theta=theta, color=color, line_close=True)
            
            return _fig_to_image(fig)
        except Exception as e:
            return str(e)
  • Registers the polar_line method by including it in the Visualizations class's self.tools list, which is aggregated into higher-level tool lists for MCP server registration.
    self.tools = [
        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,
    ]
  • Helper function used by polar_line (and other plot tools) to convert Plotly figure to MCP ImageContent with base64-encoded PNG data.
    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 used by polar_line to retrieve Pandas DataFrame from data source by executing the provided SQL query.
    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)
Behavior3/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 discloses key behavioral traits: it runs a query, makes a plot, uses DuckDB SQL syntax with specific table names for CSV/parquet sources, and returns an image. However, it lacks details on permissions, error handling, or performance limits. The description does not contradict any annotations.

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 appropriately sized and front-loaded: the first sentence states the core purpose, followed by specific syntax guidelines and output information. Every sentence earns its place by providing essential usage details without redundancy.

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

Completeness4/5

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

Given the complexity (a visualization tool with 5 parameters) and no annotations or output schema, the description is fairly complete: it covers the tool's purpose, syntax rules, and output type. However, it could benefit from more behavioral context (e.g., error cases or limitations) to fully compensate for the lack of structured data.

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. The description adds some context: it mentions 'CSV' and 'PARQUET' as table names in queries, which relates to the 'source_id' and 'query' parameters, but does not provide additional meaning beyond what the schema descriptions offer for parameters like 'r', 'theta', or 'color'.

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

Purpose5/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 polar line plot using result'. It specifies the verb ('run query' and 'make a polar line plot'), the resource ('specified source'), and distinguishes it from siblings like 'polar_scatter' (which makes scatter plots) and 'run_query' (which only runs queries without visualization).

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool: for creating polar line plots from query results. It implicitly distinguishes it from siblings by specifying the plot type (polar line), but does not explicitly state when not to use it or name alternatives (e.g., 'use polar_scatter for scatter plots instead').

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