Petal Components Mcp

io.github.petalframework由 GitHub 帳號 petalframework 發布v0.1.0更新於 Oct 24, 2026

Phoenix LiveView component schemas from petal_components, exposed to AI coding assistants.

已驗證Streamable HTTP可網頁執行知識與記憶開發者工具

概覽

AI 產生的概覽

向 AI 程式助理提供 petal_components 元件結構,讓它寫出正確的 Phoenix LiveView HEEx 標記,而不是手寫 Tailwind。

可以做什麼
  • 列出 petal_components 函式庫中的所有元件與一句話簡介
  • 取得單一元件的完整結構:屬性、插槽、預設值、可用值、文件與 HEEx 用法範例
  • 取得在 Phoenix 專案中安裝 petal_components 的標準步驟
適用情境
當助理撰寫或審閱 Phoenix LiveView 樣板、應使用真實的 petal_components 標籤(例如 button、modal、table、field)時,或在 Phoenix 專案中安裝並驗證 petal_components 時使用。
執行需求
可使用 mcp.petal.build 的遠端 HTTP 端點,或在本機以 stdio 執行 npm 套件 petal-components-mcp(需 Node.js 建置與啟動,可選 PORT)。未宣告驗證、環境變數或標頭。
安裝前請注意
僅唯讀查詢內建的元件結構,不要求憑證,也不寫入資料。結構來自 JSON 快照,可能落後於最新的 petal_components 版本。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Petal Components Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.petalframework%2Fpetal-components-mcp/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "petal-components": {
      "type": "http",
      "url": "https://mcp.petal.build/mcp"
    }
  }
}

README

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.

Install (Claude Code)

sh
claude mcp add petal --transport http https://mcp.petal.build

Then in any Phoenix project, ask the AI to build something. It'll call list_components and get_component to ground its output in real petal_components schemas.

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

Running locally

sh
# Regenerate schemas from the latest petal_components on Hexnpm run extract     # cd scripts/extract && mix deps.get && mix run extract_schemas.exs
# Build and servenpm installnpm run buildPORT=8765 npm start
# Health checkcurl http://localhost:8765/healthz

The extraction is self-contained — scripts/extract/ is a tiny Mix project that pulls petal_components from Hex, introspects every Phoenix.Component.__components__/0, and writes src/schemas.json. No need for a local petal_components clone.

To use a local server with Claude Code:

sh
claude mcp add petal-local --transport http http://localhost:8765/mcp

Deploy (Fly.io)

The MCP server is hosted at mcp.petal.build on Fly.io as a standalone app.

First-time setup

sh
# 1. Create the app (one-time, requires Fly auth)fly apps create petal-components-mcp
# 2. Deployfly deploy --remote-only
# 3. Add the custom domainfly certs add mcp.petal.build

After step 3, Fly prints the DNS records you need. Add a CNAME at the petal.build DNS provider:

mcp.petal.build  CNAME  petal-components-mcp.fly.dev

Then fly certs check mcp.petal.build will go green once propagation hits.

Subsequent deploys

sh
fly deploy --remote-only

Syncing after a new petal_components release on Hex

sh
# 1. Regenerate schemas from the latest petal_components on Hexnpm run extract
# 2. Eyeball the diff (catches surprises before they ship to AI agents worldwide)git diff src/schemas.json | head -50
# 3. Commit and deploygit add src/schemas.jsongit commit -m "chore: sync schemas with petal_components vX.Y.Z"git pushfly deploy --remote-only

The /healthz endpoint reports the bundled version, so you can confirm a deploy went out:

sh
curl https://mcp.petal.build/healthz# {"ok":true,"petal_components_version":"3.2.0","components":79,...}

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.

License

MIT.

來源:README.md,提交 bb1f6d4

工具

3

get_install_instructions

Get the canonical steps for installing petal_components in a Phoenix project. Call this when the user asks to install petal_components, when you are setting up a new Phoenix project that needs UI components, or when verifying an existing installation. Returns step-by-step instructions covering mix.exs, mix deps.get, Tailwind v4 CSS config, and the web module import. Steps are idempotent - safe to follow on a project that is partially configured.

無需輸入參數。

list_components

List every component shipped by petal_components, the shadcn-style component library for Phoenix LiveView. This is the canonical Phoenix UI vocabulary - call it before composing any HEEx so you reach for an existing component instead of hand-rolling Tailwind divs.

無需輸入參數。

get_component

Get the full schema for one petal_components component: attrs, slots, defaults, allowed values, and a working HEEx usage example. Call this every time you are about to write a tag like <.button>, <.modal>, <.table>, or <.field> so the attrs and slots match the real library instead of training-data guesses.

輸入參數name必填

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分