@hanzo/ui 4.4.3 → 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.
Files changed (321) hide show
  1. package/MCP-INSTRUCTIONS.md +73 -0
  2. package/README-MCP.md +175 -0
  3. package/bin/cli.js +100 -0
  4. package/bin/create-registry.js +108 -0
  5. package/bin/mcp.js +403 -0
  6. package/bin/npx-registry-mcp.js +15 -0
  7. package/bin/registry-mcp-wrapper.sh +19 -0
  8. package/bin/registry-mcp.js +100 -0
  9. package/bin/start-mcp-server.sh +22 -0
  10. package/bin/test-mcp.sh +52 -0
  11. package/bin/update-registry.js +196 -0
  12. package/blocks/components/enh-heading-block.tsx +1 -2
  13. package/blocks/components/screenful-block/index.tsx +2 -0
  14. package/blocks/def/card-block.ts +1 -3
  15. package/blocks/def/enh-heading-block.ts +1 -2
  16. package/dist/blocks/components/accordian-block.d.ts +4 -0
  17. package/dist/blocks/components/accordian-block.jsx +25 -0
  18. package/dist/blocks/components/block-component-props.d.ts +7 -0
  19. package/dist/blocks/components/block-component-props.js +1 -0
  20. package/dist/blocks/components/bullet-cards-block.d.ts +4 -0
  21. package/dist/blocks/components/bullet-cards-block.jsx +25 -0
  22. package/dist/blocks/components/card-block/index.d.ts +6 -0
  23. package/dist/blocks/components/card-block/index.jsx +87 -0
  24. package/dist/blocks/components/card-block/link-out-button.d.ts +6 -0
  25. package/dist/blocks/components/card-block/link-out-button.jsx +4 -0
  26. package/dist/blocks/components/card-block/util.d.ts +4 -0
  27. package/dist/blocks/components/card-block/util.js +6 -0
  28. package/dist/blocks/components/carte-blanche-block/index.d.ts +4 -0
  29. package/dist/blocks/components/carte-blanche-block/index.jsx +82 -0
  30. package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +10 -0
  31. package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +23 -0
  32. package/dist/blocks/components/content.d.ts +10 -0
  33. package/dist/blocks/components/content.jsx +47 -0
  34. package/dist/blocks/components/cta-block.d.ts +12 -0
  35. package/dist/blocks/components/cta-block.jsx +69 -0
  36. package/dist/blocks/components/enh-heading-block.d.ts +7 -0
  37. package/dist/blocks/components/enh-heading-block.jsx +142 -0
  38. package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +5 -0
  39. package/dist/blocks/components/grid-block/grid-block-mutator.js +1 -0
  40. package/dist/blocks/components/grid-block/index.d.ts +9 -0
  41. package/dist/blocks/components/grid-block/index.jsx +56 -0
  42. package/dist/blocks/components/grid-block/mutator-registry.d.ts +3 -0
  43. package/dist/blocks/components/grid-block/mutator-registry.js +5 -0
  44. package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +3 -0
  45. package/dist/blocks/components/grid-block/table-borders.mutator.js +36 -0
  46. package/dist/blocks/components/group-block.d.ts +7 -0
  47. package/dist/blocks/components/group-block.jsx +61 -0
  48. package/dist/blocks/components/heading-block.d.ts +4 -0
  49. package/dist/blocks/components/heading-block.jsx +99 -0
  50. package/dist/blocks/components/image-block.d.ts +7 -0
  51. package/dist/blocks/components/image-block.jsx +69 -0
  52. package/dist/blocks/components/index.d.ts +14 -0
  53. package/dist/blocks/components/index.js +13 -0
  54. package/dist/blocks/components/screenful-block/content.d.ts +8 -0
  55. package/dist/blocks/components/screenful-block/content.jsx +71 -0
  56. package/dist/blocks/components/screenful-block/index.d.ts +12 -0
  57. package/dist/blocks/components/screenful-block/index.jsx +57 -0
  58. package/dist/blocks/components/screenful-block/poster-background.d.ts +7 -0
  59. package/dist/blocks/components/screenful-block/poster-background.jsx +14 -0
  60. package/dist/blocks/components/screenful-block/video-background.d.ts +8 -0
  61. package/dist/blocks/components/screenful-block/video-background.jsx +20 -0
  62. package/dist/blocks/components/space-block.d.ts +4 -0
  63. package/dist/blocks/components/space-block.jsx +42 -0
  64. package/dist/blocks/components/video-block.d.ts +9 -0
  65. package/dist/blocks/components/video-block.jsx +83 -0
  66. package/dist/blocks/def/accordian-block.d.ts +10 -0
  67. package/dist/blocks/def/accordian-block.js +2 -0
  68. package/dist/blocks/def/block.d.ts +4 -0
  69. package/dist/blocks/def/block.js +1 -0
  70. package/dist/blocks/def/bullet-cards-block.d.ts +17 -0
  71. package/dist/blocks/def/bullet-cards-block.js +1 -0
  72. package/dist/blocks/def/card-block.d.ts +17 -0
  73. package/dist/blocks/def/card-block.js +2 -0
  74. package/dist/blocks/def/carte-blanche-block.d.ts +12 -0
  75. package/dist/blocks/def/carte-blanche-block.js +1 -0
  76. package/dist/blocks/def/cta-block.d.ts +8 -0
  77. package/dist/blocks/def/cta-block.js +1 -0
  78. package/dist/blocks/def/element-block.d.ts +7 -0
  79. package/dist/blocks/def/element-block.js +2 -0
  80. package/dist/blocks/def/enh-heading-block.d.ts +22 -0
  81. package/dist/blocks/def/enh-heading-block.js +1 -0
  82. package/dist/blocks/def/grid-block.d.ts +12 -0
  83. package/dist/blocks/def/grid-block.js +1 -0
  84. package/dist/blocks/def/group-block.d.ts +7 -0
  85. package/dist/blocks/def/group-block.js +1 -0
  86. package/dist/blocks/def/heading-block.d.ts +11 -0
  87. package/dist/blocks/def/heading-block.js +1 -0
  88. package/dist/blocks/def/image-block.d.ts +26 -0
  89. package/dist/blocks/def/image-block.js +1 -0
  90. package/dist/blocks/def/index.d.ts +17 -0
  91. package/dist/blocks/def/index.js +2 -0
  92. package/dist/blocks/def/screenful-block.d.ts +41 -0
  93. package/dist/blocks/def/screenful-block.js +1 -0
  94. package/dist/blocks/def/space-block.d.ts +47 -0
  95. package/dist/blocks/def/space-block.js +8 -0
  96. package/dist/blocks/def/video-block.d.ts +5 -0
  97. package/dist/blocks/def/video-block.js +1 -0
  98. package/dist/blocks/index.d.ts +2 -0
  99. package/dist/blocks/index.js +2 -0
  100. package/dist/mcp/enhanced-server.d.ts +29 -0
  101. package/dist/mcp/enhanced-server.js +1128 -0
  102. package/dist/mcp/index.d.ts +28 -0
  103. package/dist/mcp/index.js +436 -0
  104. package/dist/primitives/accordion.d.ts +10 -0
  105. package/dist/primitives/accordion.jsx +21 -0
  106. package/dist/primitives/action-button.d.ts +9 -0
  107. package/dist/primitives/action-button.jsx +16 -0
  108. package/dist/primitives/apply-typography.d.ts +7 -0
  109. package/dist/primitives/apply-typography.jsx +38 -0
  110. package/dist/primitives/aspect-ratio.d.ts +3 -0
  111. package/dist/primitives/aspect-ratio.jsx +4 -0
  112. package/dist/primitives/avatar.d.ts +6 -0
  113. package/dist/primitives/avatar.jsx +11 -0
  114. package/dist/primitives/badge.d.ts +9 -0
  115. package/dist/primitives/badge.jsx +18 -0
  116. package/dist/primitives/breadcrumb.d.ts +19 -0
  117. package/dist/primitives/breadcrumb.jsx +27 -0
  118. package/dist/primitives/breakpoint-indicator.d.ts +3 -0
  119. package/dist/primitives/breakpoint-indicator.jsx +14 -0
  120. package/dist/primitives/button.d.ts +12 -0
  121. package/dist/primitives/button.jsx +55 -0
  122. package/dist/primitives/calendar.d.ts +8 -0
  123. package/dist/primitives/calendar.jsx +40 -0
  124. package/dist/primitives/card.d.ts +8 -0
  125. package/dist/primitives/card.jsx +18 -0
  126. package/dist/primitives/carousel.d.ts +18 -0
  127. package/dist/primitives/carousel.jsx +106 -0
  128. package/dist/primitives/checkbox.d.ts +4 -0
  129. package/dist/primitives/checkbox.jsx +15 -0
  130. package/dist/primitives/combobox.d.ts +41 -0
  131. package/dist/primitives/combobox.jsx +77 -0
  132. package/dist/primitives/command.d.ts +17 -0
  133. package/dist/primitives/command.jsx +38 -0
  134. package/dist/primitives/context-menu.d.ts +27 -0
  135. package/dist/primitives/context-menu.jsx +57 -0
  136. package/dist/primitives/dialog-video-controller.d.ts +3 -0
  137. package/dist/primitives/dialog-video-controller.jsx +24 -0
  138. package/dist/primitives/dialog.d.ts +28 -0
  139. package/dist/primitives/dialog.jsx +37 -0
  140. package/dist/primitives/drawer.d.ts +29 -0
  141. package/dist/primitives/drawer.jsx +34 -0
  142. package/dist/primitives/form.d.ts +12 -0
  143. package/dist/primitives/form.jsx +69 -0
  144. package/dist/primitives/icons/github.d.ts +4 -0
  145. package/dist/primitives/icons/github.jsx +6 -0
  146. package/dist/primitives/icons/index.d.ts +4 -0
  147. package/dist/primitives/icons/index.js +4 -0
  148. package/dist/primitives/icons/youtube-logo.d.ts +4 -0
  149. package/dist/primitives/icons/youtube-logo.jsx +39 -0
  150. package/dist/primitives/index-common.d.ts +47 -0
  151. package/dist/primitives/index-common.js +46 -0
  152. package/dist/primitives/index-next.d.ts +2 -0
  153. package/dist/primitives/index-next.js +2 -0
  154. package/dist/primitives/input-otp.d.ts +7 -0
  155. package/dist/primitives/input-otp.jsx +24 -0
  156. package/dist/primitives/input.d.ts +5 -0
  157. package/dist/primitives/input.jsx +11 -0
  158. package/dist/primitives/label.d.ts +5 -0
  159. package/dist/primitives/label.jsx +11 -0
  160. package/dist/primitives/list-adaptor.d.ts +9 -0
  161. package/dist/primitives/list-adaptor.js +1 -0
  162. package/dist/primitives/list-box.d.ts +10 -0
  163. package/dist/primitives/list-box.jsx +14 -0
  164. package/dist/primitives/loading-spinner.d.ts +5 -0
  165. package/dist/primitives/loading-spinner.jsx +8 -0
  166. package/dist/primitives/navigation-menu.d.ts +12 -0
  167. package/dist/primitives/navigation-menu.jsx +38 -0
  168. package/dist/primitives/next/image.d.ts +11 -0
  169. package/dist/primitives/next/image.jsx +42 -0
  170. package/dist/primitives/next/index.d.ts +7 -0
  171. package/dist/primitives/next/index.js +7 -0
  172. package/dist/primitives/next/inline-icon.d.ts +13 -0
  173. package/dist/primitives/next/inline-icon.jsx +15 -0
  174. package/dist/primitives/next/link-element.d.ts +23 -0
  175. package/dist/primitives/next/link-element.jsx +56 -0
  176. package/dist/primitives/next/mdx-link.d.ts +3 -0
  177. package/dist/primitives/next/mdx-link.jsx +12 -0
  178. package/dist/primitives/next/media-stack.d.ts +8 -0
  179. package/dist/primitives/next/media-stack.jsx +28 -0
  180. package/dist/primitives/next/nav-items.d.ts +10 -0
  181. package/dist/primitives/next/nav-items.jsx +24 -0
  182. package/dist/primitives/next/youtube-embed.d.ts +11 -0
  183. package/dist/primitives/next/youtube-embed.jsx +23 -0
  184. package/dist/primitives/popover.d.ts +9 -0
  185. package/dist/primitives/popover.jsx +18 -0
  186. package/dist/primitives/progress.d.ts +4 -0
  187. package/dist/primitives/progress.jsx +9 -0
  188. package/dist/primitives/radio-group.d.ts +7 -0
  189. package/dist/primitives/radio-group.jsx +18 -0
  190. package/dist/primitives/scroll-area.d.ts +5 -0
  191. package/dist/primitives/scroll-area.jsx +19 -0
  192. package/dist/primitives/select.d.ts +13 -0
  193. package/dist/primitives/select.jsx +62 -0
  194. package/dist/primitives/separator.d.ts +4 -0
  195. package/dist/primitives/separator.jsx +7 -0
  196. package/dist/primitives/sheet.d.ts +30 -0
  197. package/dist/primitives/sheet.jsx +56 -0
  198. package/dist/primitives/skeleton.d.ts +4 -0
  199. package/dist/primitives/skeleton.jsx +3 -0
  200. package/dist/primitives/slider.d.ts +9 -0
  201. package/dist/primitives/slider.jsx +30 -0
  202. package/dist/primitives/sonner.d.ts +5 -0
  203. package/dist/primitives/sonner.jsx +16 -0
  204. package/dist/primitives/step-indicator.d.ts +9 -0
  205. package/dist/primitives/step-indicator.jsx +23 -0
  206. package/dist/primitives/switch.d.ts +6 -0
  207. package/dist/primitives/switch.jsx +14 -0
  208. package/dist/primitives/table.d.ts +10 -0
  209. package/dist/primitives/table.jsx +21 -0
  210. package/dist/primitives/tabs.d.ts +7 -0
  211. package/dist/primitives/tabs.jsx +18 -0
  212. package/dist/primitives/text-area.d.ts +5 -0
  213. package/dist/primitives/text-area.jsx +9 -0
  214. package/dist/primitives/toggle-group.d.ts +14 -0
  215. package/dist/primitives/toggle-group.jsx +28 -0
  216. package/dist/primitives/toggle.d.ts +14 -0
  217. package/dist/primitives/toggle.jsx +52 -0
  218. package/dist/primitives/tooltip.d.ts +11 -0
  219. package/dist/primitives/tooltip.jsx +18 -0
  220. package/dist/primitives/video-player.d.ts +6 -0
  221. package/dist/primitives/video-player.jsx +8 -0
  222. package/dist/registry/api.d.ts +37 -0
  223. package/dist/registry/api.js +130 -0
  224. package/dist/registry/index.d.ts +9 -0
  225. package/dist/registry/index.js +45 -0
  226. package/dist/style/theme-provider.d.ts +4 -0
  227. package/dist/style/theme-provider.jsx +11 -0
  228. package/dist/tailwind/fontFamily.tailwind.d.ts +8 -0
  229. package/dist/tailwind/fontFamily.tailwind.js +7 -0
  230. package/dist/tailwind/fontSize.tailwind.d.ts +36 -0
  231. package/dist/tailwind/fontSize.tailwind.js +13 -0
  232. package/dist/tailwind/index.d.ts +3 -0
  233. package/dist/tailwind/index.js +2 -0
  234. package/dist/tailwind/screens.tailwind.d.ts +9 -0
  235. package/dist/tailwind/screens.tailwind.js +8 -0
  236. package/dist/tailwind/tw-font-desc.d.ts +6 -0
  237. package/dist/tailwind/tw-font-desc.js +6 -0
  238. package/dist/types/animation-def.d.ts +2 -0
  239. package/dist/types/animation-def.js +1 -0
  240. package/dist/types/breakpoints.d.ts +4 -0
  241. package/dist/types/breakpoints.js +4 -0
  242. package/dist/types/bullet-item.d.ts +6 -0
  243. package/dist/types/bullet-item.js +2 -0
  244. package/dist/types/button-def.d.ts +29 -0
  245. package/dist/types/button-def.js +2 -0
  246. package/dist/types/dimensions.d.ts +5 -0
  247. package/dist/types/dimensions.js +1 -0
  248. package/dist/types/grid-def.d.ts +36 -0
  249. package/dist/types/grid-def.js +33 -0
  250. package/dist/types/image-def.d.ts +27 -0
  251. package/dist/types/image-def.js +1 -0
  252. package/dist/types/index.d.ts +13 -0
  253. package/dist/types/index.js +2 -0
  254. package/dist/types/link-def.d.ts +44 -0
  255. package/dist/types/link-def.js +1 -0
  256. package/dist/types/media-stack-def.d.ts +25 -0
  257. package/dist/types/media-stack-def.js +1 -0
  258. package/dist/types/t-shirt-size.d.ts +2 -0
  259. package/dist/types/t-shirt-size.js +1 -0
  260. package/dist/types/tshirt-dimensions.d.ts +12 -0
  261. package/dist/types/tshirt-dimensions.js +1 -0
  262. package/dist/types/video-def.d.ts +9 -0
  263. package/dist/types/video-def.js +1 -0
  264. package/dist/util/format-and-abbreviate-as-currency.d.ts +11 -0
  265. package/dist/util/format-and-abbreviate-as-currency.js +91 -0
  266. package/dist/util/format-to-max-char.d.ts +5 -0
  267. package/dist/util/format-to-max-char.js +57 -0
  268. package/dist/util/index-client.d.ts +2 -0
  269. package/dist/util/index-client.js +3 -0
  270. package/dist/util/index.d.ts +17 -0
  271. package/dist/util/index.js +41 -0
  272. package/dist/util/number-abbreviate.d.ts +9 -0
  273. package/dist/util/number-abbreviate.js +30 -0
  274. package/dist/util/specifier.d.ts +7 -0
  275. package/dist/util/specifier.js +31 -0
  276. package/dist/util/spread-to-transform.d.ts +7 -0
  277. package/dist/util/spread-to-transform.js +18 -0
  278. package/dist/util/step-animation.d.ts +5 -0
  279. package/dist/util/step-animation.js +60 -0
  280. package/dist/util/two-way-map.d.ts +8 -0
  281. package/dist/util/two-way-map.js +16 -0
  282. package/mcp/README.md +141 -0
  283. package/mcp/enhanced-server.ts +1208 -0
  284. package/mcp/index.ts +518 -0
  285. package/mcp/package.json +10 -0
  286. package/package.json +24 -4
  287. package/primitives/accordion.tsx +5 -5
  288. package/primitives/button.tsx +6 -3
  289. package/primitives/dialog.tsx +12 -7
  290. package/primitives/next/inline-icon.tsx +2 -3
  291. package/primitives/next/link-element.tsx +2 -2
  292. package/primitives/tabs.tsx +1 -1
  293. package/primitives/tooltip.tsx +1 -1
  294. package/public/r/accordion.json +11 -0
  295. package/public/r/alert.json +11 -0
  296. package/public/r/avatar.json +11 -0
  297. package/public/r/badge.json +11 -0
  298. package/public/r/button.json +11 -0
  299. package/public/r/card.json +11 -0
  300. package/public/r/checkbox.json +11 -0
  301. package/public/r/default.json +6 -0
  302. package/public/r/dialog.json +11 -0
  303. package/public/r/input.json +11 -0
  304. package/public/r/label.json +11 -0
  305. package/public/r/new-york.json +6 -0
  306. package/public/r/popover.json +11 -0
  307. package/public/r/select.json +11 -0
  308. package/public/r/table.json +11 -0
  309. package/public/r/tabs.json +11 -0
  310. package/public/r/toast.json +11 -0
  311. package/registry/api.ts +164 -0
  312. package/registry/index.ts +60 -0
  313. package/registry/package.json +10 -0
  314. package/registry.json +184 -0
  315. package/tailwind/typography-test.mdx +0 -1
  316. package/test/test-registry.js +73 -0
  317. package/tsconfig.json +8 -1
  318. package/types/bullet-item.ts +2 -2
  319. package/types/index.ts +0 -1
  320. package/types/link-def.ts +8 -14
  321. package/types/icon.ts +0 -10
package/mcp/index.ts ADDED
@@ -0,0 +1,518 @@
1
+ import { registrySchema, Registry, RegistryItem } from "../registry"
2
+ import { fetchRegistry, getRegistryItem, getRegistryItemUrl } from "../registry/api"
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js"
4
+ import {
5
+ CallToolRequestSchema,
6
+ ListToolsRequestSchema,
7
+ } from "@modelcontextprotocol/sdk/types.js"
8
+ import { z } from "zod"
9
+ import { zodToJsonSchema } from "zod-to-json-schema"
10
+
11
+ // Get package version
12
+ let packageVersion = "4.5.0"
13
+ try {
14
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
15
+ const packageJson = require("../../package.json")
16
+ packageVersion = packageJson.version || packageVersion
17
+ } catch (error) {
18
+ console.error("Could not load package.json for version", error)
19
+ }
20
+
21
+ /**
22
+ * MCP Server implementation for @hanzo/ui registry
23
+ * Provides tools for interacting with the registry
24
+ */
25
+ export const server = new Server(
26
+ {
27
+ name: "hanzo-ui",
28
+ version: packageVersion,
29
+ },
30
+ {
31
+ capabilities: {
32
+ resources: {},
33
+ tools: {},
34
+ },
35
+ }
36
+ )
37
+
38
+ // Register the available tools
39
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
40
+ return {
41
+ tools: [
42
+ {
43
+ name: "init",
44
+ description:
45
+ "Initialize a new project using @hanzo/ui components and styles.",
46
+ inputSchema: zodToJsonSchema(z.object({
47
+ style: z.string().optional().describe("The style to use for the project (e.g., 'default' or 'new-york')"),
48
+ })),
49
+ },
50
+ {
51
+ name: "list_components",
52
+ description: "List all available components in the registry",
53
+ inputSchema: zodToJsonSchema(z.object({
54
+ type: z.string().optional().describe("Filter components by type (e.g., 'ui', 'block')"),
55
+ category: z.string().optional().describe("Filter components by category"),
56
+ })),
57
+ },
58
+ {
59
+ name: "get_component",
60
+ description: "Get detailed information about a specific component",
61
+ inputSchema: zodToJsonSchema(
62
+ z.object({
63
+ name: z
64
+ .string()
65
+ .describe("The name of the component to get from the registry"),
66
+ })
67
+ ),
68
+ },
69
+ {
70
+ name: "add_component",
71
+ description: "Get instructions for adding a component to a project",
72
+ inputSchema: zodToJsonSchema(
73
+ z.object({
74
+ name: z
75
+ .string()
76
+ .describe("The name of the component to add"),
77
+ style: z
78
+ .string()
79
+ .optional()
80
+ .describe("The style to use (default, new-york, etc.)"),
81
+ })
82
+ ),
83
+ },
84
+ {
85
+ name: "list_styles",
86
+ description: "List all available styles in the registry",
87
+ inputSchema: zodToJsonSchema(z.object({})),
88
+ },
89
+ {
90
+ name: "search_registry",
91
+ description: "Search the registry for components matching criteria",
92
+ inputSchema: zodToJsonSchema(
93
+ z.object({
94
+ query: z
95
+ .string()
96
+ .describe("Search term to look for in component names and descriptions"),
97
+ })
98
+ ),
99
+ },
100
+ ],
101
+ }
102
+ })
103
+
104
+ // Handle tool calls
105
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
106
+ try {
107
+ // Ensure we have arguments
108
+ const args = request.params.arguments || {}
109
+
110
+ // Get registry URL from environment variable or use default
111
+ const REGISTRY_URL = process.env.REGISTRY_URL || "https://ui.hanzo.ai/registry/registry.json"
112
+ const registry = await getRegistry(REGISTRY_URL)
113
+
114
+ switch (request.params.name) {
115
+ case "init": {
116
+ const style = args.style || "default"
117
+
118
+ let text = `# Initialize a new project with @hanzo/ui
119
+
120
+ To create a new project with @hanzo/ui components, follow these steps:
121
+
122
+ 1. Create a new project first:
123
+ \`\`\`bash
124
+ # Using npm
125
+ npm create next-app@latest my-app
126
+
127
+ # Or using yarn
128
+ yarn create next-app my-app
129
+
130
+ # Or using pnpm
131
+ pnpm create next-app my-app
132
+ \`\`\`
133
+
134
+ 2. Navigate to your project directory:
135
+ \`\`\`bash
136
+ cd my-app
137
+ \`\`\`
138
+
139
+ 3. Install @hanzo/ui and initialize it:
140
+ \`\`\`bash
141
+ npx @hanzo/ui@latest init${style ? ` --style=${style}` : ""}
142
+ \`\`\`
143
+
144
+ This will:
145
+ - Install all necessary dependencies
146
+ - Set up the project structure for @hanzo/ui
147
+ - Configure tailwind.css with the appropriate theme
148
+ - Add component configuration
149
+ `
150
+
151
+ // Check if the registry has any additional setup instructions
152
+ const setupConfig = registry.items.find(
153
+ (item) => item.type === "registry:config" && item.name === "setup"
154
+ )
155
+
156
+ if (setupConfig) {
157
+ text += `
158
+ ## Additional Setup
159
+
160
+ ${setupConfig.description || "Follow any additional setup instructions provided during initialization."}
161
+ `
162
+ }
163
+
164
+ return {
165
+ content: [
166
+ { type: "text", text }
167
+ ],
168
+ }
169
+ }
170
+
171
+ case "list_components": {
172
+ // Filter components based on type and category if provided
173
+ const typeFilter = args.type ? `ui:${args.type}` : null
174
+ const categoryFilter = args.category || null
175
+
176
+ let components = registry.items.filter(item => {
177
+ // Filter by type if specified
178
+ if (typeFilter && !item.type.includes(typeFilter)) {
179
+ return false
180
+ }
181
+
182
+ // Filter by category if specified
183
+ if (categoryFilter && item.category !== categoryFilter) {
184
+ return false
185
+ }
186
+
187
+ return true
188
+ })
189
+
190
+ // Group components by category if they have categories
191
+ const hasCategories = components.some(item => item.category)
192
+ let responseText = "# Available Components\n\n"
193
+
194
+ if (hasCategories) {
195
+ // Group by category
196
+ const categorized = components.reduce((acc, item) => {
197
+ const category = item.category || "Uncategorized"
198
+ if (!acc[category]) {
199
+ acc[category] = []
200
+ }
201
+ acc[category].push(item)
202
+ return acc
203
+ }, {} as Record<string, RegistryItem[]>)
204
+
205
+ // Build response
206
+ for (const [category, items] of Object.entries(categorized)) {
207
+ responseText += `## ${category}\n\n`
208
+
209
+ items.forEach(item => {
210
+ responseText += `- **${item.name}** - ${item.description || 'No description available'}\n`
211
+ })
212
+
213
+ responseText += "\n"
214
+ }
215
+ } else {
216
+ // Simple list
217
+ components.forEach(item => {
218
+ responseText += `- **${item.name}** (${item.type}) - ${item.description || 'No description available'}\n`
219
+ })
220
+ }
221
+
222
+ responseText += "\nTo get detailed information about a specific component, use the `get_component` tool.\n"
223
+ responseText += "To add a component to your project, use the `add_component` tool.\n"
224
+
225
+ return {
226
+ content: [{ type: "text", text: responseText }],
227
+ }
228
+ }
229
+
230
+ case "get_component": {
231
+ const name = z.string().parse(args.name)
232
+
233
+ if (!name) {
234
+ throw new Error("Component name is required")
235
+ }
236
+
237
+ const itemUrl = getRegistryItemUrl(name, REGISTRY_URL)
238
+ const component = await getRegistryItem(itemUrl, "")
239
+
240
+ if (!component) {
241
+ return {
242
+ content: [
243
+ {
244
+ type: "text",
245
+ text: `Component '${name}' not found in the registry.`,
246
+ },
247
+ ],
248
+ }
249
+ }
250
+
251
+ // Build a markdown description of the component
252
+ let componentDetails = `# ${component.name}\n\n`
253
+
254
+ if (component.description) {
255
+ componentDetails += `${component.description}\n\n`
256
+ }
257
+
258
+ componentDetails += `**Type:** ${component.type}\n`
259
+
260
+ if (component.category) {
261
+ componentDetails += `**Category:** ${component.category}\n`
262
+ }
263
+
264
+ // Dependencies
265
+ if (component.dependencies && component.dependencies.length > 0) {
266
+ componentDetails += `\n## Dependencies\n\n`
267
+ component.dependencies.forEach(dep => {
268
+ componentDetails += `- ${dep}\n`
269
+ })
270
+ }
271
+
272
+ // Registry Dependencies
273
+ if (component.registryDependencies && component.registryDependencies.length > 0) {
274
+ componentDetails += `\n## Required Components\n\n`
275
+ componentDetails += `This component requires the following components that will be installed automatically:\n\n`
276
+ component.registryDependencies.forEach(dep => {
277
+ componentDetails += `- ${dep}\n`
278
+ })
279
+ }
280
+
281
+ // Files
282
+ if (component.files && component.files.length > 0) {
283
+ componentDetails += `\n## Files\n\n`
284
+ component.files.forEach(file => {
285
+ componentDetails += `- ${file.path} (${file.type})\n`
286
+ })
287
+ }
288
+
289
+ // Show example usage if available
290
+ const exampleFile = component.files?.find(file => file.type === "registry:example")
291
+ if (exampleFile && exampleFile.content) {
292
+ componentDetails += `\n## Example Usage\n\n\`\`\`tsx\n${exampleFile.content}\n\`\`\`\n`
293
+ }
294
+
295
+ // Add installation instructions
296
+ componentDetails += `\n## Installation\n\n`
297
+ componentDetails += `Run the following command to add this component to your project:\n\n`
298
+ componentDetails += `\`\`\`bash\n`
299
+ componentDetails += `npx @hanzo/ui@latest add ${name}\n`
300
+ componentDetails += `\`\`\`\n`
301
+
302
+ return {
303
+ content: [{ type: "text", text: componentDetails }],
304
+ }
305
+ }
306
+
307
+ case "add_component": {
308
+ const name = z.string().parse(args.name)
309
+ const style = args.style || "default"
310
+
311
+ if (!name) {
312
+ throw new Error("Component name is required")
313
+ }
314
+
315
+ const itemUrl = getRegistryItemUrl(name, REGISTRY_URL)
316
+ const component = await getRegistryItem(itemUrl, "")
317
+
318
+ if (!component) {
319
+ return {
320
+ content: [
321
+ {
322
+ type: "text",
323
+ text: `Component '${name}' not found in the registry.`,
324
+ },
325
+ ],
326
+ }
327
+ }
328
+
329
+ // Check if the component has dependencies
330
+ const hasDeps = component.registryDependencies && component.registryDependencies.length > 0
331
+
332
+ let instructions = `# Adding the ${name} Component\n\n`
333
+
334
+ // Main installation command
335
+ instructions += `Run the following command to add the \`${name}\` component to your project:\n\n`
336
+ instructions += `\`\`\`bash\n`
337
+ instructions += `npx @hanzo/ui@latest add ${name} --style=${style}\n`
338
+ instructions += `\`\`\`\n\n`
339
+
340
+ // Explain what this will do
341
+ instructions += `This will:\n`
342
+ instructions += `- Add the component file(s) to your project\n`
343
+ instructions += `- Install any required npm dependencies\n`
344
+
345
+ if (hasDeps) {
346
+ instructions += `- Install required component dependencies: ${component.registryDependencies!.join(", ")}\n`
347
+ }
348
+
349
+ // Usage example
350
+ instructions += `\n## Usage\n\nAfter adding the component, you can import it in your project:\n\n`
351
+ instructions += `\`\`\`tsx\n`
352
+ instructions += `import { ${name.charAt(0).toUpperCase() + name.slice(1)} } from "@/components/ui/${name}"\n\n`
353
+
354
+ // Add a simple example if possible
355
+ if (component.type.includes("ui:")) {
356
+ instructions += `export default function Example() {\n`
357
+ instructions += ` return <${name.charAt(0).toUpperCase() + name.slice(1)} />\n`
358
+ instructions += `}\n`
359
+ }
360
+
361
+ instructions += `\`\`\`\n`
362
+
363
+ return {
364
+ content: [
365
+ {
366
+ type: "text",
367
+ text: instructions,
368
+ },
369
+ ],
370
+ }
371
+ }
372
+
373
+ case "list_styles": {
374
+ // Find all style-related items in the registry
375
+ const styles = registry.items.filter(item =>
376
+ item.type === "registry:style" || item.type.includes("style")
377
+ )
378
+
379
+ let styleInfo = "# Available Styles\n\n"
380
+
381
+ if (styles.length === 0) {
382
+ styleInfo += "The registry does not define any specific styles.\n\n"
383
+ styleInfo += "The default style will be used when installing components.\n"
384
+ } else {
385
+ styles.forEach(style => {
386
+ styleInfo += `## ${style.name}\n\n`
387
+ styleInfo += `${style.description || 'No description available'}\n\n`
388
+
389
+ // Add usage info
390
+ styleInfo += `**Usage:**\n\n`
391
+ styleInfo += `\`\`\`bash\n`
392
+ styleInfo += `# Initialize with this style\n`
393
+ styleInfo += `npx @hanzo/ui@latest init --style=${style.name}\n\n`
394
+ styleInfo += `# Install components with this style\n`
395
+ styleInfo += `npx @hanzo/ui@latest add [component] --style=${style.name}\n`
396
+ styleInfo += `\`\`\`\n\n`
397
+ })
398
+ }
399
+
400
+ return {
401
+ content: [{ type: "text", text: styleInfo }],
402
+ }
403
+ }
404
+
405
+ case "search_registry": {
406
+ const query = z.string().parse(args.query).toLowerCase()
407
+
408
+ if (!query || query.length < 2) {
409
+ return {
410
+ content: [
411
+ {
412
+ type: "text",
413
+ text: "Please provide a search term with at least 2 characters.",
414
+ },
415
+ ],
416
+ }
417
+ }
418
+
419
+ // Search through all items in the registry
420
+ const results = registry.items.filter(item => {
421
+ // Search in name
422
+ if (item.name.toLowerCase().includes(query)) {
423
+ return true
424
+ }
425
+
426
+ // Search in description
427
+ if (item.description?.toLowerCase().includes(query)) {
428
+ return true
429
+ }
430
+
431
+ // Search in category
432
+ if (item.category?.toLowerCase().includes(query)) {
433
+ return true
434
+ }
435
+
436
+ return false
437
+ })
438
+
439
+ if (results.length === 0) {
440
+ return {
441
+ content: [
442
+ {
443
+ type: "text",
444
+ text: `No components found matching '${query}'. Try a different search term.`,
445
+ },
446
+ ],
447
+ }
448
+ }
449
+
450
+ // Format the results
451
+ let searchResults = `# Search Results for '${query}'\n\n`
452
+ searchResults += `Found ${results.length} matching components\n\n`
453
+
454
+ results.forEach(item => {
455
+ searchResults += `## ${item.name}\n\n`
456
+ searchResults += `**Type:** ${item.type}\n`
457
+
458
+ if (item.category) {
459
+ searchResults += `**Category:** ${item.category}\n`
460
+ }
461
+
462
+ if (item.description) {
463
+ searchResults += `\n${item.description}\n`
464
+ }
465
+
466
+ searchResults += `\n**Installation:**\n\n`
467
+ searchResults += `\`\`\`bash\nnpx @hanzo/ui@latest add ${item.name}\n\`\`\`\n\n`
468
+ })
469
+
470
+ return {
471
+ content: [{ type: "text", text: searchResults }],
472
+ }
473
+ }
474
+
475
+ default:
476
+ throw new Error(`Tool ${request.params.name} not found`)
477
+ }
478
+ } catch (error) {
479
+ if (error instanceof z.ZodError) {
480
+ return {
481
+ content: [
482
+ {
483
+ type: "text",
484
+ text: `Invalid input: ${JSON.stringify(error.errors)}`,
485
+ },
486
+ ],
487
+ }
488
+ }
489
+
490
+ throw error
491
+ }
492
+ })
493
+
494
+ /**
495
+ * Fetches and parses the registry from the given URL
496
+ * @param registryUrl - URL to the registry.json file
497
+ * @returns The parsed registry object
498
+ */
499
+ async function getRegistry(registryUrl: string): Promise<Registry> {
500
+ try {
501
+ const [registryJson] = await fetchRegistry([registryUrl], {
502
+ useCache: false,
503
+ })
504
+ return registrySchema.parse(registryJson)
505
+ } catch (error) {
506
+ console.error(`Failed to fetch registry from ${registryUrl}:`, error)
507
+ // Return a minimal valid registry if we can't fetch the real one
508
+ return {
509
+ name: "hanzo-ui",
510
+ items: [],
511
+ }
512
+ }
513
+ }
514
+
515
+ // Support CommonJS
516
+ if (typeof module !== 'undefined') {
517
+ module.exports = { server }
518
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@hanzo/ui-mcp",
3
+ "private": true,
4
+ "type": "module",
5
+ "main": "../dist/mcp/index.js",
6
+ "types": "../dist/mcp/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc"
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/ui",
3
- "version": "4.4.3",
3
+ "version": "4.5.2",
4
4
  "description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -31,20 +31,37 @@
31
31
  "scripts": {
32
32
  "lat": "npm show @hanzo/ui version",
33
33
  "pub": "npm publish",
34
- "tc": "tsc"
34
+ "tc": "tsc",
35
+ "build": "tsc -p tsconfig.json",
36
+ "update-registry": "node ./bin/update-registry.js",
37
+ "registry:mcp": "node ./bin/cli.js registry:mcp",
38
+ "registry:mcp:http": "node ./bin/cli.js registry:mcp --http"
39
+ },
40
+ "bin": {
41
+ "@hanzo/ui": "./bin/cli.js",
42
+ "hanzo-ui": "./bin/cli.js"
35
43
  },
36
44
  "exports": {
37
45
  "./blocks": "./blocks/index.ts",
38
46
  "./primitives": "./primitives/index-next.ts",
39
47
  "./primitives-common": "./primitives/index-common.ts",
48
+ "./registry": {
49
+ "types": "./dist/registry/index.d.ts",
50
+ "default": "./dist/registry/index.js"
51
+ },
40
52
  "./style/": "./style/*",
41
53
  "./tailwind": "./tailwind/index.ts",
42
54
  "./types": "./types/index.ts",
43
55
  "./util": "./util/index.ts",
44
- "./util-client": "./util/index-client.ts"
56
+ "./util-client": "./util/index-client.ts",
57
+ "./mcp": {
58
+ "types": "./dist/mcp/index.d.ts",
59
+ "default": "./dist/mcp/index.js"
60
+ }
45
61
  },
46
62
  "dependencies": {
47
63
  "@hanzo/react-drawer": "^0.1.8",
64
+ "@modelcontextprotocol/sdk": "^1.10.2",
48
65
  "@next/third-parties": "^15.0.1",
49
66
  "@radix-ui/react-accordion": "^1.1.2",
50
67
  "@radix-ui/react-aspect-ratio": "^1.0.3",
@@ -75,6 +92,7 @@
75
92
  "class-variance-authority": "^0.7.0",
76
93
  "clsx": "^2.1.0",
77
94
  "cmdk": "^0.2.0",
95
+ "commander": "^12.1.0",
78
96
  "embla-carousel-react": "8.5.1",
79
97
  "input-otp": "^1.0.1",
80
98
  "lodash.castarray": "^4.4.0",
@@ -100,7 +118,8 @@
100
118
  "react-dom": "18.3.1",
101
119
  "react-hook-form": "7.51.4",
102
120
  "validator": "^13.11.0",
103
- "zod": "3.23.8"
121
+ "zod": "3.23.8",
122
+ "zod-to-json-schema": "^3.24.5"
104
123
  },
105
124
  "devDependencies": {
106
125
  "@mdx-js/loader": "^3.0.0",
@@ -113,6 +132,7 @@
113
132
  "@types/node": "20.14.15",
114
133
  "@types/react": "18.3.1",
115
134
  "@types/react-dom": "18.3.1",
135
+ "glob": "^11.0.2",
116
136
  "tailwindcss": "3.4.14",
117
137
  "typescript": "5.6.3"
118
138
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  import * as React from "react"
5
5
  import * as AccordionPrimitive from "@radix-ui/react-accordion"
6
- import { ChevronUp } from "lucide-react"
6
+ import { ChevronDown } from "lucide-react"
7
7
 
8
8
  import { cn } from "../util"
9
9
 
@@ -29,18 +29,18 @@ type AccordionTriggerProps = React.ComponentPropsWithoutRef<typeof AccordionPrim
29
29
  const AccordionTrigger = React.forwardRef<
30
30
  React.ElementRef<typeof AccordionPrimitive.Trigger>,
31
31
  AccordionTriggerProps
32
- >(({ showChevron, headerClx, className, children, ...props }, ref) => (
32
+ >(({ showChevron = true, headerClx, className, children, ...props }, ref) => (
33
33
  <AccordionPrimitive.Header className={cn('flex', headerClx)}>
34
34
  <AccordionPrimitive.Trigger
35
35
  ref={ref}
36
36
  className={cn(
37
- "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:-rotate-180",
37
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
38
38
  className
39
39
  )}
40
40
  {...props}
41
41
  >
42
42
  {children}
43
- {showChevron && <ChevronUp className="shrink-0 transition-transform duration-200" />}
43
+ {showChevron && <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />}
44
44
  </AccordionPrimitive.Trigger>
45
45
  </AccordionPrimitive.Header>
46
46
  ))
@@ -58,7 +58,7 @@ const AccordionContent = React.forwardRef<
58
58
  )}
59
59
  {...props}
60
60
  >
61
- {children}
61
+ <div className="pb-4 pt-0">{children}</div>
62
62
  </AccordionPrimitive.Content>
63
63
  ))
64
64
  AccordionContent.displayName = AccordionPrimitive.Content.displayName
@@ -4,6 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority"
4
4
 
5
5
  import { cn } from "../util"
6
6
 
7
+ // Define all variants
7
8
  const variant = {
8
9
  primary: "bg-primary text-primary-fg sm:hover:bg-primary-hover font-nav whitespace-nowrap not-typography",
9
10
  secondary: "bg-secondary text-secondary-fg sm:hover:bg-secondary-hover font-nav whitespace-nowrap not-typography",
@@ -15,6 +16,7 @@ const variant = {
15
16
  linkMuted: "text-muted-1 sm:hover:text-foreground font-sans ",
16
17
  }
17
18
 
19
+ // Define all sizes
18
20
  const size = {
19
21
  link: '',
20
22
  xs: "h-8 px-2 text-xs",
@@ -25,6 +27,7 @@ const size = {
25
27
  icon: "h-10 w-10",
26
28
  }
27
29
 
30
+ // Define rounded options
28
31
  const rounded = {
29
32
  full: 'rounded-full',
30
33
  sm: 'rounded-sm',
@@ -34,11 +37,11 @@ const rounded = {
34
37
  none: ''
35
38
  }
36
39
 
37
-
40
+ // Updated buttonVariants with the latest Shadcn patterns
38
41
  const buttonVariants = cva(
39
- "flex items-center justify-center font-medium transition-colors " +
42
+ "inline-flex items-center justify-center font-medium ring-offset-background transition-colors " +
40
43
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 " +
41
- "disabled:opacity-50 disabled:pointer-events-none ring-offset-background",
44
+ "disabled:opacity-50 disabled:pointer-events-none",
42
45
  {
43
46
  variants: {
44
47
  variant,