Skip to main content
Glama
kdqed
by kdqed

polar_scatter

Create polar scatter plots by querying data sources with SQL. Visualize radial and angular coordinates from query results as scatter points on a polar coordinate system.

Instructions

Run query against specified source and make a polar scatter 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 coloring the points, with color representing another dimension

Implementation Reference

  • Handler function implementing the polar_scatter tool. Runs SQL query on specified data source, generates polar scatter plot using plotly.express.scatter_polar with radial (r) and angular (theta) coordinates, optionally colored by another column, converts to base64 PNG ImageContent or returns error string.
    def polar_scatter(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 coloring the points, with color representing another dimension')
        ] = None,
    ) -> str | ImageContent:
        """
        Run query against specified source and make a polar scatter 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.scatter_polar(df, r=r, theta=theta, color=color)
            
            return _fig_to_image(fig)
        except Exception as e:
            return str(e)
  • Registration of the polar_scatter tool in the Visualizations class's self.tools list during initialization.
    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 to convert a Plotly figure to a base64-encoded PNG ImageContent object, used by polar_scatter and other visualization tools.
    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 function to retrieve and execute SQL query on the specified data source using query_utils, returning a DataFrame; used by polar_scatter and other tools.
    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?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool executes a query, creates a polar scatter plot, and returns an image. However, it doesn't mention performance characteristics, error handling, authentication requirements, or what happens with invalid queries/parameters. The statement about DuckDB SQL syntax and table naming conventions adds useful context beyond basic functionality.

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 (4 sentences) and front-loaded with the core purpose. Each sentence adds value: the first states the purpose, the second specifies SQL syntax requirements, the third clarifies table naming conventions, and the fourth describes the return type. There's minimal waste, though the structure could be slightly more organized.

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 tool's complexity (query execution + visualization), no annotations, and no output schema, the description is moderately complete. It covers the main workflow and return type but lacks details about error conditions, performance limits, or what the image output contains (format, dimensions, etc.). For a visualization tool with query execution, more context about failure modes would be helpful.

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 5 parameters thoroughly. The description adds minimal parameter semantics beyond the schema - it mentions using result columns for coordinates and coloring, but this is already covered in the schema descriptions. The baseline of 3 is appropriate when 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 polar scatter plot using result' - this specifies both the action (run query, make plot) and the resource (data source, query result). It distinguishes from siblings like 'scatter_plot' by specifying 'polar' scatter plot, but doesn't fully differentiate from 'polar_line' beyond plot type.

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

Usage Guidelines3/5

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

The description provides some usage context: it specifies when to use 'CSV' vs 'PARQUET' as table names based on source type, and mentions this is for both csv and parquet sources. However, it doesn't explicitly state when to choose this tool over alternatives like 'scatter_plot', 'polar_line', or 'run_query' - the guidance is implied rather than explicit.

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