Skip to main content
Glama

generate_component

Create React Native components using the Native_MCP server by specifying the component name. Simplifies React Native development with a standardized interface for component generation.

Instructions

Generate a React Native component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
component_nameYes

Implementation Reference

  • The core handler function for the 'generate_component' tool. It takes a 'component_name' parameter and generates a basic React Native functional component as a string.
    def generate_component(params): name = params.get("component_name", "MyComponent") code = f"""import React from 'react';\nimport {{ View, Text }} from 'react-native';\n\nconst {name} = () => (\n <View>\n <Text>{name} works!</Text>\n </View>\n);\n\nexport default {name};\n""" return {"component": code}
  • mcp_server.py:19-45 (registration)
    The load_tools method in ToolManager dynamically discovers tool directories under 'tools/', loads their mcp.json for metadata and entry_point, imports the module, and registers each command (like 'generate_component') by mapping command name to the function in self.commands.
    def load_tools(self): if not os.path.isdir(self.tools_dir): return for tool_name in os.listdir(self.tools_dir): tool_path = os.path.join(self.tools_dir, tool_name) if not os.path.isdir(tool_path): continue mcp_json_path = os.path.join(tool_path, 'mcp.json') if not os.path.isfile(mcp_json_path): continue with open(mcp_json_path, 'r', encoding='utf-8') as f: meta = json.load(f) entry_point = meta.get('entry_point') if not entry_point: continue entry_path = os.path.join(tool_path, entry_point) if not os.path.isfile(entry_path): continue # Dynamically import the tool's entry point spec = importlib.util.spec_from_file_location(f"{tool_name}_module", entry_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) # Register commands for cmd, cmd_meta in meta.get('commands', {}).items(): if hasattr(module, cmd): self.commands[cmd] = (tool_name, getattr(module, cmd))

Other Tools

Related 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/ArkVex/Native_MCP'

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