Skip to main content
Glama

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
NameRequiredDescriptionDefault
filterNoFilter 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.
pageNoPage number for pagination
pageSizeNoNumber of items per page

Implementation Reference

  • 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)}` }] }; } });
  • 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", {
  • 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; }

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