get_component
Retrieve the full schema for a specified petal_components component, including attrs, slots, defaults, allowed values, and a HEEx usage example to validate Phoenix LiveView markup.
Instructions
Get the full schema for a single petal_components component — attrs, slots, defaults, allowed values, and a HEEx usage example. Call this any time you're about to write a Phoenix LiveView component reference like <.pc_button> or <.input>, to ensure the attrs and slots match the real library.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Component function name (e.g. 'button', 'modal', 'input'). Get the full list via list_components. |
Implementation Reference
- src/mcp.ts:79-98 (handler)The request handler for the 'get_component' tool. It parses the component name from input, calls getComponent() from schemas, and returns the rendered schema or an error if not found.
if (name === "get_component") { const { name: componentName } = GetComponentInput.parse(args); const component = getComponent(componentName); if (!component) { return { content: [ { type: "text", text: `No component named "${componentName}" exists in petal_components v${schemas.version}. Call list_components to see what's available.`, }, ], isError: true, }; } return { content: [{ type: "text", text: renderComponent(component) }], }; } - src/schemas.ts:43-45 (helper)The getComponent() helper that looks up a component by name in the schemas JSON data and returns the Component or null.
export function getComponent(name: string): Component | null { return schemas.components.find((c) => c.name === name) ?? null; } - src/mcp.ts:39-55 (registration)Tool registration/definition for 'get_component' in the ListToolsRequestSchema handler, including its name, description, and inputSchema.
{ name: "get_component", description: "Get the full schema for a single petal_components component — attrs, slots, defaults, allowed values, and a HEEx usage example. Call this any time you're about to write a Phoenix LiveView component reference like <.pc_button> or <.input>, to ensure the attrs and slots match the real library.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Component function name (e.g. 'button', 'modal', 'input'). Get the full list via list_components.", }, }, required: ["name"], additionalProperties: false, }, }, - src/mcp.ts:59-59 (schema)Zod schema (GetComponentInput) used to validate the 'name' argument for the get_component tool handler.
const GetComponentInput = z.object({ name: z.string() });