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 分