@frontmcp/skills 1.9.0 → 1.9.1-rc.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/catalog/frontmcp-setup/examples/multi-app-composition/local-apps-with-shared-tools.md
CHANGED
|
@@ -5,10 +5,10 @@ level: basic
|
|
|
5
5
|
description: 'Compose multiple local `@App` classes into a server with shared tools available to all apps.'
|
|
6
6
|
tags: [setup, multi-app, local, multi, app, composition]
|
|
7
7
|
features:
|
|
8
|
-
- 'Multiple `@App` classes with unique `id` fields
|
|
9
|
-
- 'Server-level `tools` array for shared tools
|
|
8
|
+
- 'Multiple `@App` classes with unique `id` fields, which prefix their tools when two tools share a name (`billing:charge`)'
|
|
9
|
+
- 'Server-level `tools` array for shared tools every app serves under their own name (`server:<name>` when an app tool has the same name)'
|
|
10
10
|
- 'Each app is self-contained with its own tools array'
|
|
11
|
-
- 'The `id` field on `@App`
|
|
11
|
+
- 'The `id` field on `@App` is the prefix of its tools when names collide'
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# Local Apps with Shared Tools
|
|
@@ -20,6 +20,7 @@ Compose multiple local `@App` classes into a server with shared tools available
|
|
|
20
20
|
```typescript
|
|
21
21
|
// src/apps/billing.app.ts
|
|
22
22
|
import { App } from '@frontmcp/sdk';
|
|
23
|
+
|
|
23
24
|
import { ChargeTool } from '../tools/charge.tool';
|
|
24
25
|
import { RefundTool } from '../tools/refund.tool';
|
|
25
26
|
|
|
@@ -34,6 +35,7 @@ export class BillingApp {}
|
|
|
34
35
|
```typescript
|
|
35
36
|
// src/apps/inventory.app.ts
|
|
36
37
|
import { App } from '@frontmcp/sdk';
|
|
38
|
+
|
|
37
39
|
import { CheckStockTool } from '../tools/check-stock.tool';
|
|
38
40
|
|
|
39
41
|
@App({
|
|
@@ -62,7 +64,9 @@ export default class HealthCheckTool extends ToolContext {
|
|
|
62
64
|
```typescript
|
|
63
65
|
// src/main.ts
|
|
64
66
|
import 'reflect-metadata';
|
|
67
|
+
|
|
65
68
|
import { FrontMcp } from '@frontmcp/sdk';
|
|
69
|
+
|
|
66
70
|
import { BillingApp } from './apps/billing.app';
|
|
67
71
|
import { InventoryApp } from './apps/inventory.app';
|
|
68
72
|
import HealthCheckTool from './tools/health-check.tool';
|
|
@@ -77,10 +81,10 @@ export default class Server {}
|
|
|
77
81
|
|
|
78
82
|
## What This Demonstrates
|
|
79
83
|
|
|
80
|
-
- Multiple `@App` classes with unique `id` fields
|
|
81
|
-
- Server-level `tools` array for shared tools
|
|
84
|
+
- Multiple `@App` classes with unique `id` fields, which prefix their tools when two tools share a name (`billing:charge`)
|
|
85
|
+
- Server-level `tools` array for shared tools every app serves under their own name (`server:<name>` when an app tool has the same name)
|
|
82
86
|
- Each app is self-contained with its own tools array
|
|
83
|
-
- The `id` field on `@App`
|
|
87
|
+
- The `id` field on `@App` is the prefix of its tools when names collide
|
|
84
88
|
|
|
85
89
|
## Related
|
|
86
90
|
|
|
@@ -193,16 +193,16 @@ The type is: `standalone?: 'includeInParent' | boolean` (defaults to `false`).
|
|
|
193
193
|
|
|
194
194
|
## Tool Namespacing
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
A local app's tool keeps its own name while no other tool in the server shares it. When two tools share a name, each is listed with its owner's id as a prefix: `appId:toolName`.
|
|
197
197
|
|
|
198
198
|
```typescript
|
|
199
|
-
@App({ id: 'billing', name: 'Billing', tools: [
|
|
199
|
+
@App({ id: 'billing', name: 'Billing', tools: [SearchTool] })
|
|
200
200
|
class BillingApp {}
|
|
201
|
-
//
|
|
201
|
+
// Listed as: billing:search (another app also has `search`)
|
|
202
202
|
|
|
203
|
-
@App({ id: 'inventory', name: 'Inventory', tools: [CheckStockTool] })
|
|
203
|
+
@App({ id: 'inventory', name: 'Inventory', tools: [SearchTool, CheckStockTool] })
|
|
204
204
|
class InventoryApp {}
|
|
205
|
-
//
|
|
205
|
+
// Listed as: inventory:search and check_stock
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
For remote and ESM apps, the `namespace` option controls the prefix:
|
|
@@ -217,7 +217,7 @@ app.esm('@acme/tools@^1.0.0', { namespace: 'acme' });
|
|
|
217
217
|
|
|
218
218
|
## Shared Tools
|
|
219
219
|
|
|
220
|
-
Tools declared directly on `@FrontMcp` (not inside an `@App`) are
|
|
220
|
+
Tools declared directly on `@FrontMcp` (not inside an `@App`) are served next to every app's tools, through the same flows: server-level plugin hooks, hooks on the tool class, `authorities`, rate limits, `availableWhen` and the startup checks apply to them as to app tools. They resolve server-level `providers`, not an app's.
|
|
221
221
|
|
|
222
222
|
```typescript
|
|
223
223
|
@FrontMcp({
|
|
@@ -228,7 +228,13 @@ Tools declared directly on `@FrontMcp` (not inside an `@App`) are shared across
|
|
|
228
228
|
export default class Server {}
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
- A shared tool keeps its own name. If an app in the same scope has a tool of that name, both are prefixed: `billing:health_check` for the app's and `server:health_check` for the shared one. No app may have the id `server` while `@FrontMcp` declares tools or resources (startup fails with `ReservedAppIdError`).
|
|
232
|
+
- With `splitByApp: true`, and for a `standalone` app, each app's scope serves its own instance of every shared tool and resource.
|
|
233
|
+
- An app's plugin hooks run for a shared tool only when declared with `appliesTo: 'uncovered-apps'`; server-level plugin hooks always run.
|
|
234
|
+
- A shared tool belongs to no app, so `incrementalAuth` asks for no app grant before it runs.
|
|
235
|
+
- `@FrontMcp` does not accept `prompts`; declare them on an `@App`.
|
|
236
|
+
|
|
237
|
+
The same pattern works for shared resources (and resource templates) and shared skills:
|
|
232
238
|
|
|
233
239
|
```typescript
|
|
234
240
|
@FrontMcp({
|
|
@@ -383,7 +389,7 @@ export default class Server {}
|
|
|
383
389
|
### Runtime
|
|
384
390
|
|
|
385
391
|
- [ ] All app tools appear in `tools/list` with correct namespace prefixes
|
|
386
|
-
- [ ] Shared tools appear
|
|
392
|
+
- [ ] Shared tools appear under their own name, or as `server:<name>` when an app tool has the same name
|
|
387
393
|
- [ ] `standalone: true` apps are isolated and do not appear in parent tool listing
|
|
388
394
|
- [ ] `standalone: 'includeInParent'` apps have isolated scope but visible tools
|
|
389
395
|
- [ ] Per-app auth modes are enforced independently per app
|
|
@@ -2914,10 +2914,10 @@
|
|
|
2914
2914
|
"level": "basic",
|
|
2915
2915
|
"tags": ["setup", "multi-app", "local", "multi", "app", "composition"],
|
|
2916
2916
|
"features": [
|
|
2917
|
-
"Multiple `@App` classes with unique `id` fields
|
|
2918
|
-
"Server-level `tools` array for shared tools
|
|
2917
|
+
"Multiple `@App` classes with unique `id` fields, which prefix their tools when two tools share a name (`billing:charge`)",
|
|
2918
|
+
"Server-level `tools` array for shared tools every app serves under their own name (`server:<name>` when an app tool has the same name)",
|
|
2919
2919
|
"Each app is self-contained with its own tools array",
|
|
2920
|
-
"The `id` field on `@App`
|
|
2920
|
+
"The `id` field on `@App` is the prefix of its tools when names collide"
|
|
2921
2921
|
]
|
|
2922
2922
|
},
|
|
2923
2923
|
{
|