Skip to main content
Glama
iannuttall

Flux UI MCP Server

by iannuttall

get_flux_component_examples

Retrieve implementation examples for Flux UI components to understand usage patterns and accelerate development.

Instructions

Get usage examples for a specific Flux UI component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYesName of the Flux UI component (e.g., "accordion", "button")

Implementation Reference

  • The main handler function for the 'get_flux_component_examples' tool. It validates the component name, checks the cache for component info (including examples), fetches details if needed via fetchComponentDetails, and returns the examples as a success response.
    private async handleGetComponentExamples(args: any) {
      const componentName = this.validateComponentName(args);
    
      try {
        // Use cached details if available, otherwise fetch
         let componentInfo: ComponentInfo | undefined = this.componentCache.get(componentName);
          if (!componentInfo) {
               console.error(`Cache miss for examples: ${componentName}, fetching details...`);
              componentInfo = await this.fetchComponentDetails(componentName);
              this.componentCache.set(componentName, componentInfo); // Cache the fetched details
               console.error(`Cached details while fetching examples for ${componentName}`);
          } else {
               console.error(`Cache hit for examples: ${componentName}`);
          }
    
    
        const examples = componentInfo?.examples || [];
    
        if (!examples || examples.length === 0) {
           console.error(`No examples found for ${componentName} even after fetch.`);
          // Optionally, you could try re-fetching just the examples part if details fetch failed previously
          // const freshExamples = await this.fetchComponentExamplesDirectly(componentName);
          // return this.createSuccessResponse(freshExamples);
            return this.createSuccessResponse([]); // Return empty array if none found
        }
    
        return this.createSuccessResponse(examples);
      } catch (error) {
         console.error(`Error fetching examples for ${componentName}:`, error);
        if (error instanceof McpError) {
            throw error;
        }
        // Pass specific context to error handler
        this.handleAxiosError(error, `fetching examples for component "${componentName}"`);
      }
    }
  • Input schema definition for the 'get_flux_component_examples' tool, specifying the required 'componentName' parameter.
    inputSchema: {
      type: "object",
      properties: {
        componentName: {
          type: "string",
          description: 'Name of the Flux UI component (e.g., "accordion", "button")',
        },
      },
      required: ["componentName"],
    },
  • src/index.ts:124-137 (registration)
    Registration of the 'get_flux_component_examples' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: "get_flux_component_examples",
      description: "Get usage examples for a specific Flux UI component",
      inputSchema: {
        type: "object",
        properties: {
          componentName: {
            type: "string",
            description: 'Name of the Flux UI component (e.g., "accordion", "button")',
          },
        },
        required: ["componentName"],
      },
    },
  • src/index.ts:161-162 (registration)
    Dispatch case in the CallToolRequestSchema switch statement that routes calls to the handleGetComponentExamples handler.
    case "get_flux_component_examples":
      return await this.handleGetComponentExamples(request.params.arguments);
  • Helper function used by fetchComponentDetails to parse HTML and extract code examples from 'pre' elements, associating them with titles from nearby headings.
    private extractExamples($: cheerio.CheerioAPI): ComponentExample[] {
      const examples: ComponentExample[] = [];
      // Look for sections containing code examples. Flux UI seems to use blocks
      // with a 'Code' tab or similar structure.
      // This selector might need adjustment based on the actual structure.
      // Let's try finding 'pre' elements and their preceding headings.
      $("pre").each((_, element) => {
          const codeBlock = $(element);
          const code = codeBlock.text().trim();
    
          if (code) {
              let title = "Code Example";
              let description : string | undefined = undefined;
    
              // Try to find the nearest preceding heading (h2, h3)
              let potentialTitleElement = codeBlock.closest('div[class*="relative"]').prev('h2, h3'); // Adjust selector based on actual structure
              if (!potentialTitleElement.length) {
                 potentialTitleElement = codeBlock.parent().prev('h2, h3'); // Try another common structure
              }
               if (!potentialTitleElement.length) {
                 potentialTitleElement = codeBlock.prev('h2, h3'); // Simplest case
              }
    
    
              if (potentialTitleElement.length) {
                  title = potentialTitleElement.text().trim();
                  description = `Example for ${title}`;
              } else {
                   // Fallback: Try to find a title in the code block structure if tabs are used
                   const tabButton = codeBlock.closest('[role="tabpanel"]')?.attr('aria-labelledby');
                   if (tabButton) {
                      const titleElement = $(`#${tabButton}`);
                      if(titleElement.length && titleElement.text().trim().toLowerCase() === 'code') {
                          // Find the heading associated with this example block
                          let heading = $(`#${tabButton}`).closest('div').prev('h2, h3'); // Adjust based on DOM
                          if(heading.length) title = heading.text().trim();
                      }
                   }
              }
    
    
              examples.push({ title, code, description });
          }
      });
    
      // Deduplicate examples based on code content if necessary (simple check)
      const uniqueExamples = Array.from(new Map(examples.map(e => [e.code, e])).values());
    
       console.error(`Found ${uniqueExamples.length} examples.`);
      return uniqueExamples;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get usage examples') but doesn't describe what the tool returns (e.g., structured data, text, or error handling), whether it's idempotent or has side effects, or any limitations (e.g., rate limits or authentication needs). For a tool with no annotation coverage, this is a significant gap in 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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Get usage examples'), making it easy to parse. There's no redundancy or fluff, earning a high score for conciseness.

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 the lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain what the return value looks like (e.g., a list of examples, markdown text, or error messages), behavioral traits like idempotency, or how it integrates with sibling tools. For a tool with no structured output information, the description should provide more context to compensate.

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?

The input schema has 100% description coverage, with the parameter 'componentName' clearly documented as the name of a Flux UI component (e.g., 'accordion', 'button'). The description adds no additional semantic context beyond this, such as valid component names or example formats. Since the schema does the heavy lifting, a baseline score of 3 is appropriate, but the description doesn't compensate for any gaps (though none exist here).

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 verb ('Get') and resource ('usage examples for a specific Flux UI component'), making the purpose immediately understandable. It distinguishes from sibling tools like 'get_flux_component_details' (which likely provides metadata) and 'list_flux_components' (which lists components rather than examples). However, it doesn't specify the format or scope of examples (e.g., code snippets, screenshots, or documentation excerpts), leaving some ambiguity.

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. It doesn't mention prerequisites (e.g., needing a valid component name), compare it to siblings like 'search_flux_components' for broader queries, or indicate scenarios where examples are useful (e.g., learning, troubleshooting). This lack of context makes it harder for an agent to decide when this tool is appropriate.

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/iannuttall/flux-ui-mcp'

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