@buildpad/mcp 0.1.4
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/README.md +316 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8210 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# @buildpad/mcp
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for Buildpad components. Enables AI agents like VS Code Copilot to discover, understand, and generate code using the **Copy & Own** distribution model.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@buildpad/mcp)
|
|
6
|
+
|
|
7
|
+
## What is MCP?
|
|
8
|
+
|
|
9
|
+
The [Model Context Protocol](https://modelcontextprotocol.io) is an open standard that enables AI assistants to securely access external data sources and tools. This MCP server exposes the Buildpad component library to AI agents.
|
|
10
|
+
|
|
11
|
+
## Copy & Own Model
|
|
12
|
+
|
|
13
|
+
Buildpad uses the **Copy & Own** distribution model (similar to shadcn/ui):
|
|
14
|
+
|
|
15
|
+
- ✅ Components are copied as source code to your project
|
|
16
|
+
- ✅ Full customization - components become your application code
|
|
17
|
+
- ✅ No external package dependencies for component code
|
|
18
|
+
- ✅ No breaking changes from upstream updates
|
|
19
|
+
- ✅ Works offline after installation
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- 📦 **Component Discovery** - List all available Buildpad components
|
|
24
|
+
- 📖 **Source Code Access** - Read component source code and documentation
|
|
25
|
+
- 🛠️ **Code Generation** - Generate components, forms, and interfaces
|
|
26
|
+
- 🔧 **CLI Integration** - Get CLI commands to install components
|
|
27
|
+
- 📚 **Usage Examples** - Get real-world usage examples with local imports
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### For VS Code Copilot (Recommended — via npx)
|
|
32
|
+
|
|
33
|
+
The MCP server is published on npm. No local build required.
|
|
34
|
+
|
|
35
|
+
Add to your VS Code `settings.json` or `.vscode/mcp.json`:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcp": {
|
|
40
|
+
"servers": {
|
|
41
|
+
"buildpad": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["@buildpad/mcp@latest"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Reload VS Code window.
|
|
51
|
+
|
|
52
|
+
### For VS Code Copilot (Local build)
|
|
53
|
+
|
|
54
|
+
For development within the monorepo:
|
|
55
|
+
|
|
56
|
+
1. Build the MCP server:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm build:mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. Add to your VS Code `settings.json` or `.vscode/mcp.json`:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcp": {
|
|
67
|
+
"servers": {
|
|
68
|
+
"buildpad": {
|
|
69
|
+
"command": "node",
|
|
70
|
+
"args": [
|
|
71
|
+
"/absolute/path/to/buildpad-ui/packages/mcp-server/dist/index.js"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
3. Reload VS Code window
|
|
80
|
+
|
|
81
|
+
### For Other AI Agents
|
|
82
|
+
|
|
83
|
+
Use any MCP-compatible client:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
87
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
88
|
+
|
|
89
|
+
const transport = new StdioClientTransport({
|
|
90
|
+
command: "node",
|
|
91
|
+
args: ["/path/to/buildpad-ui/packages/mcp-server/dist/index.js"],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const client = new Client({
|
|
95
|
+
name: "my-app",
|
|
96
|
+
version: "1.0.0",
|
|
97
|
+
}, {
|
|
98
|
+
capabilities: {},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await client.connect(transport);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Available Resources
|
|
105
|
+
|
|
106
|
+
### Packages
|
|
107
|
+
|
|
108
|
+
- `buildpad://packages/types` - TypeScript type definitions
|
|
109
|
+
- `buildpad://packages/services` - CRUD service classes
|
|
110
|
+
- `buildpad://packages/hooks` - React hooks for relations
|
|
111
|
+
- `buildpad://packages/ui-interfaces` - Field interface components
|
|
112
|
+
- `buildpad://packages/ui-collections` - Dynamic collection components
|
|
113
|
+
|
|
114
|
+
### Components
|
|
115
|
+
|
|
116
|
+
- `buildpad://components/Input` - Text input component
|
|
117
|
+
- `buildpad://components/SelectDropdown` - Dropdown select
|
|
118
|
+
- `buildpad://components/DateTime` - Date/time picker
|
|
119
|
+
- `buildpad://components/FileImage` - Image upload
|
|
120
|
+
- `buildpad://components/CollectionForm` - Dynamic form
|
|
121
|
+
- ... and many more
|
|
122
|
+
|
|
123
|
+
## Available Tools
|
|
124
|
+
|
|
125
|
+
### `list_components`
|
|
126
|
+
|
|
127
|
+
List all available components with descriptions and categories.
|
|
128
|
+
|
|
129
|
+
### `get_component`
|
|
130
|
+
|
|
131
|
+
Get detailed information and source code for a specific component.
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"name": "Input"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `list_packages`
|
|
140
|
+
|
|
141
|
+
List all Buildpad packages with their exports.
|
|
142
|
+
|
|
143
|
+
### `get_install_command`
|
|
144
|
+
|
|
145
|
+
Get the CLI command to install components. Essential for AI agents to help users add components.
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"components": ["input", "select-dropdown", "datetime"]
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Or install by category:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"category": "selection"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `get_copy_own_info`
|
|
162
|
+
|
|
163
|
+
Get detailed information about the Copy & Own distribution model.
|
|
164
|
+
|
|
165
|
+
### `copy_component`
|
|
166
|
+
|
|
167
|
+
Get complete source code and file structure to manually copy a component into your project (shadcn-style). Returns the full implementation code, target paths, and required dependencies.
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"name": "datetime",
|
|
172
|
+
"includeLib": true
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
- Full component source code
|
|
178
|
+
- Target file paths
|
|
179
|
+
- Required lib modules (types, services, hooks)
|
|
180
|
+
- Peer dependencies to install
|
|
181
|
+
- Copy instructions
|
|
182
|
+
|
|
183
|
+
### `generate_form`
|
|
184
|
+
|
|
185
|
+
Generate a CollectionForm component with specified configuration.
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"collection": "products",
|
|
190
|
+
"fields": ["title", "description", "price"],
|
|
191
|
+
"mode": "create"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### `generate_interface`
|
|
196
|
+
|
|
197
|
+
Generate a field interface component.
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"type": "input",
|
|
202
|
+
"field": "title",
|
|
203
|
+
"props": {
|
|
204
|
+
"placeholder": "Enter title",
|
|
205
|
+
"required": true
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### `get_usage_example`
|
|
211
|
+
|
|
212
|
+
Get real-world usage examples for a component (with local imports).
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"component": "SelectDropdown"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### `get_rbac_pattern`
|
|
221
|
+
|
|
222
|
+
Get RBAC (Role-Based Access Control) setup patterns for DaaS applications. Returns step-by-step MCP tool call sequences to set up roles, policies, access, and permissions.
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"pattern": "own_items",
|
|
227
|
+
"collections": ["articles", "categories"],
|
|
228
|
+
"roleName": "Editor"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Available patterns:**
|
|
233
|
+
| Pattern | Description |
|
|
234
|
+
|---------|-------------|
|
|
235
|
+
| `own_items` | Users manage their own records, read others' published items |
|
|
236
|
+
| `role_hierarchy` | Admin > Editor > Viewer cascading permissions |
|
|
237
|
+
| `public_read` | Public read + authenticated write |
|
|
238
|
+
| `multi_tenant` | Organization-level data isolation |
|
|
239
|
+
| `full_crud` | Unrestricted CRUD access |
|
|
240
|
+
| `read_only` | Read-only access |
|
|
241
|
+
|
|
242
|
+
**Dynamic variables supported:** `$CURRENT_USER`, `$CURRENT_USER.<field>`, `$CURRENT_ROLE`, `$CURRENT_ROLES`, `$CURRENT_POLICIES`, `$NOW`
|
|
243
|
+
|
|
244
|
+
## Usage with Copilot
|
|
245
|
+
|
|
246
|
+
Once configured, you can ask Copilot:
|
|
247
|
+
|
|
248
|
+
- "How do I install Buildpad components?" (uses `get_copy_own_info`)
|
|
249
|
+
- "Add the Input and SelectDropdown components to my project" (uses `get_install_command`)
|
|
250
|
+
- "Show me how to use the Input component" (uses `get_usage_example`)
|
|
251
|
+
- "Generate a form for a products collection" (uses `generate_form`)
|
|
252
|
+
- "List all available selection components" (uses `list_components`)
|
|
253
|
+
- "Show me the source code for CollectionForm" (uses `get_component`)
|
|
254
|
+
- "Set up RBAC with own_items pattern for articles" (uses `get_rbac_pattern`)
|
|
255
|
+
- "Generate role hierarchy for Admin, Editor, Viewer" (uses `get_rbac_pattern`)
|
|
256
|
+
|
|
257
|
+
The AI agent will provide CLI commands that you can run to install components.
|
|
258
|
+
|
|
259
|
+
## Development
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Build
|
|
263
|
+
pnpm build
|
|
264
|
+
|
|
265
|
+
# Watch mode
|
|
266
|
+
pnpm dev
|
|
267
|
+
|
|
268
|
+
# Type check
|
|
269
|
+
pnpm typecheck
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Architecture
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
┌─────────────────────────────────────────┐
|
|
276
|
+
│ AI Agent (VS Code Copilot, etc.) │
|
|
277
|
+
└────────────────┬────────────────────────┘
|
|
278
|
+
│ MCP Protocol
|
|
279
|
+
┌────────────────▼────────────────────────┐
|
|
280
|
+
│ @buildpad/mcp │
|
|
281
|
+
│ ┌──────────────────────────────────┐ │
|
|
282
|
+
│ │ Resource Handlers │ │
|
|
283
|
+
│ │ - List components │ │
|
|
284
|
+
│ │ - Read component source │ │
|
|
285
|
+
│ │ - Get documentation │ │
|
|
286
|
+
│ └──────────────────────────────────┘ │
|
|
287
|
+
│ ┌──────────────────────────────────┐ │
|
|
288
|
+
│ │ Tool Handlers │ │
|
|
289
|
+
│ │ - get_install_command │ │
|
|
290
|
+
│ │ - get_copy_own_info │ │
|
|
291
|
+
│ │ - generate_form │ │
|
|
292
|
+
│ │ - generate_interface │ │
|
|
293
|
+
│ │ - get_usage_example │ │
|
|
294
|
+
│ │ - get_rbac_pattern │ │
|
|
295
|
+
│ └──────────────────────────────────┘ │
|
|
296
|
+
│ ┌──────────────────────────────────┐ │
|
|
297
|
+
│ │ Component Registry (embedded) │ │
|
|
298
|
+
│ │ - Metadata & Categories │ │
|
|
299
|
+
│ │ - Dependencies │ │
|
|
300
|
+
│ │ - File mappings │ │
|
|
301
|
+
│ └──────────────────────────────────┘ │
|
|
302
|
+
└─────────────────────────────────────────┘
|
|
303
|
+
│
|
|
304
|
+
┌────────────────▼────────────────────────┐
|
|
305
|
+
│ @buildpad/cli (npm) │
|
|
306
|
+
│ npx @buildpad/cli@latest add <comp> │
|
|
307
|
+
│ - Fetches source from GitHub CDN │
|
|
308
|
+
│ - Transforms imports │
|
|
309
|
+
│ - Resolves dependencies │
|
|
310
|
+
│ - Copies to user project │
|
|
311
|
+
└─────────────────────────────────────────┘
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|