@frontmcp/skills 0.0.1
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/LICENSE +201 -0
- package/README.md +135 -0
- package/catalog/TEMPLATE.md +49 -0
- package/catalog/adapters/create-adapter/SKILL.md +127 -0
- package/catalog/adapters/official-adapters/SKILL.md +136 -0
- package/catalog/auth/configure-auth/SKILL.md +250 -0
- package/catalog/auth/configure-auth/references/auth-modes.md +77 -0
- package/catalog/auth/configure-session/SKILL.md +201 -0
- package/catalog/config/configure-elicitation/SKILL.md +136 -0
- package/catalog/config/configure-http/SKILL.md +167 -0
- package/catalog/config/configure-throttle/SKILL.md +189 -0
- package/catalog/config/configure-throttle/references/guard-config.md +68 -0
- package/catalog/config/configure-transport/SKILL.md +151 -0
- package/catalog/config/configure-transport/references/protocol-presets.md +57 -0
- package/catalog/deployment/build-for-browser/SKILL.md +95 -0
- package/catalog/deployment/build-for-cli/SKILL.md +100 -0
- package/catalog/deployment/build-for-sdk/SKILL.md +218 -0
- package/catalog/deployment/deploy-to-cloudflare/SKILL.md +192 -0
- package/catalog/deployment/deploy-to-lambda/SKILL.md +304 -0
- package/catalog/deployment/deploy-to-node/SKILL.md +229 -0
- package/catalog/deployment/deploy-to-node/references/Dockerfile.example +45 -0
- package/catalog/deployment/deploy-to-vercel/SKILL.md +196 -0
- package/catalog/deployment/deploy-to-vercel/references/vercel.json.example +60 -0
- package/catalog/development/create-agent/SKILL.md +563 -0
- package/catalog/development/create-agent/references/llm-config.md +46 -0
- package/catalog/development/create-job/SKILL.md +566 -0
- package/catalog/development/create-prompt/SKILL.md +400 -0
- package/catalog/development/create-provider/SKILL.md +233 -0
- package/catalog/development/create-resource/SKILL.md +437 -0
- package/catalog/development/create-skill/SKILL.md +526 -0
- package/catalog/development/create-skill-with-tools/SKILL.md +579 -0
- package/catalog/development/create-tool/SKILL.md +418 -0
- package/catalog/development/create-tool/references/output-schema-types.md +56 -0
- package/catalog/development/create-tool/references/tool-annotations.md +34 -0
- package/catalog/development/create-workflow/SKILL.md +709 -0
- package/catalog/development/decorators-guide/SKILL.md +598 -0
- package/catalog/plugins/create-plugin/SKILL.md +336 -0
- package/catalog/plugins/create-plugin-hooks/SKILL.md +282 -0
- package/catalog/plugins/official-plugins/SKILL.md +667 -0
- package/catalog/setup/frontmcp-skills-usage/SKILL.md +200 -0
- package/catalog/setup/multi-app-composition/SKILL.md +358 -0
- package/catalog/setup/nx-workflow/SKILL.md +357 -0
- package/catalog/setup/project-structure-nx/SKILL.md +186 -0
- package/catalog/setup/project-structure-standalone/SKILL.md +153 -0
- package/catalog/setup/setup-project/SKILL.md +493 -0
- package/catalog/setup/setup-redis/SKILL.md +385 -0
- package/catalog/setup/setup-sqlite/SKILL.md +359 -0
- package/catalog/skills-manifest.json +414 -0
- package/catalog/testing/setup-testing/SKILL.md +539 -0
- package/catalog/testing/setup-testing/references/test-auth.md +88 -0
- package/catalog/testing/setup-testing/references/test-browser-build.md +57 -0
- package/catalog/testing/setup-testing/references/test-cli-binary.md +48 -0
- package/catalog/testing/setup-testing/references/test-direct-client.md +62 -0
- package/catalog/testing/setup-testing/references/test-e2e-handler.md +51 -0
- package/catalog/testing/setup-testing/references/test-tool-unit.md +41 -0
- package/package.json +34 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/loader.d.ts +46 -0
- package/src/loader.js +75 -0
- package/src/loader.js.map +1 -0
- package/src/manifest.d.ts +81 -0
- package/src/manifest.js +26 -0
- package/src/manifest.js.map +1 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nx-workflow
|
|
3
|
+
description: Complete Nx monorepo workflow for FrontMCP with all generators, build, test, and deployment commands. Use when working in an Nx workspace, running generators, or managing monorepo builds.
|
|
4
|
+
tags: [nx, monorepo, generators, workflow, scaffold]
|
|
5
|
+
priority: 8
|
|
6
|
+
visibility: both
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
metadata:
|
|
9
|
+
docs: https://docs.agentfront.dev/frontmcp/nx-plugin/overview
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Nx Monorepo Workflow for FrontMCP
|
|
13
|
+
|
|
14
|
+
Use the `@frontmcp/nx` plugin to scaffold, build, test, and deploy FrontMCP projects in an Nx monorepo. The plugin provides generators for every FrontMCP primitive (tools, resources, prompts, skills, agents, plugins, adapters, providers, flows, jobs, workflows) and deployment shells for multiple targets.
|
|
15
|
+
|
|
16
|
+
## When to Use Nx
|
|
17
|
+
|
|
18
|
+
Use the Nx workflow when your project has multiple apps, shared libraries, or needs fine-grained build caching and affected-only testing. For simple single-server projects, the standalone `frontmcp create` approach is sufficient.
|
|
19
|
+
|
|
20
|
+
## Step 1 -- Initialize the Workspace
|
|
21
|
+
|
|
22
|
+
### Option A: Scaffold a new Nx workspace with the FrontMCP CLI
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx frontmcp create my-project --nx
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This creates a full Nx workspace with `@frontmcp/nx` pre-installed, sample app, and workspace configuration.
|
|
29
|
+
|
|
30
|
+
### Option B: Add FrontMCP to an existing Nx workspace
|
|
31
|
+
|
|
32
|
+
Install the plugin:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
yarn add -D @frontmcp/nx
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then initialize the workspace structure:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
nx g @frontmcp/nx:workspace my-workspace
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The workspace generator creates the directory structure (`apps/`, `libs/`, `servers/`) and base configuration. It accepts these options:
|
|
45
|
+
|
|
46
|
+
| Option | Type | Default | Description |
|
|
47
|
+
| ----------------- | ------------------------------------ | ---------- | -------------------------------- |
|
|
48
|
+
| `name` | `string` | (required) | Workspace name |
|
|
49
|
+
| `packageManager` | `'npm' \| 'yarn' \| 'pnpm' \| 'bun'` | `'npm'` | Package manager to use |
|
|
50
|
+
| `skipInstall` | `boolean` | `false` | Skip package installation |
|
|
51
|
+
| `skipGit` | `boolean` | `false` | Skip git initialization |
|
|
52
|
+
| `createSampleApp` | `boolean` | `true` | Create a sample demo application |
|
|
53
|
+
|
|
54
|
+
## Step 2 -- Generate Apps and Libraries
|
|
55
|
+
|
|
56
|
+
### Generate an App
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
nx g @frontmcp/nx:app my-app
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Creates an `@App`-decorated class in `apps/my-app/` with a tools directory, barrel exports, and project configuration. The `--project` flag is not needed for app generation since the app is the project.
|
|
63
|
+
|
|
64
|
+
### Generate a Shared Library
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
nx g @frontmcp/nx:lib my-lib
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Creates a shared library in `libs/my-lib/` with TypeScript configuration, Jest setup, and barrel exports. Use libraries for shared providers, utilities, and types that multiple apps consume.
|
|
71
|
+
|
|
72
|
+
### Generate a Server (Deployment Shell)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
nx g @frontmcp/nx:server my-server --deploymentTarget=node --apps=my-app
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Creates a `@FrontMcp`-decorated server class in `servers/my-server/` that composes one or more apps. The server is the deployment unit.
|
|
79
|
+
|
|
80
|
+
| Option | Type | Default | Description |
|
|
81
|
+
| ------------------ | ------------------------------------------------ | ---------------- | ------------------------------------- |
|
|
82
|
+
| `name` | `string` | (required) | Server name |
|
|
83
|
+
| `apps` | `string` | (required) | Comma-separated app names to compose |
|
|
84
|
+
| `deploymentTarget` | `'node' \| 'vercel' \| 'lambda' \| 'cloudflare'` | `'node'` | Deployment target platform |
|
|
85
|
+
| `directory` | `string` | `servers/<name>` | Override the default directory |
|
|
86
|
+
| `redis` | `'docker' \| 'existing' \| 'none'` | `'none'` | Redis setup option (node target only) |
|
|
87
|
+
| `skills` | `'recommended' \| 'minimal' \| 'full' \| 'none'` | `'recommended'` | Skills bundle to include |
|
|
88
|
+
|
|
89
|
+
## Step 3 -- Generate MCP Primitives
|
|
90
|
+
|
|
91
|
+
All primitive generators require `--project` to specify which app receives the generated file. Each generator creates the implementation file, a `.spec.ts` test file, and updates barrel exports.
|
|
92
|
+
|
|
93
|
+
### Tool
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
nx g @frontmcp/nx:tool my-tool --project=my-app
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Creates a `@Tool`-decorated class extending `ToolContext` in `apps/my-app/src/tools/`. Use the `--directory` option to place it in a subdirectory within `src/tools/`.
|
|
100
|
+
|
|
101
|
+
### Resource
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
nx g @frontmcp/nx:resource my-resource --project=my-app
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Creates a `@Resource`-decorated class extending `ResourceContext` in `apps/my-app/src/resources/`.
|
|
108
|
+
|
|
109
|
+
### Prompt
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
nx g @frontmcp/nx:prompt my-prompt --project=my-app
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Creates a `@Prompt`-decorated class extending `PromptContext` in `apps/my-app/src/prompts/`.
|
|
116
|
+
|
|
117
|
+
### Skill (Class-Based)
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
nx g @frontmcp/nx:skill my-skill --project=my-app
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Creates a `@Skill`-decorated class extending `SkillContext` in `apps/my-app/src/skills/`.
|
|
124
|
+
|
|
125
|
+
### Skill (SKILL.md Directory)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
nx g @frontmcp/nx:skill-dir my-skill --project=my-app
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Creates a `SKILL.md`-based skill directory in `apps/my-app/src/skills/my-skill/` with a template SKILL.md file. Use this for declarative skills that are defined by markdown instructions rather than code.
|
|
132
|
+
|
|
133
|
+
### Agent
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
nx g @frontmcp/nx:agent my-agent --project=my-app
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Creates an `@Agent`-decorated class in `apps/my-app/src/agents/`. Agents are autonomous AI components with their own LLM providers and isolated scopes, automatically exposed as `use-agent:<agent_id>` tools.
|
|
140
|
+
|
|
141
|
+
### Plugin
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
nx g @frontmcp/nx:plugin my-plugin --project=my-app
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Creates a `@Plugin` class extending `DynamicPlugin` in `apps/my-app/src/plugins/`. Plugins participate in lifecycle events and can contribute additional capabilities.
|
|
148
|
+
|
|
149
|
+
### Adapter
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
nx g @frontmcp/nx:adapter my-adapter --project=my-app
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Creates an `@Adapter` class extending `DynamicAdapter` in `apps/my-app/src/adapters/`. Adapters convert external definitions (OpenAPI, Lambda, etc.) into generated tools, resources, and prompts.
|
|
156
|
+
|
|
157
|
+
### Provider
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
nx g @frontmcp/nx:provider my-provider --project=my-app
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Creates a `@Provider` class in `apps/my-app/src/providers/`. Providers are named singletons resolved via DI (e.g., database pools, API clients, config).
|
|
164
|
+
|
|
165
|
+
### Flow
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
nx g @frontmcp/nx:flow my-flow --project=my-app
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Creates a `@Flow` class extending `FlowBase` in `apps/my-app/src/flows/`. Flows define execution pipelines with hooks and stages.
|
|
172
|
+
|
|
173
|
+
### Job
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
nx g @frontmcp/nx:job my-job --project=my-app
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Creates a `@Job` class in `apps/my-app/src/jobs/`. Jobs are pure executable units with strict input/output schemas.
|
|
180
|
+
|
|
181
|
+
### Workflow
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
nx g @frontmcp/nx:workflow my-workflow --project=my-app
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Creates a `@Workflow` class in `apps/my-app/src/workflows/`. Workflows connect jobs into managed steps with triggers.
|
|
188
|
+
|
|
189
|
+
### Auth Provider
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
nx g @frontmcp/nx:auth-provider my-auth --project=my-app
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Creates an `@AuthProvider` class in `apps/my-app/src/auth-providers/`. Auth providers handle session-based authentication (e.g., GitHub OAuth, Google OAuth).
|
|
196
|
+
|
|
197
|
+
## Step 4 -- Build and Test
|
|
198
|
+
|
|
199
|
+
### Build a Single Project
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
nx build my-server
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Builds the server and all its dependencies in the correct order. Nx caches build outputs so subsequent builds of unchanged projects are instant.
|
|
206
|
+
|
|
207
|
+
### Test a Single Project
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
nx test my-app
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Runs Jest tests for the specified project. Test files must use `.spec.ts` extension (not `.test.ts`).
|
|
214
|
+
|
|
215
|
+
### Build All Projects
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
nx run-many -t build
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Builds every project in the workspace. Nx parallelizes independent builds automatically.
|
|
222
|
+
|
|
223
|
+
### Test All Projects
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
nx run-many -t test
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Runs tests for every project in the workspace.
|
|
230
|
+
|
|
231
|
+
### Test Only Affected Projects
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
nx affected -t test
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Runs tests only for projects affected by changes since the last commit (or since the base branch). This is the fastest way to validate changes in CI.
|
|
238
|
+
|
|
239
|
+
### Build Only Affected Projects
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
nx affected -t build
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Run Multiple Targets
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
nx run-many -t build,test,lint
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Step 5 -- Workspace Structure
|
|
252
|
+
|
|
253
|
+
After scaffolding, the workspace follows this directory layout:
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
my-project/
|
|
257
|
+
apps/
|
|
258
|
+
my-app/
|
|
259
|
+
src/
|
|
260
|
+
tools/ # @Tool classes
|
|
261
|
+
resources/ # @Resource classes
|
|
262
|
+
prompts/ # @Prompt classes
|
|
263
|
+
skills/ # @Skill classes and SKILL.md dirs
|
|
264
|
+
agents/ # @Agent classes
|
|
265
|
+
plugins/ # @Plugin classes
|
|
266
|
+
adapters/ # @Adapter classes
|
|
267
|
+
providers/ # @Provider classes
|
|
268
|
+
flows/ # @Flow classes
|
|
269
|
+
jobs/ # @Job classes
|
|
270
|
+
workflows/ # @Workflow classes
|
|
271
|
+
auth-providers/ # @AuthProvider classes
|
|
272
|
+
my-app.app.ts # @App class
|
|
273
|
+
index.ts # barrel exports
|
|
274
|
+
project.json
|
|
275
|
+
tsconfig.json
|
|
276
|
+
jest.config.ts
|
|
277
|
+
libs/
|
|
278
|
+
my-lib/
|
|
279
|
+
src/
|
|
280
|
+
index.ts
|
|
281
|
+
project.json
|
|
282
|
+
servers/
|
|
283
|
+
my-server/
|
|
284
|
+
src/
|
|
285
|
+
main.ts # @FrontMcp server (default export)
|
|
286
|
+
project.json
|
|
287
|
+
Dockerfile # (node target)
|
|
288
|
+
nx.json
|
|
289
|
+
tsconfig.base.json
|
|
290
|
+
package.json
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Step 6 -- Development Workflow
|
|
294
|
+
|
|
295
|
+
### Serve in Development
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
nx serve my-server
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Or use the FrontMCP dev command:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
nx dev my-server
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Generate, Build, and Test a New Feature
|
|
308
|
+
|
|
309
|
+
A typical workflow for adding a new tool:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# 1. Generate the tool scaffold
|
|
313
|
+
nx g @frontmcp/nx:tool calculate-tax --project=billing-app
|
|
314
|
+
|
|
315
|
+
# 2. Implement the tool logic in apps/billing-app/src/tools/calculate-tax.tool.ts
|
|
316
|
+
|
|
317
|
+
# 3. Run tests for the affected app
|
|
318
|
+
nx test billing-app
|
|
319
|
+
|
|
320
|
+
# 4. Build the server that includes this app
|
|
321
|
+
nx build billing-server
|
|
322
|
+
|
|
323
|
+
# 5. Or test everything affected by your changes
|
|
324
|
+
nx affected -t test
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Visualize the Project Graph
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
nx graph
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Opens an interactive visualization of project dependencies in your browser. Useful for understanding how apps, libs, and servers relate to each other.
|
|
334
|
+
|
|
335
|
+
## Generator Reference
|
|
336
|
+
|
|
337
|
+
Complete list of all `@frontmcp/nx` generators from `generators.json`:
|
|
338
|
+
|
|
339
|
+
| Generator | Command | Description |
|
|
340
|
+
| --------------- | -------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
341
|
+
| `workspace` | `nx g @frontmcp/nx:workspace <name>` | Scaffold a full FrontMCP Nx monorepo with apps/, libs/, and servers/ |
|
|
342
|
+
| `app` | `nx g @frontmcp/nx:app <name>` | Generate a FrontMCP application in apps/ |
|
|
343
|
+
| `lib` | `nx g @frontmcp/nx:lib <name>` | Generate a shared library in libs/ |
|
|
344
|
+
| `server` | `nx g @frontmcp/nx:server <name> --apps=<apps>` | Generate a deployment shell in servers/ |
|
|
345
|
+
| `tool` | `nx g @frontmcp/nx:tool <name> --project=<app>` | Generate a @Tool class |
|
|
346
|
+
| `resource` | `nx g @frontmcp/nx:resource <name> --project=<app>` | Generate a @Resource or @ResourceTemplate class |
|
|
347
|
+
| `prompt` | `nx g @frontmcp/nx:prompt <name> --project=<app>` | Generate a @Prompt class |
|
|
348
|
+
| `skill` | `nx g @frontmcp/nx:skill <name> --project=<app>` | Generate a @Skill class |
|
|
349
|
+
| `skill-dir` | `nx g @frontmcp/nx:skill-dir <name> --project=<app>` | Generate a SKILL.md-based skill directory |
|
|
350
|
+
| `agent` | `nx g @frontmcp/nx:agent <name> --project=<app>` | Generate an @Agent class |
|
|
351
|
+
| `plugin` | `nx g @frontmcp/nx:plugin <name> --project=<app>` | Generate a @Plugin class extending DynamicPlugin |
|
|
352
|
+
| `adapter` | `nx g @frontmcp/nx:adapter <name> --project=<app>` | Generate an @Adapter class extending DynamicAdapter |
|
|
353
|
+
| `provider` | `nx g @frontmcp/nx:provider <name> --project=<app>` | Generate a @Provider class for dependency injection |
|
|
354
|
+
| `flow` | `nx g @frontmcp/nx:flow <name> --project=<app>` | Generate a @Flow class extending FlowBase |
|
|
355
|
+
| `job` | `nx g @frontmcp/nx:job <name> --project=<app>` | Generate a @Job class |
|
|
356
|
+
| `workflow` | `nx g @frontmcp/nx:workflow <name> --project=<app>` | Generate a @Workflow class |
|
|
357
|
+
| `auth-provider` | `nx g @frontmcp/nx:auth-provider <name> --project=<app>` | Generate an @AuthProvider class |
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-structure-nx
|
|
3
|
+
description: Best practices for organizing a FrontMCP Nx monorepo -- apps, libs, servers, generators, and multi-app composition. Use when working with frontmcp create --nx or an Nx workspace.
|
|
4
|
+
tags: [project, structure, nx, monorepo, organization, best-practices]
|
|
5
|
+
priority: 8
|
|
6
|
+
visibility: both
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
metadata:
|
|
9
|
+
docs: https://docs.agentfront.dev/frontmcp/nx-plugin/overview
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Nx Monorepo Project Structure
|
|
13
|
+
|
|
14
|
+
When you scaffold with `frontmcp create --nx` or add FrontMCP to an existing Nx workspace, the recommended layout separates apps, shared libraries, and server entry points:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
my-workspace/
|
|
18
|
+
├── apps/ # @App classes (one app per directory)
|
|
19
|
+
│ ├── billing/
|
|
20
|
+
│ │ ├── src/
|
|
21
|
+
│ │ │ ├── billing.app.ts
|
|
22
|
+
│ │ │ ├── tools/
|
|
23
|
+
│ │ │ ├── resources/
|
|
24
|
+
│ │ │ └── providers/
|
|
25
|
+
│ │ ├── project.json
|
|
26
|
+
│ │ └── tsconfig.json
|
|
27
|
+
│ └── crm/
|
|
28
|
+
│ ├── src/
|
|
29
|
+
│ │ ├── crm.app.ts
|
|
30
|
+
│ │ ├── tools/
|
|
31
|
+
│ │ └── resources/
|
|
32
|
+
│ ├── project.json
|
|
33
|
+
│ └── tsconfig.json
|
|
34
|
+
├── libs/ # Shared libraries
|
|
35
|
+
│ └── shared-utils/
|
|
36
|
+
│ ├── src/
|
|
37
|
+
│ │ └── index.ts
|
|
38
|
+
│ ├── project.json
|
|
39
|
+
│ └── tsconfig.json
|
|
40
|
+
├── servers/ # @FrontMcp servers composing apps
|
|
41
|
+
│ └── gateway/
|
|
42
|
+
│ ├── src/
|
|
43
|
+
│ │ └── main.ts # @FrontMcp default export
|
|
44
|
+
│ ├── project.json
|
|
45
|
+
│ └── tsconfig.json
|
|
46
|
+
├── nx.json
|
|
47
|
+
├── tsconfig.base.json
|
|
48
|
+
├── CLAUDE.md # AI config (auto-generated)
|
|
49
|
+
├── AGENTS.md
|
|
50
|
+
├── .mcp.json
|
|
51
|
+
└── .cursorrules
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Directory Roles
|
|
55
|
+
|
|
56
|
+
### apps/ -- Application Modules
|
|
57
|
+
|
|
58
|
+
Each directory under `apps/` contains a single `@App` class with its tools, resources, prompts, providers, and plugins:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// apps/billing/src/billing.app.ts
|
|
62
|
+
import { App } from '@frontmcp/sdk';
|
|
63
|
+
import { CreateInvoiceTool } from './tools/create-invoice.tool';
|
|
64
|
+
import { InvoiceResource } from './resources/invoice.resource';
|
|
65
|
+
import { StripeProvider } from './providers/stripe.provider';
|
|
66
|
+
|
|
67
|
+
@App({
|
|
68
|
+
name: 'billing',
|
|
69
|
+
tools: [CreateInvoiceTool],
|
|
70
|
+
resources: [InvoiceResource],
|
|
71
|
+
providers: [StripeProvider],
|
|
72
|
+
})
|
|
73
|
+
export class BillingApp {}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Apps are self-contained and independently testable. They do not import from other apps -- shared code goes in `libs/`.
|
|
77
|
+
|
|
78
|
+
### libs/ -- Shared Libraries
|
|
79
|
+
|
|
80
|
+
Shared providers, utilities, types, and common logic live under `libs/`:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// libs/shared-utils/src/index.ts
|
|
84
|
+
export { formatCurrency } from './format-currency';
|
|
85
|
+
export { DatabaseProvider } from './database.provider';
|
|
86
|
+
export type { AppConfig } from './app-config.interface';
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Apps and servers import from libs using Nx path aliases configured in `tsconfig.base.json`:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { DatabaseProvider } from '@my-workspace/shared-utils';
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### servers/ -- FrontMcp Entry Points
|
|
96
|
+
|
|
97
|
+
A server composes multiple apps into a single `@FrontMcp` entry point:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// servers/gateway/src/main.ts
|
|
101
|
+
import { FrontMcp } from '@frontmcp/sdk';
|
|
102
|
+
import { BillingApp } from '@my-workspace/billing';
|
|
103
|
+
import { CrmApp } from '@my-workspace/crm';
|
|
104
|
+
|
|
105
|
+
@FrontMcp({
|
|
106
|
+
info: { name: 'gateway', version: '1.0.0' },
|
|
107
|
+
apps: [BillingApp, CrmApp],
|
|
108
|
+
})
|
|
109
|
+
class GatewayServer {}
|
|
110
|
+
|
|
111
|
+
export default GatewayServer;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
You can have multiple servers composing different combinations of apps (e.g., a public-facing server and an internal admin server).
|
|
115
|
+
|
|
116
|
+
## Nx Generators
|
|
117
|
+
|
|
118
|
+
The `@frontmcp/nx-plugin` package provides generators for all entity types:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Generate a new app
|
|
122
|
+
nx g @frontmcp/nx-plugin:app crm
|
|
123
|
+
|
|
124
|
+
# Generate entities within an app
|
|
125
|
+
nx g @frontmcp/nx-plugin:tool lookup-user --project=crm
|
|
126
|
+
nx g @frontmcp/nx-plugin:resource user-profile --project=crm
|
|
127
|
+
nx g @frontmcp/nx-plugin:prompt summarize --project=crm
|
|
128
|
+
nx g @frontmcp/nx-plugin:provider database --project=crm
|
|
129
|
+
nx g @frontmcp/nx-plugin:plugin logging --project=crm
|
|
130
|
+
nx g @frontmcp/nx-plugin:agent research --project=crm
|
|
131
|
+
nx g @frontmcp/nx-plugin:job cleanup --project=crm
|
|
132
|
+
|
|
133
|
+
# Generate a new server
|
|
134
|
+
nx g @frontmcp/nx-plugin:server gateway
|
|
135
|
+
|
|
136
|
+
# Generate a shared library
|
|
137
|
+
nx g @frontmcp/nx-plugin:lib shared-utils
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Build and Test Commands
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Build a specific server
|
|
144
|
+
nx build gateway
|
|
145
|
+
|
|
146
|
+
# Test a specific app
|
|
147
|
+
nx test billing
|
|
148
|
+
|
|
149
|
+
# Run all tests
|
|
150
|
+
nx run-many -t test
|
|
151
|
+
|
|
152
|
+
# Build all projects
|
|
153
|
+
nx run-many -t build
|
|
154
|
+
|
|
155
|
+
# Lint everything
|
|
156
|
+
nx run-many -t lint
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Nx caches build and test results. Subsequent runs for unchanged projects are instant.
|
|
160
|
+
|
|
161
|
+
## AI Configuration Files
|
|
162
|
+
|
|
163
|
+
FrontMCP auto-generates AI configuration files at the workspace root:
|
|
164
|
+
|
|
165
|
+
| File | Purpose |
|
|
166
|
+
| -------------- | ---------------------------------------- |
|
|
167
|
+
| `CLAUDE.md` | Instructions for Claude Code / Claude AI |
|
|
168
|
+
| `AGENTS.md` | Instructions for agent-based AI tools |
|
|
169
|
+
| `.mcp.json` | MCP server configuration for AI IDEs |
|
|
170
|
+
| `.cursorrules` | Rules for Cursor AI editor |
|
|
171
|
+
|
|
172
|
+
These files are regenerated when you run generators or modify your workspace structure. They help AI tools understand your project layout and coding conventions.
|
|
173
|
+
|
|
174
|
+
## Dependency Graph
|
|
175
|
+
|
|
176
|
+
Nx enforces a clear dependency hierarchy:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
servers/ --> apps/ --> libs/
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- **servers** can import from **apps** and **libs**
|
|
183
|
+
- **apps** can import from **libs** only (never from other apps or servers)
|
|
184
|
+
- **libs** can import from other **libs** only
|
|
185
|
+
|
|
186
|
+
Use `nx graph` to visualize the dependency graph and ensure no circular imports exist.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-structure-standalone
|
|
3
|
+
description: Best practices for organizing a standalone FrontMCP project -- file layout, naming conventions, and folder hierarchy. Use when scaffolding with frontmcp create or organizing an existing standalone project.
|
|
4
|
+
tags: [project, structure, standalone, organization, best-practices]
|
|
5
|
+
priority: 8
|
|
6
|
+
visibility: both
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
metadata:
|
|
9
|
+
docs: https://docs.agentfront.dev/frontmcp/getting-started/quickstart
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Standalone Project Structure
|
|
13
|
+
|
|
14
|
+
When you run `frontmcp create`, the CLI scaffolds a standalone project with the following layout:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
my-project/
|
|
18
|
+
├── src/
|
|
19
|
+
│ ├── main.ts # @FrontMcp server entry (default export)
|
|
20
|
+
│ ├── my-app.app.ts # @App class
|
|
21
|
+
│ ├── tools/ # @Tool classes (*.tool.ts)
|
|
22
|
+
│ ├── resources/ # @Resource classes (*.resource.ts)
|
|
23
|
+
│ ├── prompts/ # @Prompt classes (*.prompt.ts)
|
|
24
|
+
│ ├── agents/ # @Agent classes (*.agent.ts)
|
|
25
|
+
│ ├── skills/ # @Skill classes or SKILL.md dirs
|
|
26
|
+
│ ├── providers/ # @Provider classes (*.provider.ts)
|
|
27
|
+
│ ├── plugins/ # @Plugin classes (*.plugin.ts)
|
|
28
|
+
│ └── jobs/ # @Job classes (*.job.ts)
|
|
29
|
+
├── e2e/ # E2E tests (*.e2e.spec.ts)
|
|
30
|
+
├── skills/ # Catalog skills (from --skills flag)
|
|
31
|
+
├── package.json
|
|
32
|
+
├── tsconfig.json
|
|
33
|
+
└── .env.example
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## File Naming Conventions
|
|
37
|
+
|
|
38
|
+
Every entity type uses a consistent `<name>.<type>.ts` pattern:
|
|
39
|
+
|
|
40
|
+
| Entity | File Pattern | Example |
|
|
41
|
+
| -------- | --------------- | ---------------------------- |
|
|
42
|
+
| Tool | `*.tool.ts` | `fetch-weather.tool.ts` |
|
|
43
|
+
| Resource | `*.resource.ts` | `user-profile.resource.ts` |
|
|
44
|
+
| Prompt | `*.prompt.ts` | `summarize.prompt.ts` |
|
|
45
|
+
| Agent | `*.agent.ts` | `research.agent.ts` |
|
|
46
|
+
| Skill | `*.skill.ts` | `calendar.skill.ts` |
|
|
47
|
+
| Provider | `*.provider.ts` | `database.provider.ts` |
|
|
48
|
+
| Plugin | `*.plugin.ts` | `logging.plugin.ts` |
|
|
49
|
+
| Job | `*.job.ts` | `cleanup.job.ts` |
|
|
50
|
+
| Test | `*.spec.ts` | `fetch-weather.tool.spec.ts` |
|
|
51
|
+
| E2E Test | `*.e2e.spec.ts` | `api.e2e.spec.ts` |
|
|
52
|
+
|
|
53
|
+
**One class per file.** Keep each tool, resource, prompt, etc. in its own file.
|
|
54
|
+
|
|
55
|
+
## Entry Point: main.ts
|
|
56
|
+
|
|
57
|
+
`main.ts` default-exports the `@FrontMcp` server class. This is the file FrontMCP loads at startup:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { FrontMcp } from '@frontmcp/sdk';
|
|
61
|
+
import { MyApp } from './my-app.app';
|
|
62
|
+
|
|
63
|
+
@FrontMcp({
|
|
64
|
+
info: { name: 'my-project', version: '1.0.0' },
|
|
65
|
+
apps: [MyApp],
|
|
66
|
+
})
|
|
67
|
+
class MyServer {}
|
|
68
|
+
|
|
69
|
+
export default MyServer;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## App Class
|
|
73
|
+
|
|
74
|
+
The `@App` class groups tools, resources, prompts, plugins, and providers together:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { App } from '@frontmcp/sdk';
|
|
78
|
+
import { FetchWeatherTool } from './tools/fetch-weather.tool';
|
|
79
|
+
import { DatabaseProvider } from './providers/database.provider';
|
|
80
|
+
|
|
81
|
+
@App({
|
|
82
|
+
name: 'my-app',
|
|
83
|
+
tools: [FetchWeatherTool],
|
|
84
|
+
providers: [DatabaseProvider],
|
|
85
|
+
})
|
|
86
|
+
export class MyApp {}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development Workflow
|
|
90
|
+
|
|
91
|
+
### Start development server
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
frontmcp dev
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Watches for file changes and restarts automatically.
|
|
98
|
+
|
|
99
|
+
### Build for production
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
frontmcp build --target node
|
|
103
|
+
frontmcp build --target bun
|
|
104
|
+
frontmcp build --target cloudflare-workers
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The `--target` flag determines the output format and runtime optimizations.
|
|
108
|
+
|
|
109
|
+
### Run tests
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Unit tests
|
|
113
|
+
jest
|
|
114
|
+
|
|
115
|
+
# E2E tests
|
|
116
|
+
jest --config e2e/jest.config.ts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Organizing by Feature
|
|
120
|
+
|
|
121
|
+
For larger standalone projects, group related entities into feature folders:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
src/
|
|
125
|
+
├── main.ts
|
|
126
|
+
├── my-app.app.ts
|
|
127
|
+
├── billing/
|
|
128
|
+
│ ├── create-invoice.tool.ts
|
|
129
|
+
│ ├── invoice.resource.ts
|
|
130
|
+
│ └── billing.provider.ts
|
|
131
|
+
├── users/
|
|
132
|
+
│ ├── lookup-user.tool.ts
|
|
133
|
+
│ ├── user-profile.resource.ts
|
|
134
|
+
│ └── users.provider.ts
|
|
135
|
+
└── plugins/
|
|
136
|
+
└── logging.plugin.ts
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Feature folders work well when your project has multiple related tools and resources that share a domain.
|
|
140
|
+
|
|
141
|
+
## Skills Directory
|
|
142
|
+
|
|
143
|
+
The top-level `skills/` directory (outside `src/`) holds catalog skills added via the `--skills` flag during `frontmcp create`. Each skill is a folder containing a `SKILL.md` file:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
skills/
|
|
147
|
+
├── create-tool/
|
|
148
|
+
│ └── SKILL.md
|
|
149
|
+
└── setup-project/
|
|
150
|
+
└── SKILL.md
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Skills inside `src/skills/` are `@Skill` classes that are part of your application code.
|