Skip to main content
Glama

list-charts

Retrieve a paginated list of charts from PI Dashboard, with support for filtering by attributes like description or category using operators such as like, eq, or gt.

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 'list-charts' tool registration and handler. It accepts optional 'filter', 'page', and 'pageSize' parameters. Parses filters using parseFilters(), then makes an authenticated GET request to '/charts' endpoint. Returns the list of charts as JSON text.
    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)}` }]
            };
        }
    });
  • Schema definition for the 'list-charts' tool. Defines three parameters: filter (optional string), page (optional number, default 1), and pageSize (optional number, default 20).
    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 }) => {
  • The parseFilters helper function used by list-charts to parse filter strings in the format 'fieldName(operator)=value'. Supports combining multiple filters with '&'.
    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;
    }
  • The authenticatedRequest helper function used by list-charts to make authenticated HTTP requests to the API backend. Handles auth headers, query params, orgId, and response parsing.
    async function authenticatedRequest(endpoint, method = "GET", body = null, queryParams = {}) {
        if (!apiUrlSet) {
            throw new Error("API URL not set. Please set the API URL using the set-api-url tool.");
        }
        if (!authToken) {
            throw new Error("Not authenticated. Please authenticate first.");
        }
        // Build URL with query parameters
        let url = `${API_BASE_URL}${endpoint}`;
        // Add orgId if available
        if (orgId !== null) {
            queryParams.orgId = orgId.toString();
        }
        // Add query parameters if any
        if (Object.keys(queryParams).length > 0) {
            const queryString = Object.entries(queryParams)
                .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
                .join("&");
            url = `${url}?${queryString}`;
        }
        logInfo(`Making ${method} request to ${url}`);
        const headers = {
            "Authorization": `bearer ${authToken}`,
            "Content-Type": "application/json"
        };
        const options = {
            method,
            headers
        };
        if (body !== null && ["POST", "PUT"].includes(method)) {
            options.body = JSON.stringify(body);
            logInfo(`Request body: ${JSON.stringify(body)}`);
        }
        try {
            const response = await fetch(url, options);
            if (!response.ok) {
                const errorText = await response.text();
                logError(`API request failed with status ${response.status}: ${errorText}`);
                throw new Error(`API request failed with status ${response.status}: ${response.statusText}`);
            }
            // Check if the response is JSON or binary
            const contentType = response.headers.get("content-type") || "";
            if (contentType.includes("application/json")) {
                const jsonData = await response.json();
                logInfo(`Received JSON response: ${JSON.stringify(jsonData).substring(0, 200)}...`);
                return jsonData;
            }
            else if (contentType.includes("text/csv")) {
                // For binary/file responses, return a base64 encoded string
                const buffer = await response.arrayBuffer();
                const base64 = Buffer.from(buffer).toString("base64");
                logInfo(`Received binary response of type ${contentType}, length: ${base64.length}`);
                return {
                    contentType,
                    data: base64
                };
            }
            else {
                // Otherwise, return as text
                const text = await response.text();
                logInfo(`Received text response: ${text.substring(0, 200)}...`);
                return text;
            }
        }
        catch (error) {
            logError(`API request error: ${getErrorMessage(error)}`);
            throw error;
        }
    }
Behavior1/5

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

The description lacks any behavioral disclosure beyond the basic operation. No annotations are present, so the description should inform about read-only status, side effects, or auth requirements. It does not, leaving the agent without crucial safety context.

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

Conciseness3/5

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

The description is a single sentence, which is concise, but it lacks important details such as usage context or behavioral notes. It earns its place minimally but could be more informative without becoming verbose.

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

Completeness2/5

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

Given the absence of annotations and output schema, the description should provide more context about return format, pagination behavior, or filtering instructions. It only covers the basic purpose, leaving significant gaps for the agent.

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?

With 100% schema description coverage, the input schema already documents all three parameters. The description adds no extra meaning about parameter usage or constraints beyond what is in the schema, meeting the baseline.

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 verb 'list' and resource 'charts', and implies filtering support. It distinguishes from sibling tools like get-chart (single chart) and export-chart. However, it does not specify scope (e.g., 'all charts in the organization'), leaving some ambiguity.

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?

No guidance is provided on when to use this tool versus alternatives like get-chart or export-chart. The description does not mention prerequisites, authentication needs, or scenarios where filtering or pagination is useful.

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

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