Skip to main content
Glama

21st_magic_component_inspiration

Discover and fetch JSON data for UI components from 21st.dev to inspire or integrate into your codebase. Use this tool to search for matching components, preview snippets, and streamline UI development.

Instructions

"Use this tool when the user wants to see component, get inspiration, or /21st fetch data and previews from 21st.dev. This tool returns the JSON data of matching components without generating new code. 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

TableJSON Schema
NameRequiredDescriptionDefault
messageYesFull users message
searchQueryYesSearch 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

Implementation Reference

  • The async execute method implements the tool's core logic: sends user message and search query to the 21st.dev API (/api/fetch-ui) via twentyFirstClient and returns the fetched UI component text as MCP content.
    async execute({ message, searchQuery }: z.infer<typeof this.schema>) { try { const { data } = await twentyFirstClient.post<FetchUiResponse>( "/api/fetch-ui", { message, searchQuery, } ); return { content: [ { type: "text" as const, text: data.text, }, ], }; } catch (error) { console.error("Error executing tool", error); throw error; } }
  • Zod input schema defining 'message' (full user message) and 'searchQuery' (concise 2-4 word search phrase for UI components on 21st.dev).
    schema = z.object({ message: z.string().describe("Full users message"), searchQuery: z .string() .describe( "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:13-17 (registration)
    Registers the FetchUiTool ("21st_magic_component_inspiration") alongside other tools with the MCP server instance.
    // Register tools new CreateUiTool().register(server); new LogoSearchTool().register(server); new FetchUiTool().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