impact-ui-mcp-server 1.0.0
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/DEPLOYMENT.md +224 -0
- package/QUICKSTART.md +119 -0
- package/QUICK_SETUP.md +95 -0
- package/README.md +259 -0
- package/package.json +49 -0
- package/src/index.js +565 -0
- package/src/parsers/componentParser.js +68 -0
- package/src/parsers/storybookParser.js +140 -0
- package/src/tools/codeExample.js +81 -0
- package/src/tools/componentInfo.js +26 -0
- package/src/utils/fileReader.js +91 -0
package/DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Impact UI MCP Server - Deployment Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to deploy and use the Impact UI MCP Server in other projects so teams can access Impact UI component documentation directly through their AI assistants.
|
|
4
|
+
|
|
5
|
+
## Deployment Options
|
|
6
|
+
|
|
7
|
+
### Option 1: NPM Package (Recommended for Teams)
|
|
8
|
+
|
|
9
|
+
This is the recommended approach for teams that want to use the MCP server in their projects.
|
|
10
|
+
|
|
11
|
+
#### Publishing the Package
|
|
12
|
+
|
|
13
|
+
1. **From the Impact UI repository**, navigate to the mcp-server directory:
|
|
14
|
+
```bash
|
|
15
|
+
cd mcp-server
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. **Publish to npm** (or your private npm registry):
|
|
19
|
+
```bash
|
|
20
|
+
npm publish
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For private registries:
|
|
24
|
+
```bash
|
|
25
|
+
npm publish --registry=https://your-registry.com
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Installing in Other Projects
|
|
29
|
+
|
|
30
|
+
1. **Install the package** in your project:
|
|
31
|
+
```bash
|
|
32
|
+
npm install @impact-analytics/impact-ui-mcp-server
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. **Configure Cursor IDE** to use the installed package:
|
|
36
|
+
|
|
37
|
+
Open Cursor Settings (Cmd+Shift+P → "Preferences: Open User Settings (JSON)") and add:
|
|
38
|
+
|
|
39
|
+
**If source files are included in the npm package (Option 1 - Recommended):**
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcp.servers": {
|
|
43
|
+
"impact-ui": {
|
|
44
|
+
"command": "node",
|
|
45
|
+
"args": [
|
|
46
|
+
"./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
|
|
47
|
+
],
|
|
48
|
+
"cwd": "${workspaceFolder}"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
**No environment variables needed!** The MCP server will auto-detect `impact-ui` from `node_modules`.
|
|
54
|
+
|
|
55
|
+
**If you're using a cloned repository instead:**
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcp.servers": {
|
|
59
|
+
"impact-ui": {
|
|
60
|
+
"command": "node",
|
|
61
|
+
"args": [
|
|
62
|
+
"./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
|
|
63
|
+
],
|
|
64
|
+
"cwd": "${workspaceFolder}",
|
|
65
|
+
"env": {
|
|
66
|
+
"IMPACT_UI_PATH": "/absolute/path/to/impact-ui"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
**Note**: `IMPACT_UI_PATH` is the path to the **cloned git repository** (e.g., `/Users/team/projects/impact-ui`), NOT the npm package path.
|
|
73
|
+
|
|
74
|
+
3. **Restart Cursor IDE**
|
|
75
|
+
|
|
76
|
+
### Option 2: Direct Path Configuration
|
|
77
|
+
|
|
78
|
+
If you don't want to use npm, you can point directly to the MCP server in the Impact UI repository.
|
|
79
|
+
|
|
80
|
+
1. **In Cursor Settings**, add:
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcp.servers": {
|
|
84
|
+
"impact-ui": {
|
|
85
|
+
"command": "node",
|
|
86
|
+
"args": [
|
|
87
|
+
"/absolute/path/to/impact-ui/mcp-server/src/index.js"
|
|
88
|
+
],
|
|
89
|
+
"cwd": "/absolute/path/to/impact-ui/mcp-server",
|
|
90
|
+
"env": {
|
|
91
|
+
"IMPACT_UI_PATH": "/absolute/path/to/impact-ui"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
2. **Restart Cursor IDE**
|
|
99
|
+
|
|
100
|
+
### Option 3: Environment Variable Configuration
|
|
101
|
+
|
|
102
|
+
You can also set the path via environment variables:
|
|
103
|
+
|
|
104
|
+
1. **Set environment variable** (in your shell profile or system settings):
|
|
105
|
+
```bash
|
|
106
|
+
export IMPACT_UI_PATH=/absolute/path/to/impact-ui
|
|
107
|
+
# or
|
|
108
|
+
export IMPACT_UI_FRONTEND_PATH=/absolute/path/to/impact-ui/frontend
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. **Configure Cursor** (same as Option 1 or 2, but without the `env` section)
|
|
112
|
+
|
|
113
|
+
## Configuration Options
|
|
114
|
+
|
|
115
|
+
The MCP server supports the following environment variables:
|
|
116
|
+
|
|
117
|
+
- **`IMPACT_UI_PATH`**: Path to the Impact UI repository root (e.g., `/path/to/impact-ui`)
|
|
118
|
+
- The server will automatically look for `frontend` directory inside this path
|
|
119
|
+
|
|
120
|
+
- **`IMPACT_UI_FRONTEND_PATH`**: Direct path to the frontend directory (e.g., `/path/to/impact-ui/frontend`)
|
|
121
|
+
- Use this if you want to point directly to the frontend folder
|
|
122
|
+
|
|
123
|
+
## Verification
|
|
124
|
+
|
|
125
|
+
After configuration, verify it's working:
|
|
126
|
+
|
|
127
|
+
1. Open Cursor chat (Cmd+L or Ctrl+L)
|
|
128
|
+
2. Look for the **Impact UI MCP server dropdown** - you should see all components listed
|
|
129
|
+
3. Ask: "What components are available in Impact UI?"
|
|
130
|
+
4. The MCP server should respond with component information
|
|
131
|
+
|
|
132
|
+
## Troubleshooting
|
|
133
|
+
|
|
134
|
+
### Server not starting
|
|
135
|
+
|
|
136
|
+
- **Check Node.js version**: Requires Node.js 18+
|
|
137
|
+
```bash
|
|
138
|
+
node --version
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **Verify the path**: Make sure `IMPACT_UI_PATH` points to the correct location
|
|
142
|
+
```bash
|
|
143
|
+
ls $IMPACT_UI_PATH/frontend/src/stories
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- **Check dependencies**: If using npm package, ensure it's installed
|
|
147
|
+
```bash
|
|
148
|
+
npm list @impact-analytics/impact-ui-mcp-server
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Components not found
|
|
152
|
+
|
|
153
|
+
- **Verify Storybook files exist**: The server looks for `*.stories.js` files in `frontend/src/stories`
|
|
154
|
+
```bash
|
|
155
|
+
ls /path/to/impact-ui/frontend/src/stories/*.stories.js
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- **Check file permissions**: Ensure the MCP server can read the files
|
|
159
|
+
|
|
160
|
+
### Path issues
|
|
161
|
+
|
|
162
|
+
- **Use absolute paths**: Always use absolute paths in configuration, not relative paths
|
|
163
|
+
- **Check workspace folder**: In Cursor, `${workspaceFolder}` resolves to your current workspace
|
|
164
|
+
|
|
165
|
+
## Multi-Project Setup
|
|
166
|
+
|
|
167
|
+
If you work on multiple projects that use Impact UI:
|
|
168
|
+
|
|
169
|
+
1. **Set a global environment variable** pointing to Impact UI:
|
|
170
|
+
```bash
|
|
171
|
+
# In ~/.zshrc or ~/.bashrc
|
|
172
|
+
export IMPACT_UI_PATH=/path/to/impact-ui
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
2. **Use the same configuration** in all projects:
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"mcp.servers": {
|
|
179
|
+
"impact-ui": {
|
|
180
|
+
"command": "node",
|
|
181
|
+
"args": [
|
|
182
|
+
"./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
|
|
183
|
+
],
|
|
184
|
+
"cwd": "${workspaceFolder}"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The server will automatically use the `IMPACT_UI_PATH` environment variable.
|
|
191
|
+
|
|
192
|
+
## CI/CD Integration
|
|
193
|
+
|
|
194
|
+
For automated testing or CI/CD pipelines, you can set the environment variable:
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
# Example GitHub Actions
|
|
198
|
+
env:
|
|
199
|
+
IMPACT_UI_PATH: ${{ secrets.IMPACT_UI_PATH }}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Security Considerations
|
|
203
|
+
|
|
204
|
+
- **Private npm registry**: If Impact UI is private, publish to a private npm registry
|
|
205
|
+
- **Path access**: Ensure the MCP server only has read access to the Impact UI repository
|
|
206
|
+
- **Network isolation**: The MCP server runs locally and doesn't require network access
|
|
207
|
+
|
|
208
|
+
## Updating the MCP Server
|
|
209
|
+
|
|
210
|
+
When the Impact UI library is updated:
|
|
211
|
+
|
|
212
|
+
1. **Update the npm package** (if using Option 1):
|
|
213
|
+
```bash
|
|
214
|
+
npm update @impact-analytics/impact-ui-mcp-server
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
2. **Restart Cursor IDE** to load the updated server
|
|
218
|
+
|
|
219
|
+
## Support
|
|
220
|
+
|
|
221
|
+
For issues or questions:
|
|
222
|
+
- Check the main [README.md](./README.md) for usage examples
|
|
223
|
+
- Review [QUICKSTART.md](./QUICKSTART.md) for setup instructions
|
|
224
|
+
- Contact the Impact UI team
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
1. **Install dependencies:**
|
|
6
|
+
```bash
|
|
7
|
+
cd mcp-server
|
|
8
|
+
npm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use the setup script:
|
|
12
|
+
```bash
|
|
13
|
+
./setup.sh
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configuration for Cursor IDE
|
|
17
|
+
|
|
18
|
+
### Quick Setup (Recommended)
|
|
19
|
+
|
|
20
|
+
1. **Generate the configuration automatically:**
|
|
21
|
+
```bash
|
|
22
|
+
cd mcp-server
|
|
23
|
+
npm run generate-config
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This will output the exact JSON you need to add to Cursor!
|
|
27
|
+
|
|
28
|
+
2. **Open Cursor Settings:**
|
|
29
|
+
- Press `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Windows/Linux)
|
|
30
|
+
- Type "Preferences: Open User Settings (JSON)" and select it
|
|
31
|
+
|
|
32
|
+
3. **Add the generated configuration** to your `settings.json` file
|
|
33
|
+
- Make sure to merge it with existing settings (add a comma if needed)
|
|
34
|
+
|
|
35
|
+
4. **Restart Cursor IDE**
|
|
36
|
+
|
|
37
|
+
5. **Verify it's working:**
|
|
38
|
+
- Open Cursor chat (Cmd+L or Ctrl+L)
|
|
39
|
+
- **Look for the Impact UI MCP server dropdown** - you should see a list of all components!
|
|
40
|
+
- Select any component from the dropdown to view its details
|
|
41
|
+
- Or ask: "What components are available in Impact UI?"
|
|
42
|
+
- The MCP server should automatically respond with component information
|
|
43
|
+
|
|
44
|
+
### Manual Setup
|
|
45
|
+
|
|
46
|
+
If you prefer to configure manually:
|
|
47
|
+
|
|
48
|
+
1. **Get the absolute path to your project:**
|
|
49
|
+
```bash
|
|
50
|
+
cd mcp-server
|
|
51
|
+
pwd
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. **Open Cursor Settings** (Cmd+Shift+P → "Preferences: Open User Settings (JSON)")
|
|
55
|
+
|
|
56
|
+
3. **Add this configuration:**
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcp.servers": {
|
|
60
|
+
"impact-ui": {
|
|
61
|
+
"command": "node",
|
|
62
|
+
"args": [
|
|
63
|
+
"/absolute/path/to/impact-ui/mcp-server/src/index.js"
|
|
64
|
+
],
|
|
65
|
+
"cwd": "/absolute/path/to/impact-ui/mcp-server"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Replace `/absolute/path/to/impact-ui` with your actual project path!
|
|
72
|
+
|
|
73
|
+
4. **Restart Cursor IDE**
|
|
74
|
+
|
|
75
|
+
## Testing
|
|
76
|
+
|
|
77
|
+
Test the server manually:
|
|
78
|
+
```bash
|
|
79
|
+
npm start
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The server should output: "Building component registry..." and then "Impact UI MCP Server running on stdio"
|
|
83
|
+
|
|
84
|
+
## Usage Examples
|
|
85
|
+
|
|
86
|
+
### Using Component Resources (Dropdown)
|
|
87
|
+
|
|
88
|
+
1. **Select a Component**: When you open Cursor chat, you'll see a dropdown with all Impact UI components
|
|
89
|
+
2. **Browse Components**: Select any component (e.g., "Button", "Modal", "Table")
|
|
90
|
+
3. **Ask Questions**: After selecting a component, you can ask:
|
|
91
|
+
- "What props does this component accept?"
|
|
92
|
+
- "Show me a code example for this component"
|
|
93
|
+
- "What are the best practices for using this component?"
|
|
94
|
+
|
|
95
|
+
### Using Tools Directly
|
|
96
|
+
|
|
97
|
+
Once configured, you can ask questions like:
|
|
98
|
+
|
|
99
|
+
- "What components are available in the Impact UI library?"
|
|
100
|
+
- "Show me how to use the Button component"
|
|
101
|
+
- "What props does the Modal component accept?"
|
|
102
|
+
- "Generate a code example for Table with sorting"
|
|
103
|
+
- "Find components related to forms"
|
|
104
|
+
|
|
105
|
+
## Troubleshooting
|
|
106
|
+
|
|
107
|
+
**Server won't start:**
|
|
108
|
+
- Make sure you've run `npm install`
|
|
109
|
+
- Check that the path to `frontend/src/stories` is correct
|
|
110
|
+
- Verify Node.js version is 18+ (check with `node --version`)
|
|
111
|
+
|
|
112
|
+
**Components not found:**
|
|
113
|
+
- Ensure Storybook story files exist in `frontend/src/stories`
|
|
114
|
+
- Check that story files follow naming: `ComponentName.stories.js`
|
|
115
|
+
|
|
116
|
+
**Configuration issues:**
|
|
117
|
+
- Use absolute paths (not relative) in the config file
|
|
118
|
+
- Make sure the `cwd` points to the mcp-server directory
|
|
119
|
+
- Restart Claude Desktop after changing config
|
package/QUICK_SETUP.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Quick Setup Guide for Teams
|
|
2
|
+
|
|
3
|
+
This is a quick reference for teams who want to use the Impact UI MCP Server in their projects.
|
|
4
|
+
|
|
5
|
+
## Option 1: Automated Setup (Easiest)
|
|
6
|
+
|
|
7
|
+
1. **In your project directory**, run:
|
|
8
|
+
```bash
|
|
9
|
+
npm install @impact-analytics/impact-ui-mcp-server
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. **Run the setup script**:
|
|
13
|
+
```bash
|
|
14
|
+
npx @impact-analytics/impact-ui-mcp-server/setup-for-teams.sh
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or download and run:
|
|
18
|
+
```bash
|
|
19
|
+
curl -o setup-for-teams.sh https://raw.githubusercontent.com/your-repo/impact-ui/main/mcp-server/setup-for-teams.sh
|
|
20
|
+
chmod +x setup-for-teams.sh
|
|
21
|
+
./setup-for-teams.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
3. **Copy the generated configuration** to Cursor settings
|
|
25
|
+
4. **Restart Cursor IDE**
|
|
26
|
+
|
|
27
|
+
## Option 2: Manual Setup
|
|
28
|
+
|
|
29
|
+
### Step 1: Install the Package
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @impact-analytics/impact-ui-mcp-server
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Step 2: Configure Cursor
|
|
36
|
+
|
|
37
|
+
1. Open Cursor Settings: `Cmd+Shift+P` → "Preferences: Open User Settings (JSON)"
|
|
38
|
+
2. Add this configuration:
|
|
39
|
+
|
|
40
|
+
**If source files are included in the npm package (Option 1 - Recommended):**
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcp.servers": {
|
|
44
|
+
"impact-ui": {
|
|
45
|
+
"command": "node",
|
|
46
|
+
"args": [
|
|
47
|
+
"./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
|
|
48
|
+
],
|
|
49
|
+
"cwd": "${workspaceFolder}"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
**That's it!** No environment variables needed. The MCP server auto-detects from `node_modules`.
|
|
55
|
+
|
|
56
|
+
**If using a cloned repository instead:**
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcp.servers": {
|
|
60
|
+
"impact-ui": {
|
|
61
|
+
"command": "node",
|
|
62
|
+
"args": [
|
|
63
|
+
"./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
|
|
64
|
+
],
|
|
65
|
+
"cwd": "${workspaceFolder}",
|
|
66
|
+
"env": {
|
|
67
|
+
"IMPACT_UI_PATH": "/path/to/impact-ui"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
**Note**: `IMPACT_UI_PATH` is the path to the **cloned git repository**, not the npm package.
|
|
74
|
+
|
|
75
|
+
3. **Restart Cursor IDE**
|
|
76
|
+
|
|
77
|
+
### Step 4: Verify
|
|
78
|
+
|
|
79
|
+
1. Open Cursor chat (`Cmd+L`)
|
|
80
|
+
2. Look for the **Impact UI** dropdown in the MCP server selector
|
|
81
|
+
3. Ask: "What components are available in Impact UI?"
|
|
82
|
+
|
|
83
|
+
## Troubleshooting
|
|
84
|
+
|
|
85
|
+
**Server not starting?**
|
|
86
|
+
- Check Node.js version: `node --version` (needs 18+)
|
|
87
|
+
- Verify Impact UI path exists: `ls /path/to/impact-ui/frontend`
|
|
88
|
+
|
|
89
|
+
**Components not found?**
|
|
90
|
+
- Make sure the Impact UI repository has Storybook files
|
|
91
|
+
- Check that `IMPACT_UI_PATH` points to the correct location
|
|
92
|
+
|
|
93
|
+
**Need help?**
|
|
94
|
+
- See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed instructions
|
|
95
|
+
- Check [README.md](./README.md) for usage examples
|
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Impact UI MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that provides AI assistants with access to the Impact UI component library documentation, props, and code examples. This allows team members to query the UI library through natural language prompts without switching to Storybook or documentation.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start for Teams
|
|
6
|
+
|
|
7
|
+
**Want to use this in your project?** See [DEPLOYMENT.md](./DEPLOYMENT.md) for complete setup instructions.
|
|
8
|
+
|
|
9
|
+
**Quick setup:**
|
|
10
|
+
1. Install: `npm install @impact-analytics/impact-ui-mcp-server`
|
|
11
|
+
2. Run setup script: `npx @impact-analytics/impact-ui-mcp-server/setup-for-teams.sh`
|
|
12
|
+
3. Add the generated config to Cursor settings
|
|
13
|
+
4. Restart Cursor IDE
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 📋 **Component Resources**: Browse all components in a dropdown when selecting the MCP server
|
|
18
|
+
- 🔍 **Component Discovery**: List all available components or search by name/description
|
|
19
|
+
- 📖 **Component Documentation**: Get detailed information about any component including props, types, defaults, and descriptions
|
|
20
|
+
- 💻 **Code Generation**: Generate ready-to-use code examples with proper imports and state management
|
|
21
|
+
- 🎯 **Smart Search**: Search components by name, description, or prop names
|
|
22
|
+
- 📚 **Usage Tips**: Get best practices and usage patterns for components
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
1. Navigate to the mcp-server directory:
|
|
27
|
+
```bash
|
|
28
|
+
cd mcp-server
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. Install dependencies:
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
### For Cursor IDE ⭐ (Recommended)
|
|
39
|
+
|
|
40
|
+
Cursor IDE supports MCP servers through its settings. Here's how to configure it:
|
|
41
|
+
|
|
42
|
+
1. **Open Cursor Settings:**
|
|
43
|
+
- Press `Cmd+,` (macOS) or `Ctrl+,` (Windows/Linux)
|
|
44
|
+
- Or go to `Cursor` → `Settings` → `Features` → `MCP`
|
|
45
|
+
|
|
46
|
+
2. **Add MCP Server Configuration:**
|
|
47
|
+
|
|
48
|
+
In your Cursor settings, add the following configuration. You can either:
|
|
49
|
+
|
|
50
|
+
**Option A: Via Settings UI**
|
|
51
|
+
- Navigate to `Cursor` → `Settings` → `Features` → `MCP`
|
|
52
|
+
- Click "Add MCP Server"
|
|
53
|
+
- Fill in:
|
|
54
|
+
- **Name**: `impact-ui`
|
|
55
|
+
- **Command**: `node`
|
|
56
|
+
- **Args**: `/absolute/path/to/impact-ui/mcp-server/src/index.js`
|
|
57
|
+
- **Working Directory**: `/absolute/path/to/impact-ui/mcp-server`
|
|
58
|
+
|
|
59
|
+
**Option B: Via settings.json**
|
|
60
|
+
|
|
61
|
+
Open your Cursor settings.json file:
|
|
62
|
+
- Press `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Windows/Linux)
|
|
63
|
+
- Type "Preferences: Open User Settings (JSON)"
|
|
64
|
+
|
|
65
|
+
Add this configuration:
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcp.servers": {
|
|
69
|
+
"impact-ui": {
|
|
70
|
+
"command": "node",
|
|
71
|
+
"args": [
|
|
72
|
+
"/absolute/path/to/impact-ui/mcp-server/src/index.js"
|
|
73
|
+
],
|
|
74
|
+
"cwd": "/absolute/path/to/impact-ui/mcp-server"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Replace `/absolute/path/to/impact-ui`** with your actual project path.
|
|
81
|
+
|
|
82
|
+
To get your project path, run:
|
|
83
|
+
```bash
|
|
84
|
+
cd /Users/narendrakumar/impact/impact-ui/mcp-server
|
|
85
|
+
pwd
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
3. **Restart Cursor IDE** for the changes to take effect.
|
|
89
|
+
|
|
90
|
+
4. **Verify it's working:**
|
|
91
|
+
- Open the Cursor chat (Cmd+L or Ctrl+L)
|
|
92
|
+
- Try asking: "What components are available in the Impact UI library?"
|
|
93
|
+
- The MCP server should automatically be used to answer your question
|
|
94
|
+
|
|
95
|
+
**💡 Quick Tip:** Run `npm run generate-config` in the mcp-server directory to automatically generate the correct configuration for your system!
|
|
96
|
+
|
|
97
|
+
### For Claude Desktop
|
|
98
|
+
|
|
99
|
+
If you also use Claude Desktop, add the following to your Claude Desktop configuration file:
|
|
100
|
+
|
|
101
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
102
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"impact-ui": {
|
|
108
|
+
"command": "node",
|
|
109
|
+
"args": [
|
|
110
|
+
"/absolute/path/to/impact-ui/mcp-server/src/index.js"
|
|
111
|
+
],
|
|
112
|
+
"cwd": "/absolute/path/to/impact-ui/mcp-server"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### For Other MCP Clients
|
|
119
|
+
|
|
120
|
+
The server uses stdio transport, so it can be used with any MCP-compatible client. Configure your client to run:
|
|
121
|
+
```bash
|
|
122
|
+
node /path/to/mcp-server/src/index.js
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Resources
|
|
126
|
+
|
|
127
|
+
When you select the Impact UI MCP server in Cursor, you'll see a **dropdown list of all available components**. You can:
|
|
128
|
+
|
|
129
|
+
1. **Browse Components**: Select any component from the dropdown to view its details
|
|
130
|
+
2. **Ask Questions**: After selecting a component, ask questions like:
|
|
131
|
+
- "What props does this component accept?"
|
|
132
|
+
- "Show me a code example"
|
|
133
|
+
- "What are the best practices for using this component?"
|
|
134
|
+
|
|
135
|
+
Each component resource includes:
|
|
136
|
+
- Component name and category
|
|
137
|
+
- Full description
|
|
138
|
+
- All props with types, defaults, and descriptions
|
|
139
|
+
- Available Storybook examples
|
|
140
|
+
- File locations
|
|
141
|
+
|
|
142
|
+
## Available Tools
|
|
143
|
+
|
|
144
|
+
### 1. `get_component_info`
|
|
145
|
+
Get detailed information about a specific component.
|
|
146
|
+
|
|
147
|
+
**Example query**: "What is the Button component and what props does it accept?"
|
|
148
|
+
|
|
149
|
+
### 2. `list_components`
|
|
150
|
+
List all available components, optionally filtered by category.
|
|
151
|
+
|
|
152
|
+
**Example query**: "List all components in the Patterns category"
|
|
153
|
+
|
|
154
|
+
### 3. `get_component_props`
|
|
155
|
+
Get all props for a component with types, defaults, and descriptions.
|
|
156
|
+
|
|
157
|
+
**Example query**: "What are all the props for the Modal component?"
|
|
158
|
+
|
|
159
|
+
### 4. `generate_code_example`
|
|
160
|
+
Generate a ready-to-use code example.
|
|
161
|
+
|
|
162
|
+
**Example query**: "Generate a code example for Modal with a title and primary button"
|
|
163
|
+
|
|
164
|
+
### 5. `search_components`
|
|
165
|
+
Search for components by name or description.
|
|
166
|
+
|
|
167
|
+
**Example query**: "Find components related to forms or inputs"
|
|
168
|
+
|
|
169
|
+
### 6. `get_component_usage_tips`
|
|
170
|
+
Get best practices and usage tips for a component.
|
|
171
|
+
|
|
172
|
+
**Example query**: "What are the best practices for using the Table component?"
|
|
173
|
+
|
|
174
|
+
## Usage Examples
|
|
175
|
+
|
|
176
|
+
Once configured, you can ask questions like:
|
|
177
|
+
|
|
178
|
+
- "What components are available for building forms?"
|
|
179
|
+
- "Show me how to use the Button component with an icon"
|
|
180
|
+
- "What props does the Table component accept?"
|
|
181
|
+
- "Generate a code example for Modal with state management"
|
|
182
|
+
- "Find all components that have a 'size' prop"
|
|
183
|
+
- "What's the difference between Button variants?"
|
|
184
|
+
|
|
185
|
+
## How It Works
|
|
186
|
+
|
|
187
|
+
1. **Component Discovery**: On startup, the server scans all Storybook story files (`*.stories.js`) in the `frontend/src/stories` directory.
|
|
188
|
+
|
|
189
|
+
2. **Metadata Extraction**: For each component, it extracts:
|
|
190
|
+
- Component name and category (Components vs Patterns)
|
|
191
|
+
- Description from Storybook
|
|
192
|
+
- All props with types, defaults, descriptions, and options
|
|
193
|
+
- Available story examples
|
|
194
|
+
|
|
195
|
+
3. **Component File Parsing**: It also attempts to find and parse the actual component source files to extract PropTypes and additional information.
|
|
196
|
+
|
|
197
|
+
4. **Registry Building**: All this information is stored in an in-memory registry for fast access.
|
|
198
|
+
|
|
199
|
+
5. **Tool Handlers**: When a tool is called, the server queries the registry and formats the response appropriately.
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
### Running in Development Mode
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npm run dev
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
This will watch for file changes and restart the server.
|
|
210
|
+
|
|
211
|
+
### Testing
|
|
212
|
+
|
|
213
|
+
You can test the server manually by running:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npm start
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then send JSON-RPC requests via stdin. For example:
|
|
220
|
+
```json
|
|
221
|
+
{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Project Structure
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
mcp-server/
|
|
228
|
+
├── src/
|
|
229
|
+
│ ├── index.js # Main MCP server entry point
|
|
230
|
+
│ ├── tools/ # Tool implementations
|
|
231
|
+
│ │ ├── componentInfo.js
|
|
232
|
+
│ │ └── codeExample.js
|
|
233
|
+
│ ├── parsers/ # Parsers for extracting metadata
|
|
234
|
+
│ │ ├── storybookParser.js
|
|
235
|
+
│ │ └── componentParser.js
|
|
236
|
+
│ └── utils/ # Utility functions
|
|
237
|
+
│ └── fileReader.js
|
|
238
|
+
├── package.json
|
|
239
|
+
└── README.md
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Troubleshooting
|
|
243
|
+
|
|
244
|
+
### Server not starting
|
|
245
|
+
- Check that all dependencies are installed: `npm install`
|
|
246
|
+
- Verify the path to the frontend directory is correct
|
|
247
|
+
- Check that Storybook story files exist in `frontend/src/stories`
|
|
248
|
+
|
|
249
|
+
### Components not found
|
|
250
|
+
- Ensure Storybook story files follow the naming convention: `ComponentName.stories.js`
|
|
251
|
+
- Check that the story files export a default object with `title` and `component` properties
|
|
252
|
+
|
|
253
|
+
### Code examples not generating correctly
|
|
254
|
+
- Verify component names match exactly (case-sensitive)
|
|
255
|
+
- Check that props are valid for the component
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|