Skip to main content
Glama
lallen30

BluestoneApps MCP Remote Server

by lallen30

get_component_example

Retrieve React Native component examples from BluestoneApps coding standards to implement UI elements correctly.

Instructions

Get a React Native component example

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
component_nameYesComponent Name

Implementation Reference

  • Handler function that implements the get_component_example tool logic: validates input, loads exact or fuzzy-matched component example code from resources/code-examples/react-native/components using getExampleContent and findClosestMatch helpers, returns as MCP text content or error.
      async ({ component_name }) => {
        if (!component_name) {
          return {
            content: [
              {
                type: "text",
                text: "Component name not specified",
              },
            ],
          };
        }
        
        try {
          // First try exact match
          const result = getExampleContent("components", component_name);
          
          if (result.error) {
            // Try to find by fuzzy match
            const componentsDir = path.join(CODE_EXAMPLES_DIR, "react-native", "components");
            const closestMatch = findClosestMatch(componentsDir, component_name);
            
            if (closestMatch) {
              const fuzzyResult = getExampleContent("components", closestMatch);
              return {
                content: [
                  {
                    type: "text",
                    text: fuzzyResult.content?.[0] ?? fuzzyResult.error ?? "Error: No content available",
                  },
                ],
              };
            } else {
              return {
                content: [
                  {
                    type: "text",
                    text: `Component ${component_name} not found`,
                  },
                ],
              };
            }
          }
          
          return {
            content: [
              {
                type: "text",
                text: result.content?.[0] ?? result.error ?? "Error: No content available",
              },
            ],
          };
        } catch (err) {
          console.error(`Error getting component example ${component_name}:`, err);
          return {
            content: [
              {
                type: "text",
                text: `Error getting component example: ${err}`,
              },
            ],
          };
        }
      },
    );
  • Zod input schema defining the required 'component_name' string parameter.
    {
      component_name: z.string().describe("Component Name"),
    },
  • src/index.ts:226-296 (registration)
    MCP tool registration using McpServer.tool(), specifying name, description, schema, and inline handler function.
    server.tool(
      "get_component_example",
      "Get a React Native component example",
      {
        component_name: z.string().describe("Component Name"),
      },
      async ({ component_name }) => {
        if (!component_name) {
          return {
            content: [
              {
                type: "text",
                text: "Component name not specified",
              },
            ],
          };
        }
        
        try {
          // First try exact match
          const result = getExampleContent("components", component_name);
          
          if (result.error) {
            // Try to find by fuzzy match
            const componentsDir = path.join(CODE_EXAMPLES_DIR, "react-native", "components");
            const closestMatch = findClosestMatch(componentsDir, component_name);
            
            if (closestMatch) {
              const fuzzyResult = getExampleContent("components", closestMatch);
              return {
                content: [
                  {
                    type: "text",
                    text: fuzzyResult.content?.[0] ?? fuzzyResult.error ?? "Error: No content available",
                  },
                ],
              };
            } else {
              return {
                content: [
                  {
                    type: "text",
                    text: `Component ${component_name} not found`,
                  },
                ],
              };
            }
          }
          
          return {
            content: [
              {
                type: "text",
                text: result.content?.[0] ?? result.error ?? "Error: No content available",
              },
            ],
          };
        } catch (err) {
          console.error(`Error getting component example ${component_name}:`, err);
          return {
            content: [
              {
                type: "text",
                text: `Error getting component example: ${err}`,
              },
            ],
          };
        }
      },
    );
  • Core helper function used by the handler to load example code file content from the react-native subcategory directory using glob-based search.
    function getExampleContent(subcategory: string, filename: string): { content?: string[]; path?: string; error?: string } {
      const searchDir = path.join(CODE_EXAMPLES_DIR, "react-native", subcategory);
      
      const filePath = findFileInSubdirectories(searchDir, filename);
      
      if (!filePath || !fs.existsSync(filePath)) {
        return { error: `Example ${filename} not found` };
      }
      
      try {
        const content = fs.readFileSync(filePath, 'utf8');
        return {
          content: [content],
          path: path.relative(BASE_DIR, filePath)
        };
      } catch (err) {
        console.error(`Error reading example ${filename}:`, err);
        return { error: `Error reading example ${filename}` };
      }
    }
  • Helper function for fuzzy matching: finds the first file in directory whose basename (no ext) contains the search name (case-insensitive).
    function findClosestMatch(directory: string, searchName: string, extensions: string[] = ['.js', '.jsx', '.ts', '.tsx']) {
      if (!fs.existsSync(directory)) return null;
      
      let closestMatch = null;
      
      for (const ext of extensions) {
        const files = glob.sync(`${directory}/**/*${ext}`);
        
        for (const filePath of files) {
          const fileName = path.basename(filePath);
          const fileNameNoExt = path.basename(fileName, path.extname(fileName));
          
          if (fileNameNoExt.toLowerCase().includes(searchName.toLowerCase())) {
            closestMatch = fileNameNoExt;
            break;
          }
        }
        
        if (closestMatch) break;
      }
      
      return closestMatch;
    }
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 what the tool does but doesn't describe how it behaves: e.g., what format the example returns (code snippet, documentation, etc.), whether it's read-only (implied by 'Get' but not explicit), error handling, or any rate limits. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operation.

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, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying essential information without redundancy or fluff.

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 complexity (a tool fetching examples), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., code examples, usage instructions), potential errors, or how it interacts with siblings. For a tool in a set with multiple similar 'get example' tools, more context is needed to guide effective use.

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 single parameter 'component_name' documented as 'Component Name'. The description doesn't add any meaning beyond this—it doesn't clarify what constitutes a valid component name (e.g., specific React Native components like 'Button' or 'View'), examples, or constraints. With high schema coverage, the baseline is 3, as the schema does the heavy lifting.

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 ('a React Native component example'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'get_hook_example' or 'get_screen_example', which suggests similar 'get example' patterns but for different resource types. A perfect score would explicitly differentiate between these similar tools.

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. With siblings like 'get_hook_example' and 'get_screen_example', it's unclear whether this is for UI components specifically or how it differs from other example-fetching tools. There's no mention of prerequisites, constraints, or typical use cases.

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/lallen30/mcp-remote-server'

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