get-category
Retrieve category details by ID using the PI API MCP Server, enabling efficient access to specific data within the PI Dashboard resources.
Instructions
Get a category by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Category ID |
Implementation Reference
- build/index.js:628-646 (registration)Registration of the 'get-category' MCP tool, including Zod input schema for category ID and inline async handler that makes an authenticated API request to fetch category details by ID, formats the response as text content, and handles errors appropriately.server.tool("get-category", "Get a category by ID", { id: z.number().describe("Category ID") }, async ({ id }) => { try { const category = await authenticatedRequest(`/categories/${id}`); return { content: [{ type: "text", text: `Category details:\n${JSON.stringify(category, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error fetching category: ${getErrorMessage(error)}` }] }; } });
- build/index.js:630-646 (handler)The core handler function for the get-category tool. It takes a category ID, performs an authenticated GET request to /categories/{id}, returns the JSON-stringified category details in MCP text content format on success, or an error response on failure.}, async ({ id }) => { try { const category = await authenticatedRequest(`/categories/${id}`); return { content: [{ type: "text", text: `Category details:\n${JSON.stringify(category, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error fetching category: ${getErrorMessage(error)}` }] }; } });
- build/index.js:629-629 (schema)Zod schema definition for the tool's input parameter: a required number representing the Category ID.id: z.number().describe("Category ID")