Skip to main content
Glama

find_by_attribute

Locate components by attribute name, such as disabled, color, or size, using Modus Web Components documentation. Quickly find the right UI element for your design system.

Instructions

Find components that have a specific attribute or property.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attributeYesThe attribute name to search for (e.g., "disabled", "color", "size")

Implementation Reference

  • The private async method `findByAttribute()` that executes the tool logic. It iterates over loaded component docs, searches for lines containing the attribute name in backtick notation (e.g., `disabled`), and returns context snippets of components that have that attribute.
    private async findByAttribute(attribute: string): Promise<any> {
      const normalizedAttribute = attribute.toLowerCase();
      const results: Array<{ component: string; context: string }> = [];
    
      for (const doc of this.docs) {
        const lines = doc.content.split("\n");
    
        for (let i = 0; i < lines.length; i++) {
          const line = lines[i];
          const lowerLine = line.toLowerCase();
    
          // Look for attribute definitions like: - **`disabled`**
          if (
            lowerLine.includes(`\`${normalizedAttribute}\``) &&
            (line.startsWith("-") || line.startsWith("•"))
          ) {
            // Get context - the attribute definition and its properties
            const contextStart = i;
            let contextEnd = i + 1;
    
            // Include lines until we hit another attribute or empty line
            while (
              contextEnd < lines.length &&
              !lines[contextEnd].match(/^-\s+\*\*`/) &&
              contextEnd < i + 10
            ) {
              if (lines[contextEnd].trim() === "") {
                break;
              }
              contextEnd++;
            }
    
            const context = lines.slice(contextStart, contextEnd).join("\n");
    
            results.push({
              component: doc.component,
              context: context.trim(),
            });
            break;
          }
        }
      }
    
      if (results.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: `No components found with attribute "${attribute}".`,
            },
          ],
        };
      }
    
      const resultText = results
        .map((r) => `**${r.component}**\n\`\`\`\n${r.context}\n\`\`\`\n`)
        .join("\n");
    
      return {
        content: [
          {
            type: "text",
            text: `Found ${results.length} component(s) with attribute "${attribute}":\n\n${resultText}`,
          },
        ],
      };
    }
  • src/index.ts:206-221 (registration)
    The tool registration within the `ListToolsRequestSchema` handler. Defines the tool name `find_by_attribute`, its description, and input schema requiring an `attribute` string parameter.
    {
      name: "find_by_attribute",
      description:
        "Find components that have a specific attribute or property.",
      inputSchema: {
        type: "object",
        properties: {
          attribute: {
            type: "string",
            description:
              'The attribute name to search for (e.g., "disabled", "color", "size")',
          },
        },
        required: ["attribute"],
      },
    },
  • The switch case in `CallToolRequestSchema` handler that routes the `find_by_attribute` tool name to the `findByAttribute()` method.
    case "find_by_attribute":
      return await this.findByAttribute(
        (args?.attribute as string) || ""
      );
Behavior2/5

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

No annotations provided; description does not disclose behavioral traits such as case sensitivity, match type, performance, or return format. Minimally informative for a search operation.

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

Conciseness4/5

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

Single sentence, no wasted words. Efficient but could include more context without losing brevity, e.g., scope or return type.

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 simple input, the description lacks details on return values, pagination, or limitations. Incomplete for a search tool with no annotations.

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 has 100% coverage with a description for 'attribute'. The description adds nothing beyond 'specific attribute or property', which is already implied. Baseline score is appropriate.

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?

The description clearly states the tool finds components by attribute, distinguishing it from siblings like search_components (likely name-based) and list_all_components. However, 'attribute or property' is somewhat vague; could specify the scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use vs alternatives. Implied usage when searching by attribute, but no exclusions or comparison to sibling tools like search_components.

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/julianoczkowski/mcp-modus'

If you have feedback or need assistance with the MCP directory API, please join our Discord server