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