Skip to main content
Glama

strip_plot

Execute SQL queries on CSV or Parquet sources to create strip plots, visualizing data by specifying x-axis, y-axis, and optional color attributes for enhanced analysis via Zaturn MCP server.

Instructions

Run query against specified source and make a strip 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
colorNoOptional column name from SQL result to show multiple colored strips representing another dimension
queryYesSQL query to run on the data source
source_idYesThe data source to run the query on
xYesColumn name from SQL result to use for x-axis
yYesColumn name from SQL result to use for y-axis

Implementation Reference

  • The core handler function for the 'strip_plot' MCP tool. It takes source_id, SQL query, x/y columns, optional color column, executes the query via _get_df_from_source, creates a strip plot with plotly.express.strip, converts to PNG image via _fig_to_image, and returns ImageContent or error string.
    def strip_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 show multiple colored strips representing another dimension') ] = None, ) -> str | ImageContent: """ Run query against specified source and make a strip 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.strip(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)
  • Local registration of the strip_plot method in the Visualizations class's tools list. This list is later used in ZaturnTools and registered in the MCP server.
    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 base64-encoded PNG ImageContent, used by strip_plot and all other plot 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, returning a DataFrame. Used by strip_plot and all other visualization 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)
  • Global MCP server registration where all tools from ZaturnTools (including strip_plot) are dynamically added to the FastMCP server using Tool.from_function.
    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

Other Tools

Related 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