@hanzo/ui 4.5.0 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MCP-INSTRUCTIONS.md +73 -0
- package/README-MCP.md +175 -0
- package/bin/cli.js +100 -0
- package/bin/create-registry.js +108 -0
- package/bin/mcp.js +403 -0
- package/bin/npx-registry-mcp.js +15 -0
- package/bin/registry-mcp-wrapper.sh +19 -0
- package/bin/registry-mcp.js +100 -0
- package/bin/start-mcp-server.sh +22 -0
- package/bin/test-mcp.sh +52 -0
- package/bin/update-registry.js +196 -0
- package/blocks/components/screenful-block/index.tsx +2 -0
- package/dist/blocks/components/accordian-block.d.ts +4 -0
- package/dist/blocks/components/accordian-block.jsx +25 -0
- package/dist/blocks/components/block-component-props.d.ts +7 -0
- package/dist/blocks/components/block-component-props.js +1 -0
- package/dist/blocks/components/bullet-cards-block.d.ts +4 -0
- package/dist/blocks/components/bullet-cards-block.jsx +25 -0
- package/dist/blocks/components/card-block/index.d.ts +6 -0
- package/dist/blocks/components/card-block/index.jsx +87 -0
- package/dist/blocks/components/card-block/link-out-button.d.ts +6 -0
- package/dist/blocks/components/card-block/link-out-button.jsx +4 -0
- package/dist/blocks/components/card-block/util.d.ts +4 -0
- package/dist/blocks/components/card-block/util.js +6 -0
- package/dist/blocks/components/carte-blanche-block/index.d.ts +4 -0
- package/dist/blocks/components/carte-blanche-block/index.jsx +82 -0
- package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +10 -0
- package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +23 -0
- package/dist/blocks/components/content.d.ts +10 -0
- package/dist/blocks/components/content.jsx +47 -0
- package/dist/blocks/components/cta-block.d.ts +12 -0
- package/dist/blocks/components/cta-block.jsx +69 -0
- package/dist/blocks/components/enh-heading-block.d.ts +7 -0
- package/dist/blocks/components/enh-heading-block.jsx +142 -0
- package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +5 -0
- package/dist/blocks/components/grid-block/grid-block-mutator.js +1 -0
- package/dist/blocks/components/grid-block/index.d.ts +9 -0
- package/dist/blocks/components/grid-block/index.jsx +56 -0
- package/dist/blocks/components/grid-block/mutator-registry.d.ts +3 -0
- package/dist/blocks/components/grid-block/mutator-registry.js +5 -0
- package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +3 -0
- package/dist/blocks/components/grid-block/table-borders.mutator.js +36 -0
- package/dist/blocks/components/group-block.d.ts +7 -0
- package/dist/blocks/components/group-block.jsx +61 -0
- package/dist/blocks/components/heading-block.d.ts +4 -0
- package/dist/blocks/components/heading-block.jsx +99 -0
- package/dist/blocks/components/image-block.d.ts +7 -0
- package/dist/blocks/components/image-block.jsx +69 -0
- package/dist/blocks/components/index.d.ts +14 -0
- package/dist/blocks/components/index.js +13 -0
- package/dist/blocks/components/screenful-block/content.d.ts +8 -0
- package/dist/blocks/components/screenful-block/content.jsx +71 -0
- package/dist/blocks/components/screenful-block/index.d.ts +12 -0
- package/dist/blocks/components/screenful-block/index.jsx +57 -0
- package/dist/blocks/components/screenful-block/poster-background.d.ts +7 -0
- package/dist/blocks/components/screenful-block/poster-background.jsx +14 -0
- package/dist/blocks/components/screenful-block/video-background.d.ts +8 -0
- package/dist/blocks/components/screenful-block/video-background.jsx +20 -0
- package/dist/blocks/components/space-block.d.ts +4 -0
- package/dist/blocks/components/space-block.jsx +42 -0
- package/dist/blocks/components/video-block.d.ts +9 -0
- package/dist/blocks/components/video-block.jsx +83 -0
- package/dist/blocks/def/accordian-block.d.ts +10 -0
- package/dist/blocks/def/accordian-block.js +2 -0
- package/dist/blocks/def/block.d.ts +4 -0
- package/dist/blocks/def/block.js +1 -0
- package/dist/blocks/def/bullet-cards-block.d.ts +17 -0
- package/dist/blocks/def/bullet-cards-block.js +1 -0
- package/dist/blocks/def/card-block.d.ts +17 -0
- package/dist/blocks/def/card-block.js +2 -0
- package/dist/blocks/def/carte-blanche-block.d.ts +12 -0
- package/dist/blocks/def/carte-blanche-block.js +1 -0
- package/dist/blocks/def/cta-block.d.ts +8 -0
- package/dist/blocks/def/cta-block.js +1 -0
- package/dist/blocks/def/element-block.d.ts +7 -0
- package/dist/blocks/def/element-block.js +2 -0
- package/dist/blocks/def/enh-heading-block.d.ts +22 -0
- package/dist/blocks/def/enh-heading-block.js +1 -0
- package/dist/blocks/def/grid-block.d.ts +12 -0
- package/dist/blocks/def/grid-block.js +1 -0
- package/dist/blocks/def/group-block.d.ts +7 -0
- package/dist/blocks/def/group-block.js +1 -0
- package/dist/blocks/def/heading-block.d.ts +11 -0
- package/dist/blocks/def/heading-block.js +1 -0
- package/dist/blocks/def/image-block.d.ts +26 -0
- package/dist/blocks/def/image-block.js +1 -0
- package/dist/blocks/def/index.d.ts +17 -0
- package/dist/blocks/def/index.js +2 -0
- package/dist/blocks/def/screenful-block.d.ts +41 -0
- package/dist/blocks/def/screenful-block.js +1 -0
- package/dist/blocks/def/space-block.d.ts +47 -0
- package/dist/blocks/def/space-block.js +8 -0
- package/dist/blocks/def/video-block.d.ts +5 -0
- package/dist/blocks/def/video-block.js +1 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.js +2 -0
- package/dist/mcp/enhanced-server.d.ts +29 -0
- package/dist/mcp/enhanced-server.js +1128 -0
- package/dist/mcp/index.d.ts +28 -0
- package/dist/mcp/index.js +436 -0
- package/dist/primitives/accordion.d.ts +10 -0
- package/dist/primitives/accordion.jsx +21 -0
- package/dist/primitives/action-button.d.ts +9 -0
- package/dist/primitives/action-button.jsx +16 -0
- package/dist/primitives/apply-typography.d.ts +7 -0
- package/dist/primitives/apply-typography.jsx +38 -0
- package/dist/primitives/aspect-ratio.d.ts +3 -0
- package/dist/primitives/aspect-ratio.jsx +4 -0
- package/dist/primitives/avatar.d.ts +6 -0
- package/dist/primitives/avatar.jsx +11 -0
- package/dist/primitives/badge.d.ts +9 -0
- package/dist/primitives/badge.jsx +18 -0
- package/dist/primitives/breadcrumb.d.ts +19 -0
- package/dist/primitives/breadcrumb.jsx +27 -0
- package/dist/primitives/breakpoint-indicator.d.ts +3 -0
- package/dist/primitives/breakpoint-indicator.jsx +14 -0
- package/dist/primitives/button.d.ts +12 -0
- package/dist/primitives/button.jsx +55 -0
- package/dist/primitives/calendar.d.ts +8 -0
- package/dist/primitives/calendar.jsx +40 -0
- package/dist/primitives/card.d.ts +8 -0
- package/dist/primitives/card.jsx +18 -0
- package/dist/primitives/carousel.d.ts +18 -0
- package/dist/primitives/carousel.jsx +106 -0
- package/dist/primitives/checkbox.d.ts +4 -0
- package/dist/primitives/checkbox.jsx +15 -0
- package/dist/primitives/combobox.d.ts +41 -0
- package/dist/primitives/combobox.jsx +77 -0
- package/dist/primitives/command.d.ts +17 -0
- package/dist/primitives/command.jsx +38 -0
- package/dist/primitives/context-menu.d.ts +27 -0
- package/dist/primitives/context-menu.jsx +57 -0
- package/dist/primitives/dialog-video-controller.d.ts +3 -0
- package/dist/primitives/dialog-video-controller.jsx +24 -0
- package/dist/primitives/dialog.d.ts +28 -0
- package/dist/primitives/dialog.jsx +37 -0
- package/dist/primitives/drawer.d.ts +29 -0
- package/dist/primitives/drawer.jsx +34 -0
- package/dist/primitives/form.d.ts +12 -0
- package/dist/primitives/form.jsx +69 -0
- package/dist/primitives/icons/github.d.ts +4 -0
- package/dist/primitives/icons/github.jsx +6 -0
- package/dist/primitives/icons/index.d.ts +4 -0
- package/dist/primitives/icons/index.js +4 -0
- package/dist/primitives/icons/youtube-logo.d.ts +4 -0
- package/dist/primitives/icons/youtube-logo.jsx +39 -0
- package/dist/primitives/index-common.d.ts +47 -0
- package/dist/primitives/index-common.js +46 -0
- package/dist/primitives/index-next.d.ts +2 -0
- package/dist/primitives/index-next.js +2 -0
- package/dist/primitives/input-otp.d.ts +7 -0
- package/dist/primitives/input-otp.jsx +24 -0
- package/dist/primitives/input.d.ts +5 -0
- package/dist/primitives/input.jsx +11 -0
- package/dist/primitives/label.d.ts +5 -0
- package/dist/primitives/label.jsx +11 -0
- package/dist/primitives/list-adaptor.d.ts +9 -0
- package/dist/primitives/list-adaptor.js +1 -0
- package/dist/primitives/list-box.d.ts +10 -0
- package/dist/primitives/list-box.jsx +14 -0
- package/dist/primitives/loading-spinner.d.ts +5 -0
- package/dist/primitives/loading-spinner.jsx +8 -0
- package/dist/primitives/navigation-menu.d.ts +12 -0
- package/dist/primitives/navigation-menu.jsx +38 -0
- package/dist/primitives/next/image.d.ts +11 -0
- package/dist/primitives/next/image.jsx +42 -0
- package/dist/primitives/next/index.d.ts +7 -0
- package/dist/primitives/next/index.js +7 -0
- package/dist/primitives/next/inline-icon.d.ts +13 -0
- package/dist/primitives/next/inline-icon.jsx +15 -0
- package/dist/primitives/next/link-element.d.ts +23 -0
- package/dist/primitives/next/link-element.jsx +56 -0
- package/dist/primitives/next/mdx-link.d.ts +3 -0
- package/dist/primitives/next/mdx-link.jsx +12 -0
- package/dist/primitives/next/media-stack.d.ts +8 -0
- package/dist/primitives/next/media-stack.jsx +28 -0
- package/dist/primitives/next/nav-items.d.ts +10 -0
- package/dist/primitives/next/nav-items.jsx +24 -0
- package/dist/primitives/next/youtube-embed.d.ts +11 -0
- package/dist/primitives/next/youtube-embed.jsx +23 -0
- package/dist/primitives/popover.d.ts +9 -0
- package/dist/primitives/popover.jsx +18 -0
- package/dist/primitives/progress.d.ts +4 -0
- package/dist/primitives/progress.jsx +9 -0
- package/dist/primitives/radio-group.d.ts +7 -0
- package/dist/primitives/radio-group.jsx +18 -0
- package/dist/primitives/scroll-area.d.ts +5 -0
- package/dist/primitives/scroll-area.jsx +19 -0
- package/dist/primitives/select.d.ts +13 -0
- package/dist/primitives/select.jsx +62 -0
- package/dist/primitives/separator.d.ts +4 -0
- package/dist/primitives/separator.jsx +7 -0
- package/dist/primitives/sheet.d.ts +30 -0
- package/dist/primitives/sheet.jsx +56 -0
- package/dist/primitives/skeleton.d.ts +4 -0
- package/dist/primitives/skeleton.jsx +3 -0
- package/dist/primitives/slider.d.ts +9 -0
- package/dist/primitives/slider.jsx +30 -0
- package/dist/primitives/sonner.d.ts +5 -0
- package/dist/primitives/sonner.jsx +16 -0
- package/dist/primitives/step-indicator.d.ts +9 -0
- package/dist/primitives/step-indicator.jsx +23 -0
- package/dist/primitives/switch.d.ts +6 -0
- package/dist/primitives/switch.jsx +14 -0
- package/dist/primitives/table.d.ts +10 -0
- package/dist/primitives/table.jsx +21 -0
- package/dist/primitives/tabs.d.ts +7 -0
- package/dist/primitives/tabs.jsx +18 -0
- package/dist/primitives/text-area.d.ts +5 -0
- package/dist/primitives/text-area.jsx +9 -0
- package/dist/primitives/toggle-group.d.ts +14 -0
- package/dist/primitives/toggle-group.jsx +28 -0
- package/dist/primitives/toggle.d.ts +14 -0
- package/dist/primitives/toggle.jsx +52 -0
- package/dist/primitives/tooltip.d.ts +11 -0
- package/dist/primitives/tooltip.jsx +18 -0
- package/dist/primitives/video-player.d.ts +6 -0
- package/dist/primitives/video-player.jsx +8 -0
- package/dist/registry/api.d.ts +37 -0
- package/dist/registry/api.js +130 -0
- package/dist/registry/index.d.ts +9 -0
- package/dist/registry/index.js +45 -0
- package/dist/style/theme-provider.d.ts +4 -0
- package/dist/style/theme-provider.jsx +11 -0
- package/dist/tailwind/fontFamily.tailwind.d.ts +8 -0
- package/dist/tailwind/fontFamily.tailwind.js +7 -0
- package/dist/tailwind/fontSize.tailwind.d.ts +36 -0
- package/dist/tailwind/fontSize.tailwind.js +13 -0
- package/dist/tailwind/index.d.ts +3 -0
- package/dist/tailwind/index.js +2 -0
- package/dist/tailwind/screens.tailwind.d.ts +9 -0
- package/dist/tailwind/screens.tailwind.js +8 -0
- package/dist/tailwind/tw-font-desc.d.ts +6 -0
- package/dist/tailwind/tw-font-desc.js +6 -0
- package/dist/types/animation-def.d.ts +2 -0
- package/dist/types/animation-def.js +1 -0
- package/dist/types/breakpoints.d.ts +4 -0
- package/dist/types/breakpoints.js +4 -0
- package/dist/types/bullet-item.d.ts +6 -0
- package/dist/types/bullet-item.js +2 -0
- package/dist/types/button-def.d.ts +29 -0
- package/dist/types/button-def.js +2 -0
- package/dist/types/dimensions.d.ts +5 -0
- package/dist/types/dimensions.js +1 -0
- package/dist/types/grid-def.d.ts +36 -0
- package/dist/types/grid-def.js +33 -0
- package/dist/types/image-def.d.ts +27 -0
- package/dist/types/image-def.js +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +2 -0
- package/dist/types/link-def.d.ts +44 -0
- package/dist/types/link-def.js +1 -0
- package/dist/types/media-stack-def.d.ts +25 -0
- package/dist/types/media-stack-def.js +1 -0
- package/dist/types/t-shirt-size.d.ts +2 -0
- package/dist/types/t-shirt-size.js +1 -0
- package/dist/types/tshirt-dimensions.d.ts +12 -0
- package/dist/types/tshirt-dimensions.js +1 -0
- package/dist/types/video-def.d.ts +9 -0
- package/dist/types/video-def.js +1 -0
- package/dist/util/format-and-abbreviate-as-currency.d.ts +11 -0
- package/dist/util/format-and-abbreviate-as-currency.js +91 -0
- package/dist/util/format-to-max-char.d.ts +5 -0
- package/dist/util/format-to-max-char.js +57 -0
- package/dist/util/index-client.d.ts +2 -0
- package/dist/util/index-client.js +3 -0
- package/dist/util/index.d.ts +17 -0
- package/dist/util/index.js +41 -0
- package/dist/util/number-abbreviate.d.ts +9 -0
- package/dist/util/number-abbreviate.js +30 -0
- package/dist/util/specifier.d.ts +7 -0
- package/dist/util/specifier.js +31 -0
- package/dist/util/spread-to-transform.d.ts +7 -0
- package/dist/util/spread-to-transform.js +18 -0
- package/dist/util/step-animation.d.ts +5 -0
- package/dist/util/step-animation.js +60 -0
- package/dist/util/two-way-map.d.ts +8 -0
- package/dist/util/two-way-map.js +16 -0
- package/mcp/README.md +141 -0
- package/mcp/enhanced-server.ts +1208 -0
- package/mcp/index.ts +518 -0
- package/mcp/package.json +10 -0
- package/package.json +34 -14
- package/primitives/accordion.tsx +5 -5
- package/primitives/button.tsx +6 -3
- package/primitives/dialog.tsx +12 -7
- package/primitives/tabs.tsx +1 -1
- package/primitives/tooltip.tsx +1 -1
- package/public/r/accordion.json +11 -0
- package/public/r/alert.json +11 -0
- package/public/r/avatar.json +11 -0
- package/public/r/badge.json +11 -0
- package/public/r/button.json +11 -0
- package/public/r/card.json +11 -0
- package/public/r/checkbox.json +11 -0
- package/public/r/default.json +6 -0
- package/public/r/dialog.json +11 -0
- package/public/r/input.json +11 -0
- package/public/r/label.json +11 -0
- package/public/r/new-york.json +6 -0
- package/public/r/popover.json +11 -0
- package/public/r/select.json +11 -0
- package/public/r/table.json +11 -0
- package/public/r/tabs.json +11 -0
- package/public/r/toast.json +11 -0
- package/registry/api.ts +164 -0
- package/registry/index.ts +60 -0
- package/registry/package.json +10 -0
- package/registry.json +184 -0
- package/test/test-registry.js +73 -0
- package/tsconfig.json +8 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Using @hanzo/ui with AI Assistants
|
|
2
|
+
|
|
3
|
+
This guide explains how to use @hanzo/ui with AI assistants through the Model Context Protocol (MCP).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Install the package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @hanzo/ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Start the MCP server:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @hanzo/ui registry:mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. Configure your AI assistant to use the server.
|
|
20
|
+
|
|
21
|
+
## Available Commands
|
|
22
|
+
|
|
23
|
+
- **Initialize a new project**:
|
|
24
|
+
```bash
|
|
25
|
+
npx @hanzo/ui init --style=default
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- **List available components**:
|
|
29
|
+
```bash
|
|
30
|
+
npx @hanzo/ui list
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- **Add a component**:
|
|
34
|
+
```bash
|
|
35
|
+
npx @hanzo/ui add button
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Using with LLMs
|
|
39
|
+
|
|
40
|
+
AI Assistants like Claude or ChatGPT can help you explore and use the components. Just describe what you need, and the AI can guide you through:
|
|
41
|
+
|
|
42
|
+
- Finding the right component
|
|
43
|
+
- Installing and configuring it
|
|
44
|
+
- Using it in your project
|
|
45
|
+
|
|
46
|
+
Example prompt: "I need a dropdown menu component for my React project. Can you help me find and set it up using @hanzo/ui?"
|
|
47
|
+
|
|
48
|
+
## Registry Configuration
|
|
49
|
+
|
|
50
|
+
You can create a custom registry for your components, making them available through the same interface. To create a registry:
|
|
51
|
+
|
|
52
|
+
1. Set up the registry structure
|
|
53
|
+
2. Run the update-registry script
|
|
54
|
+
3. Host the registry files
|
|
55
|
+
4. Point to your custom registry:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx @hanzo/ui registry:mcp --registry=https://your-registry-url.com/registry.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## HTTP Mode
|
|
62
|
+
|
|
63
|
+
For web-based applications, you can run the MCP server in HTTP mode:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx @hanzo/ui registry:mcp --http --port=3333
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This exposes an HTTP endpoint at http://localhost:3333 that you can use to communicate with the MCP server.
|
|
70
|
+
|
|
71
|
+
## Learn More
|
|
72
|
+
|
|
73
|
+
For detailed documentation, see [README-MCP.md](./README-MCP.md) or visit the [Hanzo UI website](https://ui.hanzo.ai).
|
package/README-MCP.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Hanzo UI with MCP Support
|
|
2
|
+
|
|
3
|
+
This implementation provides Model Context Protocol (MCP) support for the Hanzo UI library, enabling AI assistants to interact with the component registry based on shadcn/ui.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Run with npx (recommended)
|
|
9
|
+
npx @hanzo/ui registry:mcp
|
|
10
|
+
|
|
11
|
+
# Or set a custom registry URL
|
|
12
|
+
npx @hanzo/ui registry:mcp --registry=https://ui.hanzo.ai/registry/registry.json
|
|
13
|
+
|
|
14
|
+
# Run in HTTP mode instead of stdio
|
|
15
|
+
npx @hanzo/ui registry:mcp --http --port=3333
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Setup and Usage
|
|
19
|
+
|
|
20
|
+
### Configure Your LLM Tool
|
|
21
|
+
|
|
22
|
+
To configure your AI assistant or LLM to use the Hanzo UI MCP server, add the following configuration:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"name": "hanzo-ui",
|
|
27
|
+
"command": "npx @hanzo/ui registry:mcp"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Available Tools
|
|
32
|
+
|
|
33
|
+
The MCP server provides the following tools for AI assistants:
|
|
34
|
+
|
|
35
|
+
1. `init` - Initialize a new project using @hanzo/ui components and styles
|
|
36
|
+
2. `list_components` - List all available components in the registry
|
|
37
|
+
3. `get_component` - Get detailed information about a specific component
|
|
38
|
+
4. `add_component` - Get instructions for adding a component to a project
|
|
39
|
+
5. `list_styles` - List all available styles in the registry
|
|
40
|
+
6. `search_registry` - Search the registry for components matching criteria
|
|
41
|
+
|
|
42
|
+
### Registry Configuration
|
|
43
|
+
|
|
44
|
+
The registry URL can be configured by setting the `REGISTRY_URL` environment variable:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export REGISTRY_URL="https://ui.hanzo.ai/registry/registry.json"
|
|
48
|
+
npx @hanzo/ui registry:mcp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or by using the `--registry` command-line option:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx @hanzo/ui registry:mcp --registry=https://ui.hanzo.ai/registry/registry.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## HTTP Mode
|
|
58
|
+
|
|
59
|
+
You can run the MCP server in HTTP mode, which exposes the server over HTTP rather than stdio:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx @hanzo/ui registry:mcp --http --port=3333
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This allows you to access the MCP server directly from web applications or other HTTP clients.
|
|
66
|
+
|
|
67
|
+
## Developer Instructions
|
|
68
|
+
|
|
69
|
+
### Building from Source
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Clone the repository
|
|
73
|
+
git clone https://github.com/hanzoai/ui.git
|
|
74
|
+
cd ui/pkg/ui
|
|
75
|
+
|
|
76
|
+
# Install dependencies
|
|
77
|
+
npm install
|
|
78
|
+
|
|
79
|
+
# Build the package
|
|
80
|
+
npm run build
|
|
81
|
+
|
|
82
|
+
# Run the MCP server
|
|
83
|
+
node ./bin/cli.js registry:mcp
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Project Structure
|
|
87
|
+
|
|
88
|
+
- `/pkg/ui/mcp/`: MCP server implementation
|
|
89
|
+
- `/pkg/ui/registry/`: Registry schema and API
|
|
90
|
+
- `/pkg/ui/bin/`: CLI tools for running the MCP server
|
|
91
|
+
|
|
92
|
+
### Creating a Registry
|
|
93
|
+
|
|
94
|
+
The registry is compatible with shadcn/ui's registry format. To create a custom registry:
|
|
95
|
+
|
|
96
|
+
1. Create a `registry.json` file using the schema from `/pkg/ui/registry/schema.ts`
|
|
97
|
+
2. Build the registry using a build script
|
|
98
|
+
3. Host the registry files on a web server or CDN
|
|
99
|
+
4. Point the MCP server to your custom registry using the `--registry` option
|
|
100
|
+
|
|
101
|
+
## How It Works
|
|
102
|
+
|
|
103
|
+
The MCP server enables AI assistants to:
|
|
104
|
+
|
|
105
|
+
1. Discover and browse available components in your registry
|
|
106
|
+
2. Fetch detailed information about specific components
|
|
107
|
+
3. Provide instructions on adding components to projects
|
|
108
|
+
4. Initialize new projects with your component library
|
|
109
|
+
|
|
110
|
+
This makes it easy for users to interact with your UI library through conversational interfaces.
|
|
111
|
+
|
|
112
|
+
## Example Interactions
|
|
113
|
+
|
|
114
|
+
### Initialize a Project
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Assistant: To create a new project with Hanzo UI components, you can run:
|
|
118
|
+
|
|
119
|
+
npx create-next-app@latest my-app
|
|
120
|
+
cd my-app
|
|
121
|
+
npx @hanzo/ui@latest init
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Add a Component
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
Assistant: To add the Button component to your project:
|
|
128
|
+
|
|
129
|
+
npx @hanzo/ui@latest add button
|
|
130
|
+
|
|
131
|
+
This will install the component and its dependencies.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Search for Components
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Assistant: I found several form-related components:
|
|
138
|
+
- form
|
|
139
|
+
- input
|
|
140
|
+
- checkbox
|
|
141
|
+
- select
|
|
142
|
+
- textarea
|
|
143
|
+
|
|
144
|
+
Which one would you like to add to your project?
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Technical Details
|
|
148
|
+
|
|
149
|
+
### Registry Schema
|
|
150
|
+
|
|
151
|
+
The registry schema is compatible with shadcn/ui and includes:
|
|
152
|
+
|
|
153
|
+
- Component metadata (name, description, type)
|
|
154
|
+
- Dependencies (npm packages)
|
|
155
|
+
- Registry dependencies (other components)
|
|
156
|
+
- Component files with source code
|
|
157
|
+
- Category and subcategory information
|
|
158
|
+
|
|
159
|
+
### MCP Integration
|
|
160
|
+
|
|
161
|
+
The MCP server implements the Model Context Protocol, enabling AI assistants to:
|
|
162
|
+
|
|
163
|
+
- Query the registry for components
|
|
164
|
+
- Get detailed information about components
|
|
165
|
+
- Provide installation instructions
|
|
166
|
+
- Generate example usage code
|
|
167
|
+
|
|
168
|
+
### Command-Line Interface
|
|
169
|
+
|
|
170
|
+
The CLI provides options for:
|
|
171
|
+
|
|
172
|
+
- Setting the registry URL
|
|
173
|
+
- Running in HTTP mode
|
|
174
|
+
- Specifying the port for HTTP mode
|
|
175
|
+
- Verbose logging
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main CLI entry point for @hanzo/ui
|
|
5
|
+
* Supports various commands including registry:mcp
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { program } = require("commander");
|
|
9
|
+
|
|
10
|
+
// Define the version from the package.json
|
|
11
|
+
let version = "4.5.0";
|
|
12
|
+
try {
|
|
13
|
+
const packageJson = require("../package.json");
|
|
14
|
+
version = packageJson.version || version;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
// Use default version if package.json can't be loaded
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Set up the program
|
|
20
|
+
program
|
|
21
|
+
.name("@hanzo/ui")
|
|
22
|
+
.description("Hanzo UI Component Library CLI")
|
|
23
|
+
.version(version);
|
|
24
|
+
|
|
25
|
+
// Add the MCP command (main command)
|
|
26
|
+
program
|
|
27
|
+
.command("mcp")
|
|
28
|
+
.description("Start the Hanzo UI MCP server for AI assistants")
|
|
29
|
+
.option(
|
|
30
|
+
"-r, --registry <url>",
|
|
31
|
+
"URL to the registry.json file",
|
|
32
|
+
process.env.REGISTRY_URL || "https://ui.hanzo.ai/registry/registry.json"
|
|
33
|
+
)
|
|
34
|
+
.option(
|
|
35
|
+
"-p, --port <port>",
|
|
36
|
+
"Port to listen on (for HTTP mode)",
|
|
37
|
+
"3333"
|
|
38
|
+
)
|
|
39
|
+
.option(
|
|
40
|
+
"--http",
|
|
41
|
+
"Run in HTTP mode instead of stdio mode",
|
|
42
|
+
false
|
|
43
|
+
)
|
|
44
|
+
.action(async (options) => {
|
|
45
|
+
// Delegate to the dedicated MCP binary
|
|
46
|
+
require("./mcp.js");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Add the registry:mcp command (alias for compatibility)
|
|
50
|
+
program
|
|
51
|
+
.command("registry:mcp")
|
|
52
|
+
.description("Starts the registry MCP server (alias for 'mcp')")
|
|
53
|
+
.option(
|
|
54
|
+
"-r, --registry <url>",
|
|
55
|
+
"URL to the registry.json file",
|
|
56
|
+
process.env.REGISTRY_URL
|
|
57
|
+
)
|
|
58
|
+
.option(
|
|
59
|
+
"-p, --port <port>",
|
|
60
|
+
"Port to listen on (for HTTP mode)",
|
|
61
|
+
"3333"
|
|
62
|
+
)
|
|
63
|
+
.option(
|
|
64
|
+
"--http",
|
|
65
|
+
"Run in HTTP mode instead of stdio mode",
|
|
66
|
+
false
|
|
67
|
+
)
|
|
68
|
+
.action(async (options) => {
|
|
69
|
+
try {
|
|
70
|
+
// Set environment variables based on options
|
|
71
|
+
if (options.registry) {
|
|
72
|
+
process.env.REGISTRY_URL = options.registry;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Set port if running in HTTP mode
|
|
76
|
+
if (options.http) {
|
|
77
|
+
process.env.MCP_HTTP_MODE = "true";
|
|
78
|
+
process.env.MCP_PORT = options.port;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Show info about the server
|
|
82
|
+
console.error("Starting Hanzo UI MCP server...");
|
|
83
|
+
console.error(`Registry URL: ${process.env.REGISTRY_URL || "[Using default registry]"}`);
|
|
84
|
+
|
|
85
|
+
if (options.http) {
|
|
86
|
+
console.error(`Running in HTTP mode on port ${options.port}`);
|
|
87
|
+
} else {
|
|
88
|
+
console.error("Running in stdio mode");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Load and run the MCP server script
|
|
92
|
+
require("./registry-mcp.js");
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error("Error starting MCP server:", error);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Parse command line arguments
|
|
100
|
+
program.parse();
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simple registry builder for @hanzo/ui
|
|
5
|
+
* Creates the necessary structure for the MCP registry
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Configuration
|
|
12
|
+
const REGISTRY_DIR = path.resolve(__dirname, '../registry');
|
|
13
|
+
const PUBLIC_DIR = path.resolve(__dirname, '../public');
|
|
14
|
+
const OUTPUT_FILE = path.resolve(__dirname, '../registry.json');
|
|
15
|
+
const REGISTRY_STYLES = ['default', 'new-york'];
|
|
16
|
+
|
|
17
|
+
// Registry schema
|
|
18
|
+
const registrySchema = {
|
|
19
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
20
|
+
"name": "hanzo",
|
|
21
|
+
"homepage": "https://ui.hanzo.ai",
|
|
22
|
+
"items": []
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Create the basic registry structure
|
|
26
|
+
function createRegistry() {
|
|
27
|
+
console.log('Creating registry structure...');
|
|
28
|
+
|
|
29
|
+
const items = [];
|
|
30
|
+
|
|
31
|
+
// Ensure registry directory exists
|
|
32
|
+
if (!fs.existsSync(REGISTRY_DIR)) {
|
|
33
|
+
fs.mkdirSync(REGISTRY_DIR, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Create style directories and add them to registry items
|
|
37
|
+
for (const style of REGISTRY_STYLES) {
|
|
38
|
+
const styleDir = path.join(REGISTRY_DIR, style);
|
|
39
|
+
if (!fs.existsSync(styleDir)) {
|
|
40
|
+
fs.mkdirSync(styleDir, { recursive: true });
|
|
41
|
+
|
|
42
|
+
// Create ui and block directories
|
|
43
|
+
fs.mkdirSync(path.join(styleDir, 'ui'), { recursive: true });
|
|
44
|
+
fs.mkdirSync(path.join(styleDir, 'block'), { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Add style to registry
|
|
48
|
+
items.push({
|
|
49
|
+
name: style,
|
|
50
|
+
type: 'registry:style',
|
|
51
|
+
description: `The ${style} style for Hanzo UI components.`,
|
|
52
|
+
files: []
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Add primitive components as empty placeholders
|
|
57
|
+
const primitives = [
|
|
58
|
+
'accordion', 'alert', 'avatar', 'badge', 'button', 'card',
|
|
59
|
+
'checkbox', 'dialog', 'input', 'label', 'popover', 'select',
|
|
60
|
+
'table', 'tabs', 'toast'
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
for (const component of primitives) {
|
|
64
|
+
items.push({
|
|
65
|
+
name: component,
|
|
66
|
+
type: 'registry:component',
|
|
67
|
+
description: `A ${component} component for your UI.`,
|
|
68
|
+
files: [
|
|
69
|
+
{
|
|
70
|
+
path: `default/ui/${component}/${component}.tsx`,
|
|
71
|
+
type: 'registry:component'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Update registry.json
|
|
78
|
+
registrySchema.items = items;
|
|
79
|
+
|
|
80
|
+
// Create output directory if it doesn't exist
|
|
81
|
+
const outputDir = path.dirname(OUTPUT_FILE);
|
|
82
|
+
if (!fs.existsSync(outputDir)) {
|
|
83
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Write registry.json
|
|
87
|
+
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(registrySchema, null, 2), 'utf8');
|
|
88
|
+
console.log(`Registry updated with ${items.length} items.`);
|
|
89
|
+
|
|
90
|
+
// Create public/r directory if it doesn't exist
|
|
91
|
+
const publicRDir = path.join(PUBLIC_DIR, 'r');
|
|
92
|
+
if (!fs.existsSync(publicRDir)) {
|
|
93
|
+
fs.mkdirSync(publicRDir, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Generate individual component JSON files
|
|
97
|
+
console.log('Generating individual component JSON files...');
|
|
98
|
+
for (const item of items) {
|
|
99
|
+
const componentFile = path.join(publicRDir, `${item.name}.json`);
|
|
100
|
+
fs.writeFileSync(componentFile, JSON.stringify(item, null, 2), 'utf8');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(`Generated ${items.length} component JSON files.`);
|
|
104
|
+
console.log('Registry creation complete!');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Run the registry creation
|
|
108
|
+
createRegistry();
|