Skip to main content
Glama

get-filterable-attributes

Retrieve filterable attributes for a given entity type (chart or category) to enable precise data filtering.

Instructions

Get the list of attributes that can be used for filtering by examining a sample entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityTypeYesType of entity to examine (chart or category)

Implementation Reference

  • The full handler function for the 'get-filterable-attributes' tool. It takes an entityType ('chart' or 'category'), fetches a sample entity from the API, extracts its attributes (name, type, example value, and available operators based on type), and returns them as filterable attributes with example usage.
    server.tool("get-filterable-attributes", "Get the list of attributes that can be used for filtering by examining a sample entity", {
        entityType: z.enum(["chart", "category"]).describe("Type of entity to examine (chart or category)")
    }, async ({ entityType }) => {
        try {
            if (!apiUrlSet || !authToken) {
                return {
                    isError: true,
                    content: [{
                            type: "text",
                            text: "Please set API URL and authenticate before using this tool."
                        }]
                };
            }
            let endpoint = "";
            // Get a sample entity
            if (entityType === "chart") {
                endpoint = "/charts";
            }
            else if (entityType === "category") {
                endpoint = "/categories";
            }
            // Get all entities (since pagination may not be supported)
            const listResponse = await authenticatedRequest(endpoint, "GET");
            if (listResponse &&
                typeof listResponse === 'object' &&
                'content' in listResponse &&
                Array.isArray(listResponse.content) &&
                listResponse.content.length > 0) {
                // Just use the first entity as our sample
                const sampleEntity = listResponse.content[0];
                // Extract the attributes from the sample entity
                const attributes = Object.keys(sampleEntity).map(key => {
                    const value = sampleEntity[key];
                    const type = typeof value;
                    // Determine which operators are suitable based on the value type
                    let availableOperators = [];
                    if (type === "string") {
                        // Prioritize 'like' for string fields since it's case-insensitive
                        availableOperators = ["like", "nlike", "eq", "ne"];
                    }
                    else if (type === "number") {
                        availableOperators = ["eq", "ne", "gt", "lt", "ge", "le"];
                    }
                    else if (type === "boolean") {
                        availableOperators = ["eq", "ne"];
                    }
                    return {
                        name: key,
                        type: type,
                        example: value !== null && value !== undefined ? String(value).substring(0, 30) : "null", // Show a sample value (truncated)
                        operators: availableOperators
                    };
                });
                // Find a string field for the example if possible
                const stringField = attributes.find(attr => attr.type === "string" && attr.example && attr.example !== "null");
                let exampleFilter = "";
                if (stringField) {
                    exampleFilter = `${stringField.name}(like)=${stringField.example}`;
                }
                else if (attributes.length > 0) {
                    const firstAttr = attributes[0];
                    exampleFilter = `${firstAttr.name}(${firstAttr.operators[0]})=${firstAttr.example}`;
                }
                let exampleMultipleFilter = "";
                if (attributes.length > 1) {
                    const secondAttr = attributes[1];
                    exampleMultipleFilter = `${exampleFilter}&${secondAttr.name}(${secondAttr.operators[0]})=${secondAttr.example}`;
                }
                return {
                    content: [{
                            type: "text",
                            text: `Filterable attributes for ${entityType}:\n${JSON.stringify(attributes, null, 2)}\n\n` +
                                `Example filter usage: '${exampleFilter}'\n\n` +
                                `Example with multiple filters: '${exampleMultipleFilter || "Not enough attributes for multiple filter example"}'\n\n` +
                                `Note: For text fields, the 'like' operator is recommended as it performs case-insensitive substring matching.`
                        }]
                };
            }
            else {
                return {
                    content: [{
                            type: "text",
                            text: `No ${entityType} entities found to analyze. Please ensure there is at least one ${entityType} in the system.`
                        }]
                };
            }
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error fetching ${entityType} attributes: ${getErrorMessage(error)}` }]
            };
        }
    });
  • build/index.js:166-168 (registration)
    Registration of the 'get-filterable-attributes' tool on the MCP server via server.tool(), with zod schema defining the input parameter entityType.
    server.tool("get-filterable-attributes", "Get the list of attributes that can be used for filtering by examining a sample entity", {
        entityType: z.enum(["chart", "category"]).describe("Type of entity to examine (chart or category)")
    }, async ({ entityType }) => {
  • Zod input schema for the tool. Defines a single required parameter 'entityType' which must be either 'chart' or 'category'.
    entityType: z.enum(["chart", "category"]).describe("Type of entity to examine (chart or category)")
Behavior2/5

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

With no annotations, the description must disclose behavioral traits. It mentions 'by examining a sample entity,' implying a read operation, but does not explicitly state that it is read-only, whether it requires authentication, or if it has any side effects. This lack of detail reduces transparency.

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 sentence that conveys the essential information without any superfluous words. It is front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and no output schema, the description gives the core purpose but does not specify the return format or any behavioral details like error handling. It is minimally adequate.

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 coverage is 100% with the entityType parameter described. The tool description adds no additional meaning beyond the schema's own description. Baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the tool retrieves a list of attributes usable for filtering, specifying the method (examining a sample entity). This distinguishes it from sibling tools like list-charts or update-category, which have different purposes.

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, such as before constructing filter queries or after selecting an entity type. No context on prerequisites or conditions for use is given.

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