Skip to main content
Glama

create-category

Add new categories to organize PI Dashboard resources by specifying name, organization ID, and optional settings like labels, help text, and filter configurations.

Instructions

Create a new category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesUnique name of a category
orgIdYesOrganization ID
labelNoAlternative text for the category
helpTextNoHelp text to describe the category
categoryObjectsPositionNoPosition of category objects panel
cascadeFiltersNoEnable cascading filters

Implementation Reference

  • The asynchronous handler function that executes the core logic of the 'create-category' tool. It constructs a payload from the input parameters (adding optional fields if provided) and sends a POST request to the '/categories' endpoint using the shared 'authenticatedRequest' helper. It returns success or error markdown content.
    }, async ({ description, orgId, label, helpText, categoryObjectsPosition, cascadeFilters }) => {
        try {
            const payload = {
                description,
                orgId
            };
            if (label !== undefined)
                payload.label = label;
            if (helpText !== undefined)
                payload.helpText = helpText;
            if (categoryObjectsPosition !== undefined)
                payload.categoryObjectsPosition = categoryObjectsPosition;
            if (cascadeFilters !== undefined)
                payload.cascadeFilters = cascadeFilters;
            const result = await authenticatedRequest("/categories", "POST", payload);
            return {
                content: [{
                        type: "text",
                        text: `Category created successfully:\n${JSON.stringify(result, null, 2)}`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error creating category: ${getErrorMessage(error)}` }]
            };
        }
    });
  • The Zod input schema defining the parameters for the 'create-category' tool, including required fields 'description' and 'orgId', and optional fields for customization.
    description: z.string().describe("Unique name of a category"),
    orgId: z.number().describe("Organization ID"),
    label: z.string().optional().describe("Alternative text for the category"),
    helpText: z.string().optional().describe("Help text to describe the category"),
    categoryObjectsPosition: z.enum(["RIGHT", "TOP"]).optional().describe("Position of category objects panel"),
    cascadeFilters: z.boolean().optional().describe("Enable cascading filters")
  • build/index.js:648-683 (registration)
    The full registration of the 'create-category' tool via McpServer.tool(), specifying name, description, input schema, and inline handler function.
    server.tool("create-category", "Create a new category", {
        description: z.string().describe("Unique name of a category"),
        orgId: z.number().describe("Organization ID"),
        label: z.string().optional().describe("Alternative text for the category"),
        helpText: z.string().optional().describe("Help text to describe the category"),
        categoryObjectsPosition: z.enum(["RIGHT", "TOP"]).optional().describe("Position of category objects panel"),
        cascadeFilters: z.boolean().optional().describe("Enable cascading filters")
    }, async ({ description, orgId, label, helpText, categoryObjectsPosition, cascadeFilters }) => {
        try {
            const payload = {
                description,
                orgId
            };
            if (label !== undefined)
                payload.label = label;
            if (helpText !== undefined)
                payload.helpText = helpText;
            if (categoryObjectsPosition !== undefined)
                payload.categoryObjectsPosition = categoryObjectsPosition;
            if (cascadeFilters !== undefined)
                payload.cascadeFilters = cascadeFilters;
            const result = await authenticatedRequest("/categories", "POST", payload);
            return {
                content: [{
                        type: "text",
                        text: `Category created successfully:\n${JSON.stringify(result, null, 2)}`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error creating category: ${getErrorMessage(error)}` }]
            };
        }
    });
  • Shared helper function 'authenticatedRequest' used by the handler to perform the actual HTTP POST request to create the category, handling authentication, query params, 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;
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create a new category' implies a write operation but doesn't specify permissions needed, whether creation is idempotent, error conditions, or what happens on success. It lacks critical behavioral context for a mutation tool.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with comprehensive schema documentation and gets straight to the point without unnecessary elaboration.

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?

For a mutation tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after creation, error handling, or system behavior. The agent must rely entirely on the input schema without guidance on tool behavior or output expectations.

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?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds no parameter information beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting, though the description could have explained parameter relationships or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Create a new category' clearly states the action (create) and resource (category), but it's vague about what a category represents in this system and doesn't distinguish it from sibling tools like 'update-category' or 'list-categories'. It provides basic purpose but lacks specificity about the domain context.

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?

The description provides no guidance on when to use this tool versus alternatives like 'update-category' or 'list-categories'. It doesn't mention prerequisites (e.g., authentication, organization selection) or typical use cases, leaving the agent to infer usage from the tool name alone.

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