Skip to main content
Glama

list-charts

Retrieve and filter charts from PI Dashboard resources with pagination support, enabling precise data selection based on customizable criteria.

Instructions

List all charts with filtering support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoFilter criteria in the format 'fieldName(operator)=value'. Multiple filters can be combined with & (e.g., 'description(like)=revenue&categoryId(eq)=5'). Available operators: eq, ne, gt, lt, ge, le, like, nlike. Use get-filterable-attributes tool to see available fields.
pageNoPage number for pagination
pageSizeNoNumber of items per page

Implementation Reference

  • The handler function that implements the core logic of the 'list-charts' tool. It handles input parameters, parses filters using the parseFilters helper, constructs query parameters for pagination, performs an authenticated GET request to the /charts endpoint, and returns the results as formatted text or an error message.
    }, async ({ filter, page, pageSize }) => { try { let queryParams = { page: page.toString(), pageSize: pageSize.toString() }; // Parse and add filter parameters if (filter) { const filterParams = parseFilters(filter); queryParams = { ...queryParams, ...filterParams }; } const charts = await authenticatedRequest("/charts", "GET", null, queryParams); return { content: [{ type: "text", text: `Charts retrieved successfully:\n${JSON.stringify(charts, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error fetching charts: ${getErrorMessage(error)}` }] }; } });
  • Zod schema defining the input parameters for the 'list-charts' tool: optional filter string, page (default 1), and pageSize (default 20).
    filter: z.string().optional().describe("Filter criteria in the format 'fieldName(operator)=value'. Multiple filters can be combined with & (e.g., 'description(like)=revenue&categoryId(eq)=5'). Available operators: eq, ne, gt, lt, ge, le, like, nlike. Use get-filterable-attributes tool to see available fields."), page: z.number().optional().default(1).describe("Page number for pagination"), pageSize: z.number().optional().default(20).describe("Number of items per page")
  • build/index.js:764-793 (registration)
    The server.tool registration call for 'list-charts', including description, input schema, and inline handler function.
    server.tool("list-charts", "List all charts with filtering support", { filter: z.string().optional().describe("Filter criteria in the format 'fieldName(operator)=value'. Multiple filters can be combined with & (e.g., 'description(like)=revenue&categoryId(eq)=5'). Available operators: eq, ne, gt, lt, ge, le, like, nlike. Use get-filterable-attributes tool to see available fields."), page: z.number().optional().default(1).describe("Page number for pagination"), pageSize: z.number().optional().default(20).describe("Number of items per page") }, async ({ filter, page, pageSize }) => { try { let queryParams = { page: page.toString(), pageSize: pageSize.toString() }; // Parse and add filter parameters if (filter) { const filterParams = parseFilters(filter); queryParams = { ...queryParams, ...filterParams }; } const charts = await authenticatedRequest("/charts", "GET", null, queryParams); return { content: [{ type: "text", text: `Charts retrieved successfully:\n${JSON.stringify(charts, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error fetching charts: ${getErrorMessage(error)}` }] }; } });
  • Supporting utility function parseFilters that converts a filter string (e.g., 'description(like)=revenue&categoryId(eq)=5') into an object of query parameters used by the list-charts handler.
    function parseFilters(filterString) { const queryParams = {}; if (!filterString) return queryParams; // Split by & to handle multiple filters const filters = filterString.split('&'); for (const filter of filters) { // Match the pattern fieldName(operator)=value const match = filter.match(/([a-zA-Z]+)\(([a-zA-Z]+)\)=(.+)/); if (match) { const [_, field, operator, value] = match; queryParams[`${field}(${operator})`] = value; } } return queryParams; }

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/mingzilla/pi-api-mcp-server'

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