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
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | 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 | No | Page number for pagination | |
| pageSize | No | Number of items per page |
Implementation Reference
- build/index.js:768-793 (handler)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)}` }] }; } });
- build/index.js:765-767 (schema)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)}` }] }; } });
- build/index.js:127-142 (helper)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; }