Skip to main content
Glama

delete-category

Delete a category by providing its ID. Removes the specified category from the PI Dashboard.

Instructions

Delete a category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesCategory ID

Implementation Reference

  • build/index.js:720-739 (registration)
    Registration of the delete-category tool via server.tool() with schema definition and handler function
    // Delete Category tool
    server.tool("delete-category", "Delete a category", {
        id: z.number().describe("Category ID")
    }, async ({ id }) => {
        try {
            await authenticatedRequest(`/categories/${id}`, "DELETE");
            return {
                content: [{
                        type: "text",
                        text: `Category with ID ${id} successfully deleted.`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error deleting category: ${getErrorMessage(error)}` }]
            };
        }
    });
  • Input schema for delete-category: requires a numeric 'id' field
    server.tool("delete-category", "Delete a category", {
        id: z.number().describe("Category ID")
    }, async ({ id }) => {
  • Handler function that performs the DELETE request to /categories/{id} and returns success or error response
    }, async ({ id }) => {
        try {
            await authenticatedRequest(`/categories/${id}`, "DELETE");
            return {
                content: [{
                        type: "text",
                        text: `Category with ID ${id} successfully deleted.`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error deleting category: ${getErrorMessage(error)}` }]
            };
        }
  • The authenticatedRequest helper function that handles all API calls including the DELETE request used by delete-category
    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;
        }
    }
  • The getErrorMessage helper used to safely extract error messages in catch blocks
    const getErrorMessage = (error) => {
        if (error instanceof Error)
            return error.message;
        return String(error);
    };
Behavior2/5

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

Description lacks disclosure of critical behavioral details: irreversible destruction, what happens to objects in the category, permission requirements, error responses. No annotations are provided to compensate.

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

Conciseness3/5

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

Description is extremely brief (one sentence), which is concise but at the expense of completeness. It misses important details like side effects, constraints, or output. Not optimally structured for agent comprehension.

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?

Given no output schema and no annotations, the description fails to explain return values (e.g., success indicator), error conditions, or irreversible side effects. Incomplete for a potentially destructive operation.

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?

Input schema provides full coverage for the one parameter (id) with its description 'Category ID'. The tool description adds no additional meaning beyond what the schema already provides. Baseline 3 applies.

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

Purpose4/5

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

Description 'Delete a category' clearly states verb and resource. It distinguishes from sibling tools like create-category, get-category, update-category by specifying the delete action. However, it lacks scope details like whether it deletes associated objects.

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?

No explicit when-to-use or when-not-to-use guidance. There is no mention of alternatives (e.g., update-category for modifying instead of deleting) or context like prerequisites (e.g., category must exist).

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