list-ui
Fetch JSON data and previews of UI components from buouui.com. Use this tool to search and retrieve matching components without generating new code, then display the data and website page in your UI.
Instructions
"Use this tool when the user wants to see buouui.com component, or /buou fetch data and previews from buouui.com. 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 need to display the data in the UI, and finally you need to show the website page of the buouui.com."
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | Full users message | |
| searchQuery | Yes | Search query for buouui.com(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
- src/tools/list-ui.ts:29-64 (handler)The execute method implements the core logic of the 'list-ui' tool. It sends a POST request to '/api/list' with the user's message and search query, retrieves UI component data from buouui.com, and returns the JSON-stringified response or an error message.async execute({ message, searchQuery }: z.infer<typeof this.schema>) { try { const { data } = await twentyFirstClient.post<FetchUiResponse>( "/api/list", { message, searchQuery, } ); return { content: [ { type: "text" as const, text: JSON.stringify(data), }, ], }; } catch (error) { console.error("Error executing tool:", error); // 返回更详细的错误信息 return { content: [ { type: "text" as const, text: `Error: ${ error instanceof Error ? error.message : "Failed to generate UI component" }. Please try again.`, }, ], }; } }
- src/tools/list-ui.ts:20-27 (schema)Zod schema defining the input parameters for the tool: 'message' (full user message) and 'searchQuery' (short phrase for searching UI components).schema = z.object({ message: z.string().describe("Full users message"), searchQuery: z .string() .describe( "Search query for buouui.com(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 ListUiTool instance with the MCP server, making the 'list-ui' tool available.new ListUiTool().register(server);
- src/index.ts:5-5 (registration)Imports the ListUiTool class for registration.import { ListUiTool } from "./tools/list-ui";
- src/tools/list-ui.ts:16-18 (helper)Class definition extending BaseTool, setting the tool name 'list-ui' and its description.export class ListUiTool extends BaseTool { name = FETCH_UI_TOOL_NAME; description = FETCH_UI_TOOL_DESCRIPTION;