@idealyst/mcp-server 1.0.87 → 1.0.88
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/ARCHITECTURE.md +313 -0
- package/README.md +292 -104
- package/TYPE-SYSTEM.md +397 -0
- package/dist/index.js +170 -1
- package/examples/components/Accordion.examples.tsx +147 -0
- package/examples/components/ActivityIndicator.examples.tsx +350 -0
- package/examples/components/Alert.examples.tsx +335 -0
- package/examples/components/Avatar.examples.tsx +188 -0
- package/examples/components/Badge.examples.tsx +242 -0
- package/examples/components/Breadcrumb.examples.tsx +303 -0
- package/examples/components/Button.examples.tsx +113 -0
- package/examples/components/Card.examples.tsx +131 -0
- package/examples/components/Checkbox.examples.tsx +195 -0
- package/examples/components/Chip.examples.tsx +87 -0
- package/examples/components/Dialog.examples.tsx +344 -0
- package/examples/components/Divider.examples.tsx +258 -0
- package/examples/components/Icon.examples.tsx +202 -0
- package/examples/components/Input.examples.tsx +205 -0
- package/examples/components/Menu.examples.tsx +321 -0
- package/examples/components/Popover.examples.tsx +439 -0
- package/examples/components/Progress.examples.tsx +340 -0
- package/examples/components/RadioButton.examples.tsx +443 -0
- package/examples/components/Screen.examples.tsx +347 -0
- package/examples/components/Select.examples.tsx +279 -0
- package/examples/components/Skeleton.examples.tsx +278 -0
- package/examples/components/Slider.examples.tsx +249 -0
- package/examples/components/Switch.examples.tsx +94 -0
- package/examples/components/TabBar.examples.tsx +356 -0
- package/examples/components/Text.examples.tsx +177 -0
- package/examples/components/TextArea.examples.tsx +203 -0
- package/examples/components/Tooltip.examples.tsx +318 -0
- package/examples/components/View.examples.tsx +307 -0
- package/package.json +15 -2
- package/scripts/extract-types.ts +71 -0
- package/scripts/type-extractor.ts +286 -0
- package/scripts/validate-examples.ts +142 -0
- package/src/data/components/Icon.ts +1 -1
- package/src/data/components/index.ts +2 -0
- package/src/index.ts +181 -1
- package/src/tools/get-types.ts +169 -0
- package/tsconfig.examples.json +14 -0
- package/dist/data/cli-commands.d.ts +0 -2
- package/dist/data/cli-commands.d.ts.map +0 -1
- package/dist/data/cli-commands.js +0 -100
- package/dist/data/cli-commands.js.map +0 -1
- package/dist/data/components/Accordion.d.ts +0 -15
- package/dist/data/components/Accordion.d.ts.map +0 -1
- package/dist/data/components/Accordion.js +0 -112
- package/dist/data/components/Accordion.js.map +0 -1
- package/dist/data/components/ActivityIndicator.d.ts +0 -15
- package/dist/data/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/data/components/ActivityIndicator.js +0 -82
- package/dist/data/components/ActivityIndicator.js.map +0 -1
- package/dist/data/components/Alert.d.ts +0 -15
- package/dist/data/components/Alert.d.ts.map +0 -1
- package/dist/data/components/Alert.js +0 -132
- package/dist/data/components/Alert.js.map +0 -1
- package/dist/data/components/Avatar.d.ts +0 -15
- package/dist/data/components/Avatar.d.ts.map +0 -1
- package/dist/data/components/Avatar.js +0 -93
- package/dist/data/components/Avatar.js.map +0 -1
- package/dist/data/components/Badge.d.ts +0 -15
- package/dist/data/components/Badge.d.ts.map +0 -1
- package/dist/data/components/Badge.js +0 -64
- package/dist/data/components/Badge.js.map +0 -1
- package/dist/data/components/Breadcrumb.d.ts +0 -15
- package/dist/data/components/Breadcrumb.d.ts.map +0 -1
- package/dist/data/components/Breadcrumb.js +0 -96
- package/dist/data/components/Breadcrumb.js.map +0 -1
- package/dist/data/components/Button.d.ts +0 -15
- package/dist/data/components/Button.d.ts.map +0 -1
- package/dist/data/components/Button.js +0 -87
- package/dist/data/components/Button.js.map +0 -1
- package/dist/data/components/Card.d.ts +0 -15
- package/dist/data/components/Card.d.ts.map +0 -1
- package/dist/data/components/Card.js +0 -67
- package/dist/data/components/Card.js.map +0 -1
- package/dist/data/components/Checkbox.d.ts +0 -15
- package/dist/data/components/Checkbox.d.ts.map +0 -1
- package/dist/data/components/Checkbox.js +0 -118
- package/dist/data/components/Checkbox.js.map +0 -1
- package/dist/data/components/Chip.d.ts +0 -15
- package/dist/data/components/Chip.d.ts.map +0 -1
- package/dist/data/components/Chip.js +0 -76
- package/dist/data/components/Chip.js.map +0 -1
- package/dist/data/components/Dialog.d.ts +0 -15
- package/dist/data/components/Dialog.d.ts.map +0 -1
- package/dist/data/components/Dialog.js +0 -137
- package/dist/data/components/Dialog.js.map +0 -1
- package/dist/data/components/Divider.d.ts +0 -15
- package/dist/data/components/Divider.d.ts.map +0 -1
- package/dist/data/components/Divider.js +0 -71
- package/dist/data/components/Divider.js.map +0 -1
- package/dist/data/components/Icon.d.ts +0 -15
- package/dist/data/components/Icon.d.ts.map +0 -1
- package/dist/data/components/Icon.js +0 -70
- package/dist/data/components/Icon.js.map +0 -1
- package/dist/data/components/Image.d.ts +0 -15
- package/dist/data/components/Image.d.ts.map +0 -1
- package/dist/data/components/Image.js +0 -122
- package/dist/data/components/Image.js.map +0 -1
- package/dist/data/components/Input.d.ts +0 -15
- package/dist/data/components/Input.d.ts.map +0 -1
- package/dist/data/components/Input.js +0 -109
- package/dist/data/components/Input.js.map +0 -1
- package/dist/data/components/List.d.ts +0 -15
- package/dist/data/components/List.d.ts.map +0 -1
- package/dist/data/components/List.js +0 -113
- package/dist/data/components/List.js.map +0 -1
- package/dist/data/components/Menu.d.ts +0 -15
- package/dist/data/components/Menu.d.ts.map +0 -1
- package/dist/data/components/Menu.js +0 -132
- package/dist/data/components/Menu.js.map +0 -1
- package/dist/data/components/Popover.d.ts +0 -15
- package/dist/data/components/Popover.d.ts.map +0 -1
- package/dist/data/components/Popover.js +0 -159
- package/dist/data/components/Popover.js.map +0 -1
- package/dist/data/components/Pressable.d.ts +0 -15
- package/dist/data/components/Pressable.d.ts.map +0 -1
- package/dist/data/components/Pressable.js +0 -125
- package/dist/data/components/Pressable.js.map +0 -1
- package/dist/data/components/Progress.d.ts +0 -15
- package/dist/data/components/Progress.d.ts.map +0 -1
- package/dist/data/components/Progress.js +0 -95
- package/dist/data/components/Progress.js.map +0 -1
- package/dist/data/components/RadioButton.d.ts +0 -15
- package/dist/data/components/RadioButton.d.ts.map +0 -1
- package/dist/data/components/RadioButton.js +0 -140
- package/dist/data/components/RadioButton.js.map +0 -1
- package/dist/data/components/SVGImage.d.ts +0 -15
- package/dist/data/components/SVGImage.d.ts.map +0 -1
- package/dist/data/components/SVGImage.js +0 -112
- package/dist/data/components/SVGImage.js.map +0 -1
- package/dist/data/components/Screen.d.ts +0 -15
- package/dist/data/components/Screen.d.ts.map +0 -1
- package/dist/data/components/Screen.js +0 -99
- package/dist/data/components/Screen.js.map +0 -1
- package/dist/data/components/Select.d.ts +0 -15
- package/dist/data/components/Select.d.ts.map +0 -1
- package/dist/data/components/Select.js +0 -146
- package/dist/data/components/Select.js.map +0 -1
- package/dist/data/components/Skeleton.d.ts +0 -15
- package/dist/data/components/Skeleton.d.ts.map +0 -1
- package/dist/data/components/Skeleton.js +0 -110
- package/dist/data/components/Skeleton.js.map +0 -1
- package/dist/data/components/Slider.d.ts +0 -15
- package/dist/data/components/Slider.d.ts.map +0 -1
- package/dist/data/components/Slider.js +0 -129
- package/dist/data/components/Slider.js.map +0 -1
- package/dist/data/components/Switch.d.ts +0 -15
- package/dist/data/components/Switch.d.ts.map +0 -1
- package/dist/data/components/Switch.js +0 -127
- package/dist/data/components/Switch.js.map +0 -1
- package/dist/data/components/TabBar.d.ts +0 -15
- package/dist/data/components/TabBar.d.ts.map +0 -1
- package/dist/data/components/TabBar.js +0 -145
- package/dist/data/components/TabBar.js.map +0 -1
- package/dist/data/components/Table.d.ts +0 -15
- package/dist/data/components/Table.d.ts.map +0 -1
- package/dist/data/components/Table.js +0 -151
- package/dist/data/components/Table.js.map +0 -1
- package/dist/data/components/Tabs.d.ts +0 -15
- package/dist/data/components/Tabs.d.ts.map +0 -1
- package/dist/data/components/Tabs.js +0 -150
- package/dist/data/components/Tabs.js.map +0 -1
- package/dist/data/components/Text.d.ts +0 -15
- package/dist/data/components/Text.d.ts.map +0 -1
- package/dist/data/components/Text.js +0 -85
- package/dist/data/components/Text.js.map +0 -1
- package/dist/data/components/TextArea.d.ts +0 -15
- package/dist/data/components/TextArea.d.ts.map +0 -1
- package/dist/data/components/TextArea.js +0 -155
- package/dist/data/components/TextArea.js.map +0 -1
- package/dist/data/components/Tooltip.d.ts +0 -15
- package/dist/data/components/Tooltip.d.ts.map +0 -1
- package/dist/data/components/Tooltip.js +0 -105
- package/dist/data/components/Tooltip.js.map +0 -1
- package/dist/data/components/Video.d.ts +0 -15
- package/dist/data/components/Video.d.ts.map +0 -1
- package/dist/data/components/Video.js +0 -168
- package/dist/data/components/Video.js.map +0 -1
- package/dist/data/components/View.d.ts +0 -15
- package/dist/data/components/View.d.ts.map +0 -1
- package/dist/data/components/View.js +0 -126
- package/dist/data/components/View.js.map +0 -1
- package/dist/data/components/index.d.ts +0 -37
- package/dist/data/components/index.d.ts.map +0 -1
- package/dist/data/components/index.js +0 -110
- package/dist/data/components/index.js.map +0 -1
- package/dist/data/framework-guides.d.ts +0 -2
- package/dist/data/framework-guides.d.ts.map +0 -1
- package/dist/data/framework-guides.js +0 -589
- package/dist/data/framework-guides.js.map +0 -1
- package/dist/data/icon-guide.d.ts +0 -2
- package/dist/data/icon-guide.d.ts.map +0 -1
- package/dist/data/icon-guide.js +0 -285
- package/dist/data/icon-guide.js.map +0 -1
- package/dist/data/icons.json +0 -7452
- package/dist/data/navigation-guides.d.ts +0 -2
- package/dist/data/navigation-guides.d.ts.map +0 -1
- package/dist/data/navigation-guides.js +0 -1196
- package/dist/data/navigation-guides.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/TYPE-SYSTEM.md
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# Type-Driven Documentation System
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Idealyst MCP Server uses a **type-driven architecture** to ensure documentation accuracy. Instead of manually maintaining prop definitions, we extract TypeScript types directly from the source packages and validate all examples against them.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌──────────────────────────────────────────────────────────┐
|
|
11
|
+
│ Source Packages (Single Source of Truth) │
|
|
12
|
+
│ • @idealyst/components/src/*/types.ts │
|
|
13
|
+
│ • @idealyst/theme/src/theme/*.ts │
|
|
14
|
+
│ • @idealyst/navigation/src/routing/types.ts │
|
|
15
|
+
└────────────────┬─────────────────────────────────────────┘
|
|
16
|
+
│
|
|
17
|
+
▼
|
|
18
|
+
┌──────────────────────────────────────────────────────────┐
|
|
19
|
+
│ Build-Time Type Extraction │
|
|
20
|
+
│ • scripts/extract-types.ts │
|
|
21
|
+
│ • scripts/type-extractor.ts │
|
|
22
|
+
│ Uses TypeScript Compiler API (ts-morph) │
|
|
23
|
+
└────────────────┬─────────────────────────────────────────┘
|
|
24
|
+
│
|
|
25
|
+
▼
|
|
26
|
+
┌──────────────────────────────────────────────────────────┐
|
|
27
|
+
│ Generated Type Definitions │
|
|
28
|
+
│ • src/generated/types.json │
|
|
29
|
+
│ Contains all extracted types and props │
|
|
30
|
+
└────────────────┬─────────────────────────────────────────┘
|
|
31
|
+
│
|
|
32
|
+
▼
|
|
33
|
+
┌──────────────────────────────────────────────────────────┐
|
|
34
|
+
│ MCP Server Tools │
|
|
35
|
+
│ • get_component_types(component, format) │
|
|
36
|
+
│ • get_theme_types(format) │
|
|
37
|
+
│ • get_navigation_types(format) │
|
|
38
|
+
│ • get_component_examples_ts(component) │
|
|
39
|
+
└──────────────────────────────────────────────────────────┘
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Type Extraction
|
|
43
|
+
|
|
44
|
+
### What Gets Extracted
|
|
45
|
+
|
|
46
|
+
From **@idealyst/components**:
|
|
47
|
+
- Component props interfaces (`ButtonProps`, `CardProps`, etc.)
|
|
48
|
+
- All related types (enums, unions, type aliases)
|
|
49
|
+
- Individual prop details (name, type, required, description)
|
|
50
|
+
|
|
51
|
+
From **@idealyst/theme**:
|
|
52
|
+
- `Size` type: `'xs' | 'sm' | 'md' | 'lg' | 'xl'`
|
|
53
|
+
- `Intent` type: `'primary' | 'success' | 'error' | 'warning' | 'neutral' | 'info'`
|
|
54
|
+
- `Color` type: `Pallet.Shade` format
|
|
55
|
+
- `Pallet` and `Shade` types
|
|
56
|
+
|
|
57
|
+
From **@idealyst/navigation**:
|
|
58
|
+
- Navigator types (Stack, Tab, Drawer, Modal)
|
|
59
|
+
- Route configuration types
|
|
60
|
+
- Screen options types
|
|
61
|
+
|
|
62
|
+
### Running Type Extraction
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Extract types from all packages
|
|
66
|
+
yarn extract-types
|
|
67
|
+
|
|
68
|
+
# Output: src/generated/types.json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This generates a JSON file containing all type information structured for easy consumption by the MCP server.
|
|
72
|
+
|
|
73
|
+
## Example Validation
|
|
74
|
+
|
|
75
|
+
### TypeScript Example Files
|
|
76
|
+
|
|
77
|
+
All examples are stored as real TypeScript files in `examples/components/`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// examples/components/Button.examples.tsx
|
|
81
|
+
import React from 'react';
|
|
82
|
+
import { Button } from '@idealyst/components';
|
|
83
|
+
|
|
84
|
+
export function BasicButton() {
|
|
85
|
+
return (
|
|
86
|
+
<Button type="contained" intent="primary">
|
|
87
|
+
Save
|
|
88
|
+
</Button>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Running Validation
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Validate all examples against actual types
|
|
97
|
+
yarn validate-examples
|
|
98
|
+
|
|
99
|
+
# This runs TypeScript compiler on all example files
|
|
100
|
+
# Fails if any examples have type errors
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Benefits
|
|
104
|
+
|
|
105
|
+
✅ **Guaranteed Correctness**: Examples won't compile if they use wrong prop names or values
|
|
106
|
+
✅ **Auto-Discovery**: Type errors are caught immediately during build
|
|
107
|
+
✅ **Real Code**: Examples are actual TypeScript, not strings in documentation
|
|
108
|
+
✅ **IDE Support**: Examples can be developed with full autocomplete and type checking
|
|
109
|
+
|
|
110
|
+
## MCP Server Tools
|
|
111
|
+
|
|
112
|
+
### get_component_types
|
|
113
|
+
|
|
114
|
+
Get TypeScript type definitions for a component.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Request
|
|
118
|
+
{
|
|
119
|
+
component: "Button",
|
|
120
|
+
format: "both" // or "typescript" or "json"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Response
|
|
124
|
+
{
|
|
125
|
+
component: "Button",
|
|
126
|
+
typescript: "export interface ButtonProps { ... }",
|
|
127
|
+
schema: {
|
|
128
|
+
propsInterface: "ButtonProps",
|
|
129
|
+
props: [
|
|
130
|
+
{ name: "type", type: "ButtonType", required: false },
|
|
131
|
+
{ name: "size", type: "Size", required: false },
|
|
132
|
+
{ name: "leftIcon", type: "IconName | React.ReactNode", required: false }
|
|
133
|
+
],
|
|
134
|
+
relatedTypes: {
|
|
135
|
+
"ButtonType": "export type ButtonType = 'contained' | 'outlined' | 'text';"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Formats:**
|
|
142
|
+
- `typescript`: Raw TypeScript interface definitions
|
|
143
|
+
- `json`: Parsed JSON schema with prop details
|
|
144
|
+
- `both`: Combined output (default)
|
|
145
|
+
|
|
146
|
+
### get_theme_types
|
|
147
|
+
|
|
148
|
+
Get all theme types (Size, Intent, Color, etc.)
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// Request
|
|
152
|
+
{ format: "json" }
|
|
153
|
+
|
|
154
|
+
// Response
|
|
155
|
+
{
|
|
156
|
+
name: "Theme Types",
|
|
157
|
+
schema: {
|
|
158
|
+
"Size": {
|
|
159
|
+
name: "Size",
|
|
160
|
+
definition: "export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';",
|
|
161
|
+
values: ["xs", "sm", "md", "lg", "xl"]
|
|
162
|
+
},
|
|
163
|
+
"Intent": {
|
|
164
|
+
name: "Intent",
|
|
165
|
+
definition: "export type Intent = 'primary' | 'success' | ...",
|
|
166
|
+
values: ["primary", "success", "error", "warning", "neutral", "info"]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### get_navigation_types
|
|
173
|
+
|
|
174
|
+
Get navigation type definitions.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// Request
|
|
178
|
+
{ format: "typescript" }
|
|
179
|
+
|
|
180
|
+
// Response
|
|
181
|
+
{
|
|
182
|
+
name: "Navigation Types",
|
|
183
|
+
typescript: "export type NavigatorParam = ...\nexport type RouteParam = ..."
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### get_component_examples_ts
|
|
188
|
+
|
|
189
|
+
Get validated TypeScript examples for a component.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// Request
|
|
193
|
+
{ component: "Button" }
|
|
194
|
+
|
|
195
|
+
// Response: Full content of examples/components/Button.examples.tsx
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Development Workflow
|
|
199
|
+
|
|
200
|
+
### Adding a New Component
|
|
201
|
+
|
|
202
|
+
1. **Create the component** in `@idealyst/components`
|
|
203
|
+
2. **Define types** in `ComponentName/types.ts`
|
|
204
|
+
3. **Run extraction** to generate types:
|
|
205
|
+
```bash
|
|
206
|
+
yarn extract-types
|
|
207
|
+
```
|
|
208
|
+
4. **Create examples** in `examples/components/ComponentName.examples.tsx`
|
|
209
|
+
5. **Validate examples**:
|
|
210
|
+
```bash
|
|
211
|
+
yarn validate-examples
|
|
212
|
+
```
|
|
213
|
+
6. **Build MCP server**:
|
|
214
|
+
```bash
|
|
215
|
+
yarn build
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Updating Component Types
|
|
219
|
+
|
|
220
|
+
When you change a component's types:
|
|
221
|
+
|
|
222
|
+
1. **Edit types** in `@idealyst/components/src/ComponentName/types.ts`
|
|
223
|
+
2. **Rebuild packages** if necessary
|
|
224
|
+
3. **Run type extraction**:
|
|
225
|
+
```bash
|
|
226
|
+
cd packages/mcp-server
|
|
227
|
+
yarn extract-types
|
|
228
|
+
```
|
|
229
|
+
4. **Validation will catch** any examples that are now broken:
|
|
230
|
+
```bash
|
|
231
|
+
yarn validate-examples
|
|
232
|
+
```
|
|
233
|
+
5. **Fix broken examples** if needed
|
|
234
|
+
6. **Rebuild** MCP server
|
|
235
|
+
|
|
236
|
+
## Build Process
|
|
237
|
+
|
|
238
|
+
The build process ensures type accuracy:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"scripts": {
|
|
243
|
+
"prebuild": "yarn extract-types && yarn validate-examples",
|
|
244
|
+
"build": "tsc && chmod +x dist/index.js"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### What Happens
|
|
250
|
+
|
|
251
|
+
1. **Extract Types**: Parse TypeScript files from packages, generate `types.json`
|
|
252
|
+
2. **Validate Examples**: Type-check all example files
|
|
253
|
+
3. **Build Fails**: If examples have type errors
|
|
254
|
+
4. **Build Succeeds**: Only if all examples are type-correct
|
|
255
|
+
|
|
256
|
+
## CI/CD Integration
|
|
257
|
+
|
|
258
|
+
### Recommended GitHub Actions
|
|
259
|
+
|
|
260
|
+
```yaml
|
|
261
|
+
name: Validate MCP Documentation
|
|
262
|
+
|
|
263
|
+
on: [push, pull_request]
|
|
264
|
+
|
|
265
|
+
jobs:
|
|
266
|
+
validate:
|
|
267
|
+
runs-on: ubuntu-latest
|
|
268
|
+
steps:
|
|
269
|
+
- uses: actions/checkout@v3
|
|
270
|
+
|
|
271
|
+
- name: Setup Node
|
|
272
|
+
uses: actions/setup-node@v3
|
|
273
|
+
with:
|
|
274
|
+
node-version: '20'
|
|
275
|
+
|
|
276
|
+
- name: Install dependencies
|
|
277
|
+
run: yarn install
|
|
278
|
+
|
|
279
|
+
- name: Extract types
|
|
280
|
+
run: |
|
|
281
|
+
cd packages/mcp-server
|
|
282
|
+
yarn extract-types
|
|
283
|
+
|
|
284
|
+
- name: Validate examples
|
|
285
|
+
run: |
|
|
286
|
+
cd packages/mcp-server
|
|
287
|
+
yarn validate-examples
|
|
288
|
+
|
|
289
|
+
- name: Build
|
|
290
|
+
run: |
|
|
291
|
+
cd packages/mcp-server
|
|
292
|
+
yarn build
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## File Structure
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
packages/mcp-server/
|
|
299
|
+
├── scripts/
|
|
300
|
+
│ ├── extract-types.ts # Main extraction script
|
|
301
|
+
│ ├── type-extractor.ts # Type extraction utilities
|
|
302
|
+
│ └── validate-examples.ts # Example validation script
|
|
303
|
+
├── src/
|
|
304
|
+
│ ├── generated/
|
|
305
|
+
│ │ └── types.json # Auto-generated (gitignored)
|
|
306
|
+
│ ├── tools/
|
|
307
|
+
│ │ └── get-types.ts # Type export tools
|
|
308
|
+
│ └── index.ts # MCP server entry
|
|
309
|
+
├── examples/
|
|
310
|
+
│ └── components/
|
|
311
|
+
│ ├── Button.examples.tsx # Type-checked examples
|
|
312
|
+
│ ├── Card.examples.tsx
|
|
313
|
+
│ └── ...
|
|
314
|
+
├── tsconfig.json # Main TypeScript config
|
|
315
|
+
├── tsconfig.examples.json # Config for validating examples
|
|
316
|
+
└── package.json
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Benefits
|
|
320
|
+
|
|
321
|
+
### For Component Library Developers
|
|
322
|
+
- ✅ Change types → Documentation updates automatically
|
|
323
|
+
- ✅ No manual synchronization required
|
|
324
|
+
- ✅ Build fails if examples become invalid
|
|
325
|
+
|
|
326
|
+
### For AI Assistants (Claude, etc.)
|
|
327
|
+
- ✅ Access to raw TypeScript types
|
|
328
|
+
- ✅ Validated examples guaranteed to work
|
|
329
|
+
- ✅ Both human-readable and machine-readable formats
|
|
330
|
+
|
|
331
|
+
### For End Users
|
|
332
|
+
- ✅ Documentation always matches reality
|
|
333
|
+
- ✅ Examples compile on first try
|
|
334
|
+
- ✅ No "property doesn't exist" errors
|
|
335
|
+
|
|
336
|
+
## Troubleshooting
|
|
337
|
+
|
|
338
|
+
### Build Fails: "Types file not found"
|
|
339
|
+
|
|
340
|
+
Run type extraction first:
|
|
341
|
+
```bash
|
|
342
|
+
yarn extract-types
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Validation Fails: Type Errors in Examples
|
|
346
|
+
|
|
347
|
+
The examples have type errors. This is intentional! Fix the examples to match the actual types:
|
|
348
|
+
```bash
|
|
349
|
+
# See specific errors
|
|
350
|
+
yarn validate-examples
|
|
351
|
+
|
|
352
|
+
# Fix the examples, then re-validate
|
|
353
|
+
yarn validate-examples
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Types Are Out of Date
|
|
357
|
+
|
|
358
|
+
Re-extract after changing component types:
|
|
359
|
+
```bash
|
|
360
|
+
yarn extract-types
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Can't Find Component Types
|
|
364
|
+
|
|
365
|
+
Ensure the component has a `types.ts` file in its directory:
|
|
366
|
+
```
|
|
367
|
+
packages/components/src/
|
|
368
|
+
Button/
|
|
369
|
+
types.ts ← Required
|
|
370
|
+
Button.tsx
|
|
371
|
+
...
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Future Enhancements
|
|
375
|
+
|
|
376
|
+
### Planned Features
|
|
377
|
+
|
|
378
|
+
1. **Auto-Generate Prop Documentation**: Generate human-readable prop tables from types
|
|
379
|
+
2. **Visual Type Inspector**: Web UI to browse extracted types
|
|
380
|
+
3. **Incremental Extraction**: Only re-extract changed components
|
|
381
|
+
4. **Cross-Package Type Resolution**: Better handling of types imported from other packages
|
|
382
|
+
5. **Markdown Generation**: Auto-generate markdown docs from types
|
|
383
|
+
|
|
384
|
+
### Contributing
|
|
385
|
+
|
|
386
|
+
To contribute to the type system:
|
|
387
|
+
|
|
388
|
+
1. Follow the architecture in `ARCHITECTURE.md`
|
|
389
|
+
2. Add tests for new extractors
|
|
390
|
+
3. Ensure all examples remain valid
|
|
391
|
+
4. Update this documentation
|
|
392
|
+
|
|
393
|
+
## References
|
|
394
|
+
|
|
395
|
+
- [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API)
|
|
396
|
+
- [ts-morph Documentation](https://ts-morph.com/)
|
|
397
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,10 @@ import { frameworkGuides } from "./data/framework-guides.js";
|
|
|
8
8
|
import { navigationGuides } from "./data/navigation-guides.js";
|
|
9
9
|
import { iconGuide } from "./data/icon-guide.js";
|
|
10
10
|
import iconsData from "./data/icons.json" with { type: "json" };
|
|
11
|
+
import { getComponentTypes, getThemeTypes, getNavigationTypes, getAvailableComponents, getComponentExamples, } from "./tools/get-types.js";
|
|
11
12
|
const server = new Server({
|
|
12
13
|
name: "@idealyst/mcp-server",
|
|
13
|
-
version: "1.0.
|
|
14
|
+
version: "1.0.87",
|
|
14
15
|
}, {
|
|
15
16
|
capabilities: {
|
|
16
17
|
tools: {},
|
|
@@ -111,6 +112,67 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
111
112
|
required: ["query"],
|
|
112
113
|
},
|
|
113
114
|
},
|
|
115
|
+
{
|
|
116
|
+
name: "get_component_types",
|
|
117
|
+
description: "Get TypeScript type definitions for a specific component directly from the source. Returns the actual TypeScript interface and/or JSON schema.",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
component: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: "The name of the component (e.g., 'Button', 'Card', 'Input')",
|
|
124
|
+
},
|
|
125
|
+
format: {
|
|
126
|
+
type: "string",
|
|
127
|
+
description: "Output format: 'typescript' for raw TypeScript definitions, 'json' for parsed schema, 'both' for combined output (default: 'both')",
|
|
128
|
+
enum: ["typescript", "json", "both"],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
required: ["component"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "get_theme_types",
|
|
136
|
+
description: "Get TypeScript type definitions for theme types (Size, Intent, Color, etc.) directly from @idealyst/theme",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
format: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "Output format: 'typescript', 'json', or 'both' (default: 'both')",
|
|
143
|
+
enum: ["typescript", "json", "both"],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "get_navigation_types",
|
|
150
|
+
description: "Get TypeScript type definitions for navigation types directly from @idealyst/navigation",
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
format: {
|
|
155
|
+
type: "string",
|
|
156
|
+
description: "Output format: 'typescript', 'json', or 'both' (default: 'both')",
|
|
157
|
+
enum: ["typescript", "json", "both"],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "get_component_examples_ts",
|
|
164
|
+
description: "Get validated TypeScript example code for a component. These examples are type-checked and guaranteed to compile.",
|
|
165
|
+
inputSchema: {
|
|
166
|
+
type: "object",
|
|
167
|
+
properties: {
|
|
168
|
+
component: {
|
|
169
|
+
type: "string",
|
|
170
|
+
description: "The name of the component (e.g., 'Button', 'Card')",
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
required: ["component"],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
114
176
|
],
|
|
115
177
|
};
|
|
116
178
|
});
|
|
@@ -309,6 +371,113 @@ ${command.examples.map((ex) => `\`\`\`bash\n${ex}\n\`\`\``).join("\n\n")}
|
|
|
309
371
|
],
|
|
310
372
|
};
|
|
311
373
|
}
|
|
374
|
+
case "get_component_types": {
|
|
375
|
+
const componentName = args?.component;
|
|
376
|
+
const format = args?.format || 'both';
|
|
377
|
+
try {
|
|
378
|
+
const result = getComponentTypes(componentName, format);
|
|
379
|
+
return {
|
|
380
|
+
content: [
|
|
381
|
+
{
|
|
382
|
+
type: "text",
|
|
383
|
+
text: JSON.stringify(result, null, 2),
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
return {
|
|
390
|
+
content: [
|
|
391
|
+
{
|
|
392
|
+
type: "text",
|
|
393
|
+
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
case "get_theme_types": {
|
|
400
|
+
const format = args?.format || 'both';
|
|
401
|
+
try {
|
|
402
|
+
const result = getThemeTypes(format);
|
|
403
|
+
return {
|
|
404
|
+
content: [
|
|
405
|
+
{
|
|
406
|
+
type: "text",
|
|
407
|
+
text: JSON.stringify(result, null, 2),
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
return {
|
|
414
|
+
content: [
|
|
415
|
+
{
|
|
416
|
+
type: "text",
|
|
417
|
+
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
case "get_navigation_types": {
|
|
424
|
+
const format = args?.format || 'both';
|
|
425
|
+
try {
|
|
426
|
+
const result = getNavigationTypes(format);
|
|
427
|
+
return {
|
|
428
|
+
content: [
|
|
429
|
+
{
|
|
430
|
+
type: "text",
|
|
431
|
+
text: JSON.stringify(result, null, 2),
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
return {
|
|
438
|
+
content: [
|
|
439
|
+
{
|
|
440
|
+
type: "text",
|
|
441
|
+
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
case "get_component_examples_ts": {
|
|
448
|
+
const componentName = args?.component;
|
|
449
|
+
try {
|
|
450
|
+
const examples = getComponentExamples(componentName);
|
|
451
|
+
if (!examples) {
|
|
452
|
+
return {
|
|
453
|
+
content: [
|
|
454
|
+
{
|
|
455
|
+
type: "text",
|
|
456
|
+
text: `No TypeScript examples found for component "${componentName}". Available components with examples: ${getAvailableComponents().join(', ')}`,
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
content: [
|
|
463
|
+
{
|
|
464
|
+
type: "text",
|
|
465
|
+
text: examples,
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
return {
|
|
472
|
+
content: [
|
|
473
|
+
{
|
|
474
|
+
type: "text",
|
|
475
|
+
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
312
481
|
default:
|
|
313
482
|
return {
|
|
314
483
|
content: [
|