list-categories
Retrieve and filter dashboard categories from the PI API MCP Server with pagination support for organized data management.
Instructions
List all categories 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)=dashboard&orgId(eq)=1'). 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:601-626 (handler)The handler function for the 'list-categories' tool. It constructs query parameters for pagination and filters (using parseFilters helper), makes an authenticated GET request to the /categories API endpoint, and returns the response as text or error.}, 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 categories = await authenticatedRequest("/categories", "GET", null, queryParams); return { content: [{ type: "text", text: `Categories retrieved successfully:\n${JSON.stringify(categories, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error fetching categories: ${getErrorMessage(error)}` }] }; } });
- build/index.js:598-600 (schema)Zod input schema defining optional filter string, page (default 1), and pageSize (default 20) parameters for the list-categories tool.filter: z.string().optional().describe("Filter criteria in the format 'fieldName(operator)=value'. Multiple filters can be combined with & (e.g., 'description(like)=dashboard&orgId(eq)=1'). 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:597-597 (registration)Registration of the 'list-categories' tool on the MCP server using server.tool method.server.tool("list-categories", "List all categories with filtering support", {
- build/index.js:127-142 (helper)Helper function used by list-categories (and list-charts) to parse filter strings like 'description(like)=foo&orgId(eq)=1' into API query parameters.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; }