polymorph-ui-components-mcp 0.0.1

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 (64) hide show
  1. package/build/docs/Accordion.md +45 -0
  2. package/build/docs/Avatar.md +80 -0
  3. package/build/docs/Badge.md +58 -0
  4. package/build/docs/Banner.md +134 -0
  5. package/build/docs/Book.md +111 -0
  6. package/build/docs/Browser.md +92 -0
  7. package/build/docs/Button.md +154 -0
  8. package/build/docs/CHANGELOG.md +0 -0
  9. package/build/docs/Calendar.md +129 -0
  10. package/build/docs/Carousel.md +73 -0
  11. package/build/docs/CheckListItem.md +76 -0
  12. package/build/docs/Checkbox.md +84 -0
  13. package/build/docs/Choicebox.md +71 -0
  14. package/build/docs/ColorPicker.md +83 -0
  15. package/build/docs/Combobox.md +336 -0
  16. package/build/docs/CommandMenu.md +208 -0
  17. package/build/docs/ContextMenu.md +132 -0
  18. package/build/docs/GUIDELINES.md +380 -0
  19. package/build/docs/Gauge.md +46 -0
  20. package/build/docs/GridItem.md +78 -0
  21. package/build/docs/Icon.md +66 -0
  22. package/build/docs/IconStack.md +68 -0
  23. package/build/docs/Img.md +56 -0
  24. package/build/docs/Input.md +151 -0
  25. package/build/docs/InputButton.md +246 -0
  26. package/build/docs/KeyboardInput.md +104 -0
  27. package/build/docs/ListItem.md +156 -0
  28. package/build/docs/Loader.md +55 -0
  29. package/build/docs/LoadingDots.md +45 -0
  30. package/build/docs/Menu.md +139 -0
  31. package/build/docs/Modal.md +221 -0
  32. package/build/docs/ModalAnimation.md +29 -0
  33. package/build/docs/OverlayAnimation.md +21 -0
  34. package/build/docs/Pagination.md +102 -0
  35. package/build/docs/Phone.md +82 -0
  36. package/build/docs/Pill.md +122 -0
  37. package/build/docs/Progress.md +53 -0
  38. package/build/docs/Radio.md +75 -0
  39. package/build/docs/RelativeTime.md +76 -0
  40. package/build/docs/Scroller.md +194 -0
  41. package/build/docs/Select.md +177 -0
  42. package/build/docs/Sheet.md +133 -0
  43. package/build/docs/Shimmer.md +76 -0
  44. package/build/docs/Slider.md +68 -0
  45. package/build/docs/Snippet.md +99 -0
  46. package/build/docs/SplitButton.md +157 -0
  47. package/build/docs/SplitInput.md +157 -0
  48. package/build/docs/Step.md +52 -0
  49. package/build/docs/Stepper.md +85 -0
  50. package/build/docs/Table.md +252 -0
  51. package/build/docs/Tabs.md +117 -0
  52. package/build/docs/ThemeSwitcher.md +125 -0
  53. package/build/docs/Toast.md +140 -0
  54. package/build/docs/Toggle.md +70 -0
  55. package/build/docs/Toolbar.md +100 -0
  56. package/build/docs/Tooltip.md +86 -0
  57. package/build/docs/_index.json +218 -0
  58. package/build/docs/templates/changelog.hbs +36 -0
  59. package/build/index.d.ts +2 -0
  60. package/build/index.js +163 -0
  61. package/build/index.js.map +1 -0
  62. package/build/services/registry.d.ts +11 -0
  63. package/build/types.d.ts +4 -0
  64. package/package.json +34 -0
@@ -0,0 +1,86 @@
1
+ # Tooltip
2
+
3
+ A floating tooltip that appears on hover or focus of a trigger element. The tooltip displays informational text positioned relative to its trigger (top, bottom, left, or right). Supports a configurable show delay and is fully themeable via CSS custom properties. The tooltip includes a directional arrow pointing toward the trigger element.
4
+
5
+ ## Usage
6
+
7
+ ```svelte
8
+ <script>
9
+ import { Tooltip } from 'polymorph-ui-components';
10
+ </script>
11
+
12
+ <Tooltip text="This is helpful info" position="top">
13
+ <button>Hover me</button>
14
+ </Tooltip>
15
+ ```
16
+
17
+ ## Props
18
+
19
+ | Prop | Type | Required | Default | Description |
20
+ | -------- | ---------------------------------------------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
21
+ | text | `string` | Yes | - | The text content displayed inside the tooltip bubble. |
22
+ | position | `TooltipPosition = 'top' \| 'bottom' \| 'left' \| 'right'` | No | `'top'` | Where the tooltip bubble appears relative to the trigger element. |
23
+ | delay | `number` | No | `0` | Time in milliseconds to wait before showing the tooltip after hover/focus. A value of 0 shows the tooltip immediately. |
24
+ | testId | `string \| null` | No | `-` | Value for data-pw on the tooltip container element for Playwright testing. |
25
+ | classes | `string` | No | `-` | CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
26
+
27
+ ## Snippets
28
+
29
+ Svelte 5 Snippet props — pass content blocks to the component.
30
+
31
+ | Snippet | Type | Description |
32
+ | -------- | --------- | ---------------------------------------------------------------------------------------------------------- |
33
+ | children | `Snippet` | The trigger element(s) that the tooltip wraps. The tooltip appears when hovering or focusing this content. |
34
+
35
+ ## Events
36
+
37
+ This component does not emit any events.
38
+
39
+ ## CSS Variables
40
+
41
+ Override these custom properties to theme the component.
42
+
43
+ | Variable | Default | CSS Property | Description |
44
+ | ----------------------------- | ------------------------------------ | ------------------- | --------------------------------------------------------------------------- |
45
+ | `--tooltip-container-display` | `inline-flex` | display | Display mode of the wrapper element around the trigger and tooltip. |
46
+ | `--tooltip-z-index` | `1000` | z-index | Stacking order of the tooltip bubble. |
47
+ | `--tooltip-max-width` | `200px` | max-width | Maximum width of the tooltip bubble before text wraps. |
48
+ | `--tooltip-background` | `#18181b` | background | Background color of the tooltip bubble. |
49
+ | `--tooltip-color` | `#ffffff` | color | Text color inside the tooltip bubble. |
50
+ | `--tooltip-font-size` | `12px` | font-size | Font size of the tooltip text. |
51
+ | `--tooltip-font-weight` | `400` | font-weight | Font weight of the tooltip text. |
52
+ | `--tooltip-font-family` | `-` | font-family | Font family of the tooltip text. |
53
+ | `--tooltip-padding` | `6px 10px` | padding | Inner padding of the tooltip bubble. |
54
+ | `--tooltip-border-radius` | `8px` | border-radius | Corner rounding of the tooltip bubble. |
55
+ | `--tooltip-border` | `none` | border | Border of the tooltip bubble. |
56
+ | `--tooltip-box-shadow` | `0 2px 6px rgba(0, 0, 0, 0.15)` | box-shadow | Shadow effect around the tooltip bubble. |
57
+ | `--tooltip-opacity-duration` | `0.15s` | transition duration | Duration of the tooltip opacity fade transition. |
58
+ | `--tooltip-offset` | `8px` | calc offset | Distance between the tooltip bubble and the trigger element. |
59
+ | `--tooltip-arrow-size` | `5px` | border-width | Size of the directional arrow pointing from the tooltip toward the trigger. |
60
+ | `--tooltip-arrow-color` | `var(--tooltip-background, #18181b)` | border-color | Color of the directional arrow. Defaults to match the tooltip background. |
61
+
62
+ ## Type Reference
63
+
64
+ Custom types used by this component's props and events:
65
+
66
+ ### TooltipPosition
67
+
68
+ ```typescript
69
+ type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
70
+ ```
71
+
72
+ ## Web Component
73
+
74
+ Tag: `<pui-tooltip>`
75
+
76
+ ```html
77
+ <pui-tooltip text="More info" position="top">
78
+ <button>Hover me</button>
79
+ </pui-tooltip>
80
+ ```
81
+
82
+ ### Slots
83
+
84
+ | Slot Name | Maps to Snippet | Description |
85
+ | ----------- | --------------- | ---------------------------------------------------- |
86
+ | _(default)_ | `children` | The trigger element that shows the tooltip on hover. |
@@ -0,0 +1,218 @@
1
+ [
2
+ {
3
+ "name": "Accordion",
4
+ "description": "An expandable/collapsible container that uses CSS grid row animation for smooth open/close transitions. When `expand` is true, the content is visible (grid-template-rows: 1fr); when false, it collapses to 0fr. Render children content using the default `children` snippet."
5
+ },
6
+ {
7
+ "name": "Avatar",
8
+ "description": "A circular user avatar that displays an image (via the Img component with fallback support) or text initials derived from `name`. Supports small/medium/large sizes and configurable border and colors via CSS variables. Becomes a button when `onclick` is provided."
9
+ },
10
+ {
11
+ "name": "Badge",
12
+ "description": "An icon with a numeric/text badge overlay positioned in the top-right corner. Displays an image with a small badge bubble containing the `value` text. Commonly used for notification counts on icons."
13
+ },
14
+ {
15
+ "name": "Banner",
16
+ "description": "A notification banner with optional icon snippet, text content, inline link text, right content slot, and a dismissible close button. Supports click interaction with keyboard accessibility. The `visible` prop is bindable for dismiss state control. Uses slide transition for show/hide."
17
+ },
18
+ {
19
+ "name": "Book",
20
+ "description": "A 3D book display component with animated page turning. Renders multiple pages with content snippets and supports swipe/click navigation. Includes page indicator dots and configurable perspective and rotation."
21
+ },
22
+ {
23
+ "name": "Browser",
24
+ "description": "A browser window chrome frame with address bar, navigation buttons, and a content area. Renders any content inside a browser-like UI frame. Useful for documentation, screenshots, and preview displays."
25
+ },
26
+ {
27
+ "name": "Button",
28
+ "description": "An action button that supports two loader modes (circular spinner or progress bar), HTML text content, icon and children snippets, aria-expanded for dropdown triggers, and a disabled state. The progress bar mode prevents clicks during animation."
29
+ },
30
+ {
31
+ "name": "Calendar",
32
+ "description": "A date picker with single-date and date-range selection modes. Supports month/year navigation, locale-aware day and month names, min/max date constraints, disabled dates, and keyboard navigation. Range mode shows visual start/end pills with highlighted in-between days."
33
+ },
34
+ {
35
+ "name": "Carousel",
36
+ "description": "An auto-playing slideshow that renders Svelte components as slides. Supports touch swipe and mouse drag for navigation. Shows optional dot indicators below the slides for direct navigation."
37
+ },
38
+ {
39
+ "name": "Checkbox",
40
+ "description": "A styled checkbox input with a custom SVG checkmark. Supports checked state binding, disabled state, and configurable size and colors via CSS variables."
41
+ },
42
+ {
43
+ "name": "ColorPicker",
44
+ "description": "A color selection component with a custom popover containing a saturation/brightness panel, hue slider, and editable HEX/RGB/HSL input fields. The trigger shows a color swatch with an optional hex text input. Uses Button, Input, and Slider components internally."
45
+ },
46
+ {
47
+ "name": "Combobox",
48
+ "description": "A text input with a filtered dropdown list implementing the WAI-ARIA combobox pattern. Supports keyboard navigation, disabled items, custom item rendering, and bindable value/inputValue/open state. Use for autocomplete, search suggestions, and typeahead inputs."
49
+ },
50
+ {
51
+ "name": "CheckListItem",
52
+ "description": "A list row pairing a Checkbox with a plain-text label. Toggling the checkbox updates the bindable `checked` state and fires `onclick` with the new boolean value. Supports a custom `checkboxLabel` snippet and a disabled state."
53
+ },
54
+ {
55
+ "name": "Choicebox",
56
+ "description": "A single selectable option box with radio-style or checkbox-style behavior set via the `mode` prop. Renders a `children` snippet for its content, toggles a bindable `selected` state on click/keyboard, and supports a disabled state."
57
+ },
58
+ {
59
+ "name": "CommandMenu",
60
+ "description": "A command palette overlay (Ctrl+K / Cmd+K) with substring search filtering, optional command groups with headings, and keyboard navigation. Supports per-item icons, shortcut display, and a custom empty state."
61
+ },
62
+ {
63
+ "name": "ContextMenu",
64
+ "description": "A right-click context menu with a flat list of items supporting separators, disabled items, danger styling, optional icons, and shortcut labels. Has keyboard navigation, positions itself at the click point, and adjusts to stay within the viewport."
65
+ },
66
+ {
67
+ "name": "Gauge",
68
+ "description": "A full-circle ring gauge that displays a `value` clamped to 0-100 as a single SVG arc. Has an animated stroke-dashoffset transition and an optional centered percentage label. Uses SVG stroke-dasharray for the arc rendering."
69
+ },
70
+ {
71
+ "name": "GridItem",
72
+ "description": "A square grid cell with a header icon (top-right), centered main icon, and text label below. Clicking toggles a loading overlay animation (clip-path radial sweep). The `showLoader` state is bindable."
73
+ },
74
+ {
75
+ "name": "Icon",
76
+ "description": "A clickable icon component that displays an image with an optional text label below. The entire container is a button for accessibility."
77
+ },
78
+ {
79
+ "name": "IconStack",
80
+ "description": "A horizontal stack of circular icons/avatars with negative margin layering (each icon overlaps the previous one). Each item can be either an `image` (renders an img) or `text` (renders a text span). Icons are z-indexed so the first icon appears on top."
81
+ },
82
+ {
83
+ "name": "Img",
84
+ "description": "An image component with automatic fallback. If the primary `src` fails to load (onerror), it switches to the `fallback` URL. The fallback only triggers once (won't loop if fallback also fails). Supports hover styling."
85
+ },
86
+ {
87
+ "name": "Input",
88
+ "description": "A text input field with built-in validation for email, phone, password, and text patterns. Validates automatically using RegExp props plus optional custom validator functions. Supports text transformers and view presentation formatting. Can render as a textarea."
89
+ },
90
+ {
91
+ "name": "InputButton",
92
+ "description": "A composite component that combines an Input field with optional left, right, and bottom Button components. The right and bottom buttons are automatically disabled until the input validation state becomes Valid."
93
+ },
94
+ {
95
+ "name": "KeyboardInput",
96
+ "description": "A keyboard shortcut display component that renders key combinations in styled key caps, mapping common keys (cmd, ctrl, shift, arrows, etc.) to symbols. Accepts a key array or a separator-delimited string. Optionally clickable with keyboard accessibility."
97
+ },
98
+ {
99
+ "name": "ListItem",
100
+ "description": "A multi-section list row with left image (with fallback), center label (supports HTML), right image, and optional text on the right. Supports an accordion-expandable bottom section and per-section click handlers."
101
+ },
102
+ {
103
+ "name": "Loader",
104
+ "description": "A rotating circular spinner with a gradient foreground that transitions from `--loader-foreground` to `--loader-foreground-end`. The center is cut out to create a ring/donut shape. Spins continuously with a 1.4s linear animation."
105
+ },
106
+ {
107
+ "name": "LoadingDots",
108
+ "description": "Animated dot sequence for inline loading indication. Renders a configurable number of dots (default 3) that animate in a staggered sequence using either a bounce or pulse animation. Size and duration are controlled via CSS variables."
109
+ },
110
+ {
111
+ "name": "Menu",
112
+ "description": "A dropdown action menu with full keyboard navigation (ArrowUp/Down, Enter/Space, Escape, Home/End), typeahead search, click-outside dismiss, separator lines, danger-styled items, disabled items, optional icons, and configurable position. Focus is managed automatically."
113
+ },
114
+ {
115
+ "name": "Modal",
116
+ "description": "A dialog overlay component that renders on top of the page with configurable size, alignment, header, footer, and transition animations. Locks body scroll and optionally handles hardware back-press navigation. Supports click-to-dismiss and Escape key."
117
+ },
118
+ {
119
+ "name": "ModalAnimation",
120
+ "description": "A wrapper that applies fly or fade Svelte transitions to its children based on the modal's `align` prop. For top alignment, content flies in from above; for bottom, from below; for center, a fade transition is used."
121
+ },
122
+ {
123
+ "name": "OverlayAnimation",
124
+ "description": "A wrapper that applies a fade-out transition (350ms) to its children when they are removed from the DOM. Used internally by Modal to animate the overlay background."
125
+ },
126
+ {
127
+ "name": "Pagination",
128
+ "description": "A page navigation component with previous/next buttons and numbered page links. Supports configurable visible page range with ellipsis for large page counts, disabled states, and custom arrow snippets."
129
+ },
130
+ {
131
+ "name": "Phone",
132
+ "description": "A smartphone device frame that renders content inside a realistic phone shell with a notch, status bar, and home indicator. Useful for documentation, app previews, and marketing displays."
133
+ },
134
+ {
135
+ "name": "Pill",
136
+ "description": "A compact label/tag element for displaying status, categories, or metadata. Supports an optional icon snippet and click interaction with keyboard accessibility (role=button, Enter/Space). Optionally clickable when onclick is provided."
137
+ },
138
+ {
139
+ "name": "Progress",
140
+ "description": "A horizontal progress bar that fills from left to right based on `value` relative to `max`, with an animated width transition. Supports an optional percentage label and an indeterminate sweeping animation when `value` is negative. Styling is configurable via CSS variables."
141
+ },
142
+ {
143
+ "name": "Radio",
144
+ "description": "A styled radio button input with a custom circular indicator. Supports checked state binding, disabled state, and configurable size and colors via CSS variables."
145
+ },
146
+ {
147
+ "name": "RelativeTime",
148
+ "description": "Displays a human-readable relative time string (e.g., '5 minutes ago') that auto-updates at a configurable interval. Uses Intl.RelativeTimeFormat for locale-aware formatting. Renders a semantic <time> element. Optionally wraps in a Tooltip showing the full date."
149
+ },
150
+ {
151
+ "name": "Scroller",
152
+ "description": "Overflowing horizontal or vertical item list with scroll controls. Shows navigation arrows when content overflows, with gradient fade edges. Supports drag-to-scroll, snap-to-item, touch device detection, and scroll position tracking."
153
+ },
154
+ {
155
+ "name": "Select",
156
+ "description": "A dropdown selector supporting single-select and multi-select modes, each with optional searchable filtering. In multi-select mode chosen items appear as dismissible Pills in the trigger (Backspace removes the last). Has full keyboard navigation and closes on outside click."
157
+ },
158
+ {
159
+ "name": "Sheet",
160
+ "description": "A panel that slides in from any edge of the screen (left, right, top, or bottom). Includes a structured layout with header, scrollable content, and optional footer. Body scroll locks while open, focus is trapped, and Escape key dismisses. The open prop is bindable."
161
+ },
162
+ {
163
+ "name": "Shimmer",
164
+ "description": "A loading placeholder with an animated shimmer/shine effect. Renders a rectangle with a sweeping highlight gradient. All visuals (size, shape, colors, speed) controlled entirely via CSS variables. Combine multiple instances to build skeleton layouts."
165
+ },
166
+ {
167
+ "name": "Slider",
168
+ "description": "A range slider with configurable min, max, and step values and a filled track. Supports an optional value display, a disabled state, and `oninput`/`onchange` callbacks. The value is bindable for two-way binding."
169
+ },
170
+ {
171
+ "name": "Snippet",
172
+ "description": "A copyable command-line code snippet with a prompt prefix and copy-to-clipboard button. Shows 'Copied!' feedback after copying. Supports custom copy icon snippet. Clipboard errors are silently handled for non-secure contexts."
173
+ },
174
+ {
175
+ "name": "SplitButton",
176
+ "description": "A primary action button paired with a dropdown arrow that opens a Menu component. The dropdown provides full keyboard navigation, typeahead, disabled/danger items, and separator support via the MenuItem API. Click the main button for the primary action or select from the dropdown for alternatives."
177
+ },
178
+ {
179
+ "name": "SplitInput",
180
+ "description": "A row of related input fields for segmented values like OTP/PIN codes, RGB/HSL color channels, IP addresses, or time inputs. Supports per-field configuration (dataType, min/max, validation), auto-advance focus, paste distribution, keyboard navigation, and optional separators between fields. Uses the Input component internally."
181
+ },
182
+ {
183
+ "name": "Step",
184
+ "description": "An individual step within a Stepper. Displays either a numbered circle or an icon image, a text label, and a dashed separator line. When clicked, fires the onclick event with the selected index."
185
+ },
186
+ {
187
+ "name": "Stepper",
188
+ "description": "A progress indicator showing numbered steps with completion and active states. Steps before currentStepIndex are completed (green), the active step is dark, and remaining steps are inactive (grey). Each step is clickable."
189
+ },
190
+ {
191
+ "name": "Table",
192
+ "description": "A sortable data table with clickable column headers for sort toggling (ascending/descending). Supports string, number, and boolean sorting. Enables vertical scrolling with sticky headers and per-cell content scrolling."
193
+ },
194
+ {
195
+ "name": "Tabs",
196
+ "description": "A horizontal tab bar with clickable tab items and an animated active indicator. Supports overflow scrolling with arrow buttons, custom tab content via a parameterized Snippet, and keyboard activation (Enter/Space). All visuals customizable via CSS variables."
197
+ },
198
+ {
199
+ "name": "ThemeSwitcher",
200
+ "description": "A segmented control for switching between light, dark, and system theme modes. Displays icons for each mode with an animated sliding indicator. Fires a callback with the selected theme value."
201
+ },
202
+ {
203
+ "name": "Toast",
204
+ "description": "An animated notification that slides in from a configurable direction, stays visible for a duration, then slides out. Unstyled by default — themed via CSS variables (--toast-background-color, --toast-color, etc.) or consumer-defined variant classes passed through `classes`. Has optional icons, subtext, and bottom content."
205
+ },
206
+ {
207
+ "name": "Toggle",
208
+ "description": "A labeled on/off switch with sliding ball animation. The `checked` prop controls the toggle state and the `onclick` event returns the new boolean state after toggling."
209
+ },
210
+ {
211
+ "name": "Toolbar",
212
+ "description": "A fixed-position header bar with a back button, center title, and customizable left/center/right content areas via Snippet slots. Supports an additional content row below the main toolbar."
213
+ },
214
+ {
215
+ "name": "Tooltip",
216
+ "description": "A hover-triggered tooltip that displays text content above, below, left, or right of its trigger element. Supports configurable position, delay, and styling via CSS variables."
217
+ }
218
+ ]
@@ -0,0 +1,36 @@
1
+ {{#each releases}}
2
+ {{#if @first}}
3
+ # Changelog All notable changes to this project will be documented in this file. The format is
4
+ based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ {{/if}}
8
+ {{#if href}}
9
+ ## [{{title}}]({{href}}){{#if tag}} - {{niceDate}}{{/if}}
10
+ {{else}}
11
+ ##
12
+ {{title}}{{#if tag}} - {{niceDate}}{{/if}}
13
+ {{/if}}
14
+
15
+ {{#if summary}}
16
+ {{summary}}
17
+
18
+ {{/if}}
19
+ {{#each sections}}
20
+ {{#if title}}
21
+ ###
22
+ {{title}}
23
+
24
+ {{/if}}
25
+ {{#each commits}}
26
+ {{#if breaking}}
27
+ - **BREAKING:**
28
+ {{subject}}{{#if href}} ([{{shorthash}}]({{href}})){{/if}}
29
+ {{else}}
30
+ -
31
+ {{subject}}{{#if href}} ([{{shorthash}}]({{href}})){{/if}}
32
+ {{/if}}
33
+ {{/each}}
34
+ {{/each}}
35
+
36
+ {{/each}}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/build/index.js ADDED
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { z } from 'zod';
5
+ import { readFileSync } from 'node:fs';
6
+ import { dirname, join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const __filename$1 = fileURLToPath(import.meta.url);
10
+ const __dirname$1 = dirname(__filename$1);
11
+ class ComponentRegistry {
12
+ docsDir;
13
+ components = [];
14
+ docCache = new Map();
15
+ constructor(docsDir) {
16
+ this.docsDir = docsDir ?? join(__dirname$1, 'docs');
17
+ }
18
+ init() {
19
+ const indexPath = join(this.docsDir, '_index.json');
20
+ const raw = readFileSync(indexPath, 'utf-8');
21
+ this.components = JSON.parse(raw);
22
+ }
23
+ getComponentList() {
24
+ return this.components;
25
+ }
26
+ getComponentNames() {
27
+ return this.components.map((c) => c.name);
28
+ }
29
+ getComponentDocs(name) {
30
+ const lower = name.toLowerCase();
31
+ const cached = this.docCache.get(lower);
32
+ if (cached)
33
+ return cached;
34
+ const entry = this.components.find((c) => c.name.toLowerCase() === lower);
35
+ if (!entry)
36
+ return null;
37
+ try {
38
+ const mdPath = join(this.docsDir, `${entry.name}.md`);
39
+ const content = readFileSync(mdPath, 'utf-8');
40
+ this.docCache.set(lower, content);
41
+ return content;
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ }
47
+ }
48
+
49
+ class SvelteUiComponentsServer {
50
+ server;
51
+ registry;
52
+ constructor() {
53
+ this.server = new McpServer({
54
+ name: "polymorph-ui-components",
55
+ version: "1.0.0",
56
+ });
57
+ this.registry = new ComponentRegistry();
58
+ this.registry.init();
59
+ this.registerTools();
60
+ }
61
+ registerTools() {
62
+ this.registerListComponents();
63
+ this.registerGetComponentDocs();
64
+ }
65
+ registerListComponents() {
66
+ this.server.registerTool("list_components", {
67
+ title: "List Components",
68
+ description: `Returns the list of all available components with brief descriptions.
69
+
70
+ Use this to discover which components exist, then call
71
+ get_component_docs to get the full documentation for any component.`,
72
+ }, async () => {
73
+ try {
74
+ const components = this.registry.getComponentList();
75
+ return {
76
+ content: [
77
+ {
78
+ type: "text",
79
+ text: JSON.stringify(components, null, 2),
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ catch (error) {
85
+ return {
86
+ content: [
87
+ {
88
+ type: "text",
89
+ text: `Error listing components: ${error instanceof Error ? error.message : String(error)}`,
90
+ },
91
+ ],
92
+ isError: true,
93
+ };
94
+ }
95
+ });
96
+ }
97
+ registerGetComponentDocs() {
98
+ this.server.registerTool("get_component_docs", {
99
+ title: "Get Component Documentation",
100
+ description: `Returns the full markdown documentation for a component.
101
+
102
+ Covers:
103
+ - Usage example (import + template)
104
+ - Props table (name, type, required, default)
105
+ - Snippets (Svelte 5 Snippet props for passing content blocks)
106
+ - Events (event handler props with callback signatures)
107
+ - CSS Variables (custom properties to override for theming)`,
108
+ inputSchema: {
109
+ componentName: z
110
+ .string()
111
+ .describe('Component name from the list, e.g. "Button", "Input", "Modal"'),
112
+ },
113
+ }, async ({ componentName }) => {
114
+ try {
115
+ const docs = this.registry.getComponentDocs(componentName);
116
+ if (!docs) {
117
+ const available = this.registry
118
+ .getComponentNames()
119
+ .join(", ");
120
+ return {
121
+ content: [
122
+ {
123
+ type: "text",
124
+ text: `Component "${componentName}" not found. Available: ${available}`,
125
+ },
126
+ ],
127
+ isError: true,
128
+ };
129
+ }
130
+ return {
131
+ content: [
132
+ {
133
+ type: "text",
134
+ text: docs,
135
+ },
136
+ ],
137
+ };
138
+ }
139
+ catch (error) {
140
+ return {
141
+ content: [
142
+ {
143
+ type: "text",
144
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
145
+ },
146
+ ],
147
+ isError: true,
148
+ };
149
+ }
150
+ });
151
+ }
152
+ async run() {
153
+ const transport = new StdioServerTransport();
154
+ await this.server.connect(transport);
155
+ console.error("polymorph-ui-components MCP server running on stdio");
156
+ }
157
+ }
158
+ const server = new SvelteUiComponentsServer();
159
+ server.run().catch((error) => {
160
+ console.error("Fatal error starting server:", error);
161
+ process.exit(1);
162
+ });
163
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/services/registry.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["__filename","__dirname"],"mappings":";;;;;;;;AAKA,MAAMA,YAAU,GAAG,aAAa,CAAC,MAAM,CA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BAAA,OAAO,EAAE;AACP,wBAAA;AACE,4BAAA,IAAI,EAAE,MAAe;AACrB,4BAAA,IAAI,EAAE,CAAA,OAAA,EAAU,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAE;AACzE,yBAAA;AACF,qBAAA;AACD,oBAAA,OAAO,EAAE,IAAI;iBACd;YACH;AACF,QAAA,CAAC,CACF;IACH;AAEA,IAAA,MAAM,GAAG,GAAA;AACP,QAAA,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE;QAC5C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;AACpC,QAAA,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC;IACtE;AACD;AAED,MAAM,MAAM,GAAG,IAAI,wBAAwB,EAAE;AAC7C,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AAC3B,IAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC;AACpD,IAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ComponentEntry } from '../types';
2
+ export declare class ComponentRegistry {
3
+ private docsDir;
4
+ private components;
5
+ private docCache;
6
+ constructor(docsDir?: string);
7
+ init(): void;
8
+ getComponentList(): ComponentEntry[];
9
+ getComponentNames(): string[];
10
+ getComponentDocs(name: string): string | null;
11
+ }
@@ -0,0 +1,4 @@
1
+ export type ComponentEntry = {
2
+ name: string;
3
+ description: string;
4
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "polymorph-ui-components-mcp",
3
+ "version": "0.0.1",
4
+ "description": "MCP server for polymorph-ui-components - provides structured access to component props, CSS variables, and usage patterns",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "bin": {
8
+ "polymorph-ui-components-mcp": "./build/index.js"
9
+ },
10
+ "scripts": {
11
+ "prebuild": "rm -rf build/docs && mkdir -p build && cp -r ../docs build/docs 2>/dev/null || true",
12
+ "build": "rollup -c && chmod +x build/index.js && rm -rf build/docs && cp -r ../docs build/docs",
13
+ "start": "node build/index.js",
14
+ "typecheck": "tsc --noEmit"
15
+ },
16
+ "dependencies": {
17
+ "@modelcontextprotocol/sdk": "^1.29.0",
18
+ "zod": "^4.4.3"
19
+ },
20
+ "devDependencies": {
21
+ "@rollup/plugin-node-resolve": "^16.0.3",
22
+ "@rollup/plugin-typescript": "^12.3.0",
23
+ "@types/node": "^25.9.2",
24
+ "rollup": "^4.61.1",
25
+ "tslib": "^2.8.1",
26
+ "typescript": "^6.0.3"
27
+ },
28
+ "engines": {
29
+ "node": ">=18.0.0"
30
+ },
31
+ "files": [
32
+ "build"
33
+ ]
34
+ }