@agiflowai/scaffold-mcp 1.0.6 → 1.0.8

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 (37) hide show
  1. package/README.md +202 -164
  2. package/dist/ListScaffoldingMethodsTool-BLTCwsd1.mjs +350 -0
  3. package/dist/ListScaffoldingMethodsTool-BuxKRbwi.cjs +376 -0
  4. package/dist/{ScaffoldConfigLoader-B-NLy6VP.cjs → ScaffoldConfigLoader-BB4_YUFL.cjs} +1 -1
  5. package/dist/{ScaffoldConfigLoader-SHk-KEje.mjs → ScaffoldConfigLoader-DKJtnrWT.mjs} +1 -1
  6. package/dist/ScaffoldService-BCjJE9yK.mjs +3 -0
  7. package/dist/ScaffoldService-Bhzxp5-C.cjs +3 -0
  8. package/dist/TemplateService-B1bd6iHw.mjs +3 -0
  9. package/dist/TemplateService-BrJGDvQt.cjs +3 -0
  10. package/dist/VariableReplacementService-BO-UYgcf.mjs +3 -0
  11. package/dist/{VariableReplacementService-DKaF2C9l.cjs → VariableReplacementService-CNimgwaq.cjs} +1 -1
  12. package/dist/cli.cjs +89 -11
  13. package/dist/cli.mjs +84 -6
  14. package/dist/index.cjs +9 -8
  15. package/dist/index.d.cts +7 -0
  16. package/dist/index.d.mts +7 -0
  17. package/dist/index.mjs +6 -5
  18. package/dist/{stdio-BGj_FLky.cjs → stdio-BcTSxlVH.cjs} +47 -367
  19. package/dist/{stdio-wAlpLC6l.mjs → stdio-DovjJsGY.mjs} +42 -347
  20. package/dist/useScaffoldMethod-Btc_9iCj.cjs +237 -0
  21. package/dist/useScaffoldMethod-C1hQdBVD.cjs +267 -0
  22. package/dist/useScaffoldMethod-CHJAsgA2.mjs +236 -0
  23. package/dist/useScaffoldMethod-CsBTssSw.mjs +263 -0
  24. package/package.json +6 -2
  25. package/dist/ScaffoldService-BNOyoqSb.cjs +0 -3
  26. package/dist/ScaffoldService-BNdfC21Z.mjs +0 -3
  27. package/dist/TemplateService-BRfzfaZs.mjs +0 -3
  28. package/dist/TemplateService-DqieT1Tq.cjs +0 -3
  29. package/dist/VariableReplacementService-BWCd-z7X.mjs +0 -3
  30. /package/dist/{ScaffoldConfigLoader-BDMJNI1o.mjs → ScaffoldConfigLoader-8YI7v2GJ.mjs} +0 -0
  31. /package/dist/{ScaffoldConfigLoader-Y_SBLPg7.cjs → ScaffoldConfigLoader-CQlXVksz.cjs} +0 -0
  32. /package/dist/{ScaffoldService-ChzxM0Yc.cjs → ScaffoldService-BPyiY_0B.cjs} +0 -0
  33. /package/dist/{ScaffoldService-BNuN00Fm.mjs → ScaffoldService-CgYunbKN.mjs} +0 -0
  34. /package/dist/{TemplateService-D3ydJR_R.cjs → TemplateService-CAD8jkoO.cjs} +0 -0
  35. /package/dist/{TemplateService-Cg5QV29n.mjs → TemplateService-CVDL2uqt.mjs} +0 -0
  36. /package/dist/{VariableReplacementService-DHIINRnJ.mjs → VariableReplacementService-B9RA8D0a.mjs} +0 -0
  37. /package/dist/{VariableReplacementService-CAjesAYq.cjs → VariableReplacementService-DDG5KZpb.cjs} +0 -0
package/README.md CHANGED
@@ -1,246 +1,284 @@
1
1
  # @agiflowai/scaffold-mcp
2
2
 
3
- A Model Context Protocol (MCP) server for scaffolding applications with boilerplate templates and feature generators. Supports multiple transport modes: **stdio**, **HTTP**, **SSE**, and **CLI**.
3
+ > MCP server for scaffolding applications with templates and feature generators
4
4
 
5
- ## Features
5
+ Generate consistent, convention-following code for your AI coding agents. scaffold-mcp provides templates for common patterns (routes, components, services) so agents don't write boilerplate from scratch.
6
6
 
7
- - **Boilerplate scaffolding**: Generate complete application structures from templates
8
- - **Feature scaffolding**: Add features to existing projects with custom generators
9
- - **Custom generators**: Template-specific TypeScript generators for advanced scaffolding logic
10
- - **Liquid templating**: Use powerful templating engine for dynamic file generation
11
- - **Variable replacement**: Customize generated code with context-aware variable substitution
12
- - **Dynamic template discovery**: Automatically finds templates in your workspace
13
- - **Multiple frameworks**: Support for Next.js, Vite React, and custom boilerplates
14
- - **Multiple modes**: MCP server mode (stdio/HTTP/SSE) and standalone CLI mode
15
- - **MCP integration**: Seamlessly works with Claude Code and other MCP-compatible clients
7
+ ## Why Use This?
16
8
 
17
- ## Installation
9
+ When you ask an AI agent to "add a new page," it generates working code—but not necessarily code that follows your team's patterns. scaffold-mcp solves this by:
18
10
 
19
- ```bash
20
- pnpm install @agiflowai/scaffold-mcp
21
- ```
11
+ 1. **Providing templates** for common patterns your team has standardized
12
+ 2. **Enforcing structure** so every route, component, or service looks the same
13
+ 3. **Reducing boilerplate** by generating the repetitive parts automatically
22
14
 
23
- ## Usage
15
+ Think of it as "Rails generators" or "Angular schematics" for any stack.
24
16
 
25
- ### 1. MCP Server
17
+ ---
26
18
 
27
- Run scaffold-mcp as an MCP server to integrate with Claude Code or other MCP clients.
19
+ ## Quick Start
28
20
 
29
- #### Starting the Server
21
+ ### 1. Install Templates
30
22
 
31
23
  ```bash
32
- # stdio transport (default) - for Claude Code
33
- npx @agiflowai/scaffold-mcp mcp-serve
34
-
35
- # HTTP transport - for web applications
36
- npx @agiflowai/scaffold-mcp mcp-serve --type http --port 3000
37
-
38
- # SSE transport - for legacy clients
39
- npx @agiflowai/scaffold-mcp mcp-serve --type sse --port 3000
40
-
41
- # Enable admin mode (template generation tools)
42
- npx @agiflowai/scaffold-mcp mcp-serve --admin-enable
24
+ # Downloads built-in templates to your workspace
25
+ npx @agiflowai/aicode-toolkit init
43
26
  ```
44
27
 
45
- **Server Options:**
46
- - `-t, --type <type>`: Transport type: `stdio`, `http`, or `sse` (default: `stdio`)
47
- - `-p, --port <port>`: Port for HTTP/SSE servers (default: `3000`)
48
- - `--host <host>`: Host to bind to for HTTP/SSE (default: `localhost`)
49
- - `--admin-enable`: Enable admin tools for template generation
50
-
51
- #### Claude Code Configuration
28
+ ### 2. Configure Your AI Agent
52
29
 
53
- Add to your Claude Code config:
30
+ Add to your MCP config (`.mcp.json`, `.cursor/mcp.json`, etc.):
54
31
 
55
32
  ```json
56
33
  {
57
34
  "mcpServers": {
58
35
  "scaffold-mcp": {
59
36
  "command": "npx",
60
- "args": ["-y", "@agiflowai/scaffold-mcp", "mcp-serve"]
37
+ "args": ["-y", "@agiflowai/scaffold-mcp", "mcp-serve", "--admin-enable"]
61
38
  }
62
39
  }
63
40
  }
64
41
  ```
65
42
 
66
- Or if installed globally:
43
+ **Flags:**
44
+ - `--admin-enable`: Enables tools for creating new templates (optional, useful during setup)
67
45
 
68
- ```json
69
- {
70
- "mcpServers": {
71
- "scaffold-mcp": {
72
- "command": "scaffold-mcp",
73
- "args": ["mcp-serve"]
74
- }
75
- }
76
- }
77
- ```
46
+ ### 3. Start Using
78
47
 
79
- **To enable admin tools** (for template creation), add the `--admin-enable` flag:
48
+ Your AI agent now has access to scaffolding tools:
80
49
 
81
- ```json
82
- {
83
- "mcpServers": {
84
- "scaffold-mcp": {
85
- "command": "npx",
86
- "args": ["-y", "@agiflowai/scaffold-mcp", "mcp-serve", "--admin-enable"]
87
- }
88
- }
89
- }
90
50
  ```
51
+ You: "Create a new Next.js app called dashboard"
52
+ Agent: [calls list-boilerplates, then use-boilerplate]
91
53
 
92
- #### Available MCP Tools
54
+ You: "Add a products page"
55
+ Agent: [calls list-scaffolding-methods, then use-scaffold-method]
56
+ ```
93
57
 
94
- **Standard Tools** (always available):
58
+ ---
95
59
 
96
- 1. **list-boilerplates**: List all available project boilerplates
97
- - Returns: Array of boilerplate configurations with schemas
60
+ ## Available Tools
98
61
 
99
- 2. **use-boilerplate**: Create a new project from a boilerplate template
100
- - Arguments:
101
- - `boilerplateName` (string): Name of the boilerplate
102
- - `variables` (object): Variables matching the boilerplate's schema
62
+ ### Standard Tools
103
63
 
104
- 3. **list-scaffolding-methods**: List available features for a project
105
- - Arguments:
106
- - `projectPath` (string): Absolute path to project directory
64
+ | Tool | Purpose | When to Use |
65
+ |------|---------|-------------|
66
+ | `list-boilerplates` | Show available project templates | Starting a new project |
67
+ | `use-boilerplate` | Create project from template | After choosing a template |
68
+ | `list-scaffolding-methods` | Show features for a project | Adding to existing project |
69
+ | `use-scaffold-method` | Add feature to project | After choosing a feature |
70
+ | `write-to-file` | Write content to file | Custom files not in templates |
107
71
 
108
- 4. **use-scaffold-method**: Add a feature to an existing project
109
- - Arguments:
110
- - `projectPath` (string): Absolute path to project directory
111
- - `scaffold_feature_name` (string): Name of the feature to add
112
- - `variables` (object): Variables for the feature
72
+ ### Admin Tools (with `--admin-enable`)
113
73
 
114
- 5. **write-to-file**: Write content to a file
115
- - Arguments:
116
- - `file_path` (string): Path to the file
117
- - `content` (string): Content to write
74
+ | Tool | Purpose | When to Use |
75
+ |------|---------|-------------|
76
+ | `generate-boilerplate` | Create new project template | Building custom templates |
77
+ | `generate-feature-scaffold` | Create new feature scaffold | Adding feature generators |
78
+ | `generate-boilerplate-file` | Add files to templates | Populating template files |
118
79
 
119
- **Admin Tools** (enabled with `--admin-enable` flag):
80
+ ---
120
81
 
121
- 6. **generate-boilerplate**: Create a new boilerplate configuration in a template's scaffold.yaml
122
- - Arguments:
123
- - `templateName` (string): Name of the template folder
124
- - `boilerplateName` (string): Name of the boilerplate (kebab-case)
125
- - `description` (string): Detailed description
126
- - `targetFolder` (string): Target folder for projects
127
- - `variables` (array): Variable definitions with schema
128
- - `includes` (array): Template files to include
129
- - `instruction` (string, optional): Usage instructions
82
+ ## How It Works
130
83
 
131
- 7. **generate-feature-scaffold**: Create a new feature configuration in a template's scaffold.yaml
132
- - Arguments:
133
- - `templateName` (string): Name of the template folder
134
- - `featureName` (string): Name of the feature (kebab-case)
135
- - `description` (string): Feature description
136
- - `variables` (array): Variable definitions with schema
137
- - `includes` (array, optional): Template files to include
138
- - `patterns` (array, optional): File patterns this feature works with
139
- - `instruction` (string, optional): Usage instructions
84
+ ```
85
+ Your Project Templates Directory
86
+ ───────────── ───────────────────
87
+ apps/
88
+ ├── my-app/ templates/
89
+ │ ├── project.json ──────────────► └── nextjs-15/
90
+ │ │ └── sourceTemplate: "nextjs-15" ├── scaffold.yaml ← Defines what can be generated
91
+ │ └── src/ ├── architect.yaml ← Design patterns (optional)
92
+ │ └── app/ ├── RULES.yaml ← Coding rules (optional)
93
+ │ └── page.tsx └── src/ ← Template files (.liquid)
94
+ ```
95
+
96
+ 1. **Templates define patterns**: Each template has a `scaffold.yaml` that defines boilerplates and features
97
+ 2. **Projects reference templates**: Your `project.json` has a `sourceTemplate` field pointing to the template
98
+ 3. **Tools generate code**: MCP tools read the template and generate files in your project
140
99
 
141
- 8. **generate-boilerplate-file**: Create template files for boilerplates or features
142
- - Arguments:
143
- - `templateName` (string): Name of the template folder
144
- - `filePath` (string): Path of the file within the template
145
- - `content` (string): File content with Liquid variables
146
- - `header` (string, optional): Header comment for AI hints
147
- - `sourceFile` (string, optional): Copy from existing source file
100
+ ---
148
101
 
149
- ### 2. CLI Commands
102
+ ## Built-in Templates
150
103
 
151
- Use scaffold-mcp as a standalone CLI tool for scaffolding projects and adding features.
104
+ | Template | Stack | What You Can Generate |
105
+ |----------|-------|----------------------|
106
+ | `nextjs-15-drizzle` | Next.js 15 + App Router | Pages, layouts, components, API routes |
107
+ | `typescript-lib` | TypeScript library | Library structure, tests |
108
+ | `typescript-mcp-package` | MCP server | CLI commands, MCP tools |
152
109
 
153
- **Note:** Template management (init, add) is now handled by the `@agiflowai/aicode-toolkit` CLI. See [aicode-toolkit documentation](../../apps/aicode-toolkit/README.md) for details.
110
+ ---
154
111
 
155
- #### Boilerplate Commands
112
+ ## CLI Commands
113
+
114
+ scaffold-mcp also works as a standalone CLI:
156
115
 
157
116
  ```bash
158
117
  # List available boilerplates
159
- scaffold-mcp boilerplate list
118
+ npx @agiflowai/scaffold-mcp boilerplate list
160
119
 
161
- # Show boilerplate details
162
- scaffold-mcp boilerplate info <boilerplate-name>
120
+ # Get info about a boilerplate
121
+ npx @agiflowai/scaffold-mcp boilerplate info nextjs-15-drizzle
163
122
 
164
123
  # Create project from boilerplate
165
- scaffold-mcp boilerplate create <name> --vars '{"appName":"my-app"}'
166
- scaffold-mcp boilerplate create nextjs-15-boilerplate \
167
- --vars '{"projectName":"my-app","packageName":"@myorg/my-app"}' \
168
- --verbose
124
+ npx @agiflowai/scaffold-mcp boilerplate create nextjs-15-drizzle \
125
+ --vars '{"projectName":"my-app","packageName":"@myorg/my-app"}'
126
+
127
+ # List features for a project
128
+ npx @agiflowai/scaffold-mcp scaffold list ./apps/my-app
129
+
130
+ # Add feature to project
131
+ npx @agiflowai/scaffold-mcp scaffold add scaffold-nextjs-page \
132
+ --project ./apps/my-app \
133
+ --vars '{"pageTitle":"About","nextjsPagePath":"/about"}'
169
134
  ```
170
135
 
171
- #### Scaffold Commands
136
+ ---
137
+
138
+ ## Server Options
172
139
 
173
140
  ```bash
174
- # List scaffolding methods for a project
175
- scaffold-mcp scaffold list ./apps/my-app
141
+ # stdio transport (default) - for Claude Code, Cursor
142
+ npx @agiflowai/scaffold-mcp mcp-serve
176
143
 
177
- # Show scaffold method details
178
- scaffold-mcp scaffold info <feature-name> --project ./apps/my-app
144
+ # HTTP transport - for web applications
145
+ npx @agiflowai/scaffold-mcp mcp-serve --type http --port 3000
179
146
 
180
- # Add feature to project
181
- scaffold-mcp scaffold add <feature> --project ./apps/my-app --vars '{"name":"MyFeature"}'
182
- scaffold-mcp scaffold add scaffold-nextjs-page \
183
- --project ./apps/my-app \
184
- --vars '{"pageTitle":"About Us","nextjsPagePath":"/about"}' \
185
- --verbose
147
+ # SSE transport - for streaming clients
148
+ npx @agiflowai/scaffold-mcp mcp-serve --type sse --port 3000
149
+
150
+ # With admin tools enabled
151
+ npx @agiflowai/scaffold-mcp mcp-serve --admin-enable
186
152
  ```
187
153
 
188
- #### Environment Variables
154
+ | Option | Description | Default |
155
+ |--------|-------------|---------|
156
+ | `-t, --type` | Transport: `stdio`, `http`, `sse` | `stdio` |
157
+ | `-p, --port` | Port for HTTP/SSE | `3000` |
158
+ | `--host` | Host for HTTP/SSE | `localhost` |
159
+ | `--admin-enable` | Enable template creation tools | `false` |
189
160
 
190
- - `MCP_PORT`: Port number for HTTP/SSE servers (default: 3000)
191
- - `MCP_HOST`: Host for HTTP/SSE servers (default: localhost)
161
+ ---
192
162
 
193
- ## Quick Start
163
+ ## Creating Custom Templates
194
164
 
195
- ### 1. Setup Templates
165
+ ### Option 1: Using Admin Tools (Recommended)
196
166
 
197
- For template management (downloading and managing templates), use the `@agiflowai/aicode-toolkit` CLI:
167
+ Ask your AI agent:
168
+ ```
169
+ "Create a boilerplate template for our React + Vite setup"
170
+ ```
198
171
 
199
- ```bash
200
- # Initialize workspace and download templates
201
- npx @agiflowai/aicode-toolkit init
172
+ The agent will use:
173
+ 1. `generate-boilerplate` - Creates scaffold.yaml entry
174
+ 2. `generate-boilerplate-file` - Adds template files
202
175
 
203
- # Add custom templates
204
- npx @agiflowai/aicode-toolkit add --name my-template --url https://github.com/user/template
205
- ```
176
+ ### Option 2: Manually
206
177
 
207
- See the [aicode-toolkit documentation](../../apps/aicode-toolkit/README.md) for complete setup instructions.
178
+ Create the template structure:
208
179
 
209
- ### 2. Create a New Project
180
+ ```
181
+ templates/my-template/
182
+ ├── scaffold.yaml # Required: defines boilerplates and features
183
+ └── src/ # Template files (use .liquid for variable replacement)
184
+ ├── package.json.liquid
185
+ └── src/
186
+ └── index.ts.liquid
187
+ ```
210
188
 
211
- ```bash
212
- # List available boilerplates
213
- scaffold-mcp boilerplate list
189
+ **scaffold.yaml example:**
190
+
191
+ ```yaml
192
+ boilerplate:
193
+ name: my-template-app
194
+ description: My custom application template
195
+ targetFolder: apps
196
+ variables_schema:
197
+ type: object
198
+ properties:
199
+ projectName:
200
+ type: string
201
+ description: Project directory name
202
+ packageName:
203
+ type: string
204
+ description: NPM package name
205
+ required:
206
+ - projectName
207
+ - packageName
208
+ includes:
209
+ - package.json
210
+ - src/index.ts
211
+
212
+ features:
213
+ - name: scaffold-component
214
+ description: Add a React component
215
+ variables_schema:
216
+ type: object
217
+ properties:
218
+ componentName:
219
+ type: string
220
+ description: Component name (PascalCase)
221
+ required:
222
+ - componentName
223
+ includes:
224
+ - src/components/{{ componentName }}/{{ componentName }}.tsx
225
+ ```
214
226
 
215
- # Get info about a specific boilerplate
216
- scaffold-mcp boilerplate info nextjs-15-boilerplate
227
+ **Template file example (package.json.liquid):**
217
228
 
218
- # Create a new Next.js 15 project
219
- scaffold-mcp boilerplate create nextjs-15-boilerplate \
220
- --vars '{"projectName":"my-app","packageName":"@myorg/my-app","appName":"My App"}'
229
+ ```json
230
+ {
231
+ "name": "{{ packageName }}",
232
+ "version": "0.1.0",
233
+ "description": "{{ description | default: 'My application' }}"
234
+ }
221
235
  ```
222
236
 
223
- ### 3. Add Features to Existing Projects
237
+ ---
224
238
 
225
- ```bash
226
- # List available features for your project
227
- scaffold-mcp scaffold list /path/to/your/project
239
+ ## Hooks Integration (Experimental)
240
+
241
+ > **Note:** This feature is experimental and may change.
228
242
 
229
- # Get info about a specific scaffold method
230
- scaffold-mcp scaffold info scaffold-nextjs-page --project /path/to/your/project
243
+ Hooks let scaffold-mcp proactively suggest templates when your AI agent creates files.
231
244
 
232
- # Add a new Next.js page
233
- scaffold-mcp scaffold add scaffold-nextjs-page \
234
- --project /path/to/your/project \
235
- --vars '{"pageTitle":"About Us","pageDescription":"Learn more","nextjsPagePath":"/about"}'
245
+ **Claude Code setup** (`.claude/settings.json`):
246
+
247
+ ```json
248
+ {
249
+ "hooks": {
250
+ "PreToolUse": [
251
+ {
252
+ "matcher": "Write",
253
+ "hooks": [
254
+ {
255
+ "type": "command",
256
+ "command": "npx @agiflowai/scaffold-mcp hook --type claude-code.preToolUse"
257
+ }
258
+ ]
259
+ }
260
+ ]
261
+ }
262
+ }
236
263
  ```
237
264
 
265
+ When Claude tries to write a new file, the hook shows available scaffolding methods that match, so Claude can use templates instead of writing from scratch.
266
+
267
+ See [Hooks Documentation](./docs/hooks.md) for details.
268
+
269
+ ---
270
+
238
271
  ## Documentation
239
272
 
240
- - [CLI Commands](./docs/cli-commands.md) - Complete CLI reference
241
- - [MCP Tools](./docs/mcp-tools.md) - MCP server tools reference
242
- - [Template Conventions](./docs/template-conventions.md) - Guide for creating templates with Liquid syntax
243
- - [Advanced Generators](./docs/advanced-generators.md) - Guide for creating custom TypeScript generators
273
+ | Document | Description |
274
+ |----------|-------------|
275
+ | [MCP Tools Reference](./docs/mcp-tools.md) | Detailed tool documentation |
276
+ | [CLI Commands](./docs/cli-commands.md) | Complete CLI reference |
277
+ | [Template Conventions](./docs/template-conventions.md) | How to create templates |
278
+ | [Advanced Generators](./docs/advanced-generators.md) | Custom TypeScript generators |
279
+ | [Hooks Integration](./docs/hooks.md) | AI agent hooks setup |
280
+
281
+ ---
244
282
 
245
283
  ## License
246
284