Labsco
petalframework logo

Petal Components MCP

from petalframework

Adds petal-components-mcp - an MCP server exposing schemas for petal_components, the Shadcn-style Phoenix LiveView component library. Lets AI coding assistants query attrs, slots, defaults, and allowed values for 79 components so they write idiomatic HEEx instead of inventing raw Tailwind soup. Live at https://mcp.petal.build/mcp

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeNeeds API keys

petal-components-mcp

An MCP server that exposes petal_components โ€” the Shadcn-style component library for Phoenix LiveView โ€” to AI coding assistants (Claude Code, Cursor, Windsurf, etc).

Without this, AI agents writing HEEx invent raw Tailwind soup and never reach for pc_* components. With it, the AI gets the full schema for every component on demand โ€” attrs, slots, defaults, allowed values, usage examples โ€” and writes idiomatic petal_components markup by default.

Available tools

  • list_components โ€” every component in the library with a one-line summary
  • get_component โ€” full schema (attrs, slots, defaults, values, docs) + HEEx usage example

Coming soon: search_components (natural-language match) and generate_pattern (composed blocks like form-in-card, modal-with-form, dashboard skeletons).

How it works

The MCP server is a thin TypeScript service that bundles a JSON snapshot of every component in petal_components. The JSON is generated by a Mix task that introspects Phoenix.Component.__components__/0 on every loaded PetalComponents.* module โ€” so the schemas are always in sync with the actual library, no manual duplication.

petal_components (Hex)              petal-components-mcp (this repo)
       โ”‚                                       โ”‚
       โ”‚ mix run extract_schemas.exs           โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ src/schemas.json
                                               โ”‚
                                               โ”‚ tsc
                                               โ–ผ
                                         dist/server.js  โ—„โ”€โ”€ deployed to Fly

Background

This is the artifact for bet 002 โ€” testing whether AI coding assistants become the dominant install/discovery channel for Phoenix UI tooling. See the bet for hypothesis, metrics, and kill criteria.