Skip to main content
Glama

21st_magic_component_builder

Generate React UI component snippets from user requests—e.g., buttons, forms, or tables. Use this tool to quickly create component code, then manually integrate snippets into your codebase for tailored UI development.

Instructions

"Use this tool when the user requests a new UI component—e.g., mentions /ui, /21 /21st, or asks for a button, input, dialog, table, form, banner, card, or other React component. This tool ONLY returns the text snippet for that UI component. After calling this tool, you must edit or add files to integrate the snippet into the codebase."

Input Schema

NameRequiredDescriptionDefault
messageYesFull users message
searchQueryYesGenerate a search query for 21st.dev (library for searching UI components) to find a UI component that matches the user's message. Must be a two-four words max or phrase

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "message": { "description": "Full users message", "type": "string" }, "searchQuery": { "description": "Generate a search query for 21st.dev (library for searching UI components) to find a UI component that matches the user's message. Must be a two-four words max or phrase", "type": "string" } }, "required": [ "message", "searchQuery" ], "type": "object" }

Implementation Reference

  • Implements the core logic of the '21st_magic_component_builder' tool by sending a POST request to '/api/create-ui' with the user's message and search query, then returning the generated UI component text.
    async execute({ message, searchQuery }: z.infer<typeof this.schema>) { try { const { data } = await twentyFirstClient.post<CreateUiResponse>( "/api/create-ui", { message, searchQuery, } ); return { content: [ { type: "text" as const, text: data.text, }, ], }; } catch (error) { console.error("Error executing tool", error); throw error; } }
  • Defines the input schema using Zod for the tool's parameters: 'message' (user's full message) and 'searchQuery' (query for 21st.dev UI components).
    schema = z.object({ message: z.string().describe("Full users message"), searchQuery: z .string() .describe( "Generate a search query for 21st.dev (library for searching UI components) to find a UI component that matches the user's message. Must be a two-four words max or phrase" ), });
  • src/index.ts:14-14 (registration)
    Registers the CreateUiTool instance with the MCP server.
    new CreateUiTool().register(server);

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/oyasimi1209/magic-mcp'

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