@n8n/mcp-apps 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/LICENSE.md +88 -0
- package/README.md +132 -0
- package/dist/apps/workflow-preview.html +253 -0
- package/dist/apps-manifest.d.ts +8 -0
- package/dist/apps-manifest.js +10 -0
- package/dist/apps-manifest.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -0
- package/dist/server/apps/workflow-preview.d.ts +2 -0
- package/dist/server/apps/workflow-preview.js +20 -0
- package/dist/server/apps/workflow-preview.js.map +1 -0
- package/dist/server/constants.d.ts +3 -0
- package/dist/server/constants.js +7 -0
- package/dist/server/constants.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +12 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/register-mcp-app-tool.d.ts +17 -0
- package/dist/server/register-mcp-app-tool.js +23 -0
- package/dist/server/register-mcp-app-tool.js.map +1 -0
- package/dist/server/resource-loader.d.ts +3 -0
- package/dist/server/resource-loader.js +25 -0
- package/dist/server/resource-loader.js.map +1 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
Portions of this software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
- Content of branches other than the main branch (i.e. "master") are not licensed.
|
|
6
|
+
- Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under
|
|
7
|
+
the Sustainable Use License.
|
|
8
|
+
To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a
|
|
9
|
+
valid n8n Enterprise License specifically allowing you access to such source code files and as defined
|
|
10
|
+
in "LICENSE_EE.md".
|
|
11
|
+
- All third party components incorporated into the n8n Software are licensed under the original license
|
|
12
|
+
provided by the owner of the applicable component.
|
|
13
|
+
- Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
|
|
14
|
+
License" as defined below.
|
|
15
|
+
|
|
16
|
+
## Sustainable Use License
|
|
17
|
+
|
|
18
|
+
Version 1.0
|
|
19
|
+
|
|
20
|
+
### Acceptance
|
|
21
|
+
|
|
22
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
23
|
+
|
|
24
|
+
### Copyright License
|
|
25
|
+
|
|
26
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
|
|
27
|
+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
|
|
28
|
+
to the limitations below.
|
|
29
|
+
|
|
30
|
+
### Limitations
|
|
31
|
+
|
|
32
|
+
You may use or modify the software only for your own internal business purposes or for non-commercial or
|
|
33
|
+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
|
|
34
|
+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
|
|
35
|
+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
36
|
+
|
|
37
|
+
### Patents
|
|
38
|
+
|
|
39
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
|
|
40
|
+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
|
|
41
|
+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
|
|
42
|
+
you cause to be infringed by modifications or additions to the software. If you or your company make any
|
|
43
|
+
written claim that the software infringes or contributes to infringement of any patent, your patent license
|
|
44
|
+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
|
|
45
|
+
license ends immediately for work on behalf of your company.
|
|
46
|
+
|
|
47
|
+
### Notices
|
|
48
|
+
|
|
49
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
|
|
50
|
+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
|
|
51
|
+
stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
### No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
56
|
+
|
|
57
|
+
### Termination
|
|
58
|
+
|
|
59
|
+
If you use the software in violation of these terms, such use is not licensed, and your license will
|
|
60
|
+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
|
|
61
|
+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
|
|
62
|
+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
|
|
63
|
+
terms will cause your license to terminate automatically and permanently.
|
|
64
|
+
|
|
65
|
+
### No Liability
|
|
66
|
+
|
|
67
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
|
|
68
|
+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
|
|
69
|
+
any kind of legal claim.
|
|
70
|
+
|
|
71
|
+
### Definitions
|
|
72
|
+
|
|
73
|
+
The “licensor” is the entity offering these terms.
|
|
74
|
+
|
|
75
|
+
The “software” is the software the licensor makes available under these terms, including any portion of it.
|
|
76
|
+
|
|
77
|
+
“You” refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
|
|
80
|
+
all organizations that have control over, are under the control of, or are under common control with that
|
|
81
|
+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
|
|
82
|
+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
83
|
+
|
|
84
|
+
“Your license” is the license granted to you for the software under these terms.
|
|
85
|
+
|
|
86
|
+
“Use” means anything you do with the software requiring your license.
|
|
87
|
+
|
|
88
|
+
“Trademark” means trademarks, service marks, and similar rights.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @n8n/mcp-apps
|
|
2
|
+
|
|
3
|
+
UI resources and server helpers that let the n8n MCP server return **MCP
|
|
4
|
+
Apps** — small, sandboxed HTML/Vue experiences rendered inside MCP clients
|
|
5
|
+
that support the
|
|
6
|
+
[`@modelcontextprotocol/ext-apps`](https://www.npmjs.com/package/@modelcontextprotocol/ext-apps)
|
|
7
|
+
extension. The package owns both the runtime UI bundles and the small server
|
|
8
|
+
helpers used by `packages/cli` to register them as MCP resources and tools.
|
|
9
|
+
|
|
10
|
+
## What it provides
|
|
11
|
+
|
|
12
|
+
- **Server helpers** (`@n8n/mcp-apps/server`) for registering MCP App tools
|
|
13
|
+
and the static HTML resources that back them.
|
|
14
|
+
- **Vue UI apps** under `src/apps/*`, built with Vite as standalone, fully
|
|
15
|
+
inlined HTML files (CSS + JS in a single document) so they can be served
|
|
16
|
+
directly as MCP resources.
|
|
17
|
+
- **i18n plumbing** powered by `vue-i18n`, with locale negotiation driven by
|
|
18
|
+
the host context the MCP client provides at runtime.
|
|
19
|
+
|
|
20
|
+
Today the package ships a single app, `workflow-preview`, which is rendered
|
|
21
|
+
after the `create_workflow_from_code` MCP tool returns and gives the user a
|
|
22
|
+
button to open the freshly created workflow in n8n. New apps can be added
|
|
23
|
+
alongside it (see [Adding a new app](#adding-a-new-app)).
|
|
24
|
+
|
|
25
|
+
## Package layout
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/
|
|
29
|
+
apps-manifest.ts # single source of truth for the apps registry
|
|
30
|
+
apps/ # Vue UI apps, each built into a standalone HTML
|
|
31
|
+
workflow-preview/
|
|
32
|
+
App.vue # root component
|
|
33
|
+
main.ts # mounts App with i18n
|
|
34
|
+
index.html # entry HTML (built into dist/apps/<app>.html)
|
|
35
|
+
tokens.scss # design tokens / global styles
|
|
36
|
+
url.ts # defense-in-depth URL validation
|
|
37
|
+
i18n/ # vue-i18n setup + host locale resolution
|
|
38
|
+
locales/ # flat-key locale files (en.json, …)
|
|
39
|
+
server/ # consumed by packages/cli
|
|
40
|
+
apps/ # MCP resource registrations for each UI app
|
|
41
|
+
constants.ts # shared URIs, MIME type, _meta keys
|
|
42
|
+
register-mcp-app-tool.ts
|
|
43
|
+
resource-loader.ts # lazy reads built HTML from dist/apps
|
|
44
|
+
index.ts # public entry: @n8n/mcp-apps/server
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`apps-manifest.ts` is the canonical registry of MCP apps. Both the Vite
|
|
48
|
+
build (entry directory + output HTML filename per `--mode`) and the
|
|
49
|
+
server-side resource loader (compile-time union + runtime allow-list of
|
|
50
|
+
loadable HTML files) derive from it, so the build and runtime stay in
|
|
51
|
+
lockstep and there is no separate list to maintain.
|
|
52
|
+
|
|
53
|
+
The Vite build (`pnpm build:ui`) emits one inlined HTML file per app into
|
|
54
|
+
`dist/apps/<app>.html`. The TypeScript build (`pnpm build:server`) emits the
|
|
55
|
+
server helpers into `dist/server/`. Both run as part of `pnpm build`.
|
|
56
|
+
|
|
57
|
+
## UI runtime
|
|
58
|
+
|
|
59
|
+
Each app:
|
|
60
|
+
|
|
61
|
+
- Connects to the host via `@modelcontextprotocol/ext-apps`'s `App` class.
|
|
62
|
+
- Receives a `McpUiHostContext` (theme, style variables, host fonts, locale)
|
|
63
|
+
through `onhostcontextchanged` and reflects it on the document.
|
|
64
|
+
- Reads the originating tool's `structuredContent` via `ontoolresult` to
|
|
65
|
+
populate its own state.
|
|
66
|
+
- Calls `app.openLink({ url })` to ask the host to navigate — never opens
|
|
67
|
+
links itself.
|
|
68
|
+
|
|
69
|
+
URL handling is locked down by `isAllowedWorkflowUrl` in
|
|
70
|
+
`src/apps/workflow-preview/url.ts`: only `http(s)://` URLs with a non-empty
|
|
71
|
+
host are accepted, both when reading the tool result and right before calling
|
|
72
|
+
`openLink`. This is defense in depth on top of the host's own validation.
|
|
73
|
+
|
|
74
|
+
## Internationalization
|
|
75
|
+
|
|
76
|
+
Locale files live under `src/locales/` and use flat, namespaced keys
|
|
77
|
+
(`workflowPreview.openButton`, `workflowPreview.ariaLabel.ready`, …). The
|
|
78
|
+
host's BCP 47 locale is resolved to a shipped locale via `resolveLocale`,
|
|
79
|
+
applied to the `vue-i18n` instance, and mirrored to `<html lang>` for
|
|
80
|
+
assistive tech. See `src/i18n/index.ts` for the full contract.
|
|
81
|
+
|
|
82
|
+
To add a new locale:
|
|
83
|
+
|
|
84
|
+
1. Drop `<code>.json` next to `en.json` in `src/locales/`.
|
|
85
|
+
2. Import it in `src/i18n/index.ts` and add the code to `SUPPORTED_LOCALES`.
|
|
86
|
+
|
|
87
|
+
The schema is derived from `en.json`, so other locales are type-checked
|
|
88
|
+
against the same key set.
|
|
89
|
+
|
|
90
|
+
## Adding a new app
|
|
91
|
+
|
|
92
|
+
1. Create `src/apps/<app-name>/` with `index.html`, `main.ts`, and an
|
|
93
|
+
`App.vue` root component. Mount it through the shared `i18n` instance.
|
|
94
|
+
2. Add an entry to `MCP_APPS` in `src/apps-manifest.ts`:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
'<app-name>': {
|
|
98
|
+
entry: '<app-name>', // directory under src/apps/
|
|
99
|
+
htmlFile: '<app-name>.html', // output under dist/apps/
|
|
100
|
+
},
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This single entry teaches Vite about the new `--mode`, expands the
|
|
104
|
+
`McpAppHtmlFileName` type union, and adds the file to the
|
|
105
|
+
`loadAppHtml` runtime allow-list. `pnpm build:ui --mode <app-name>`
|
|
106
|
+
will then produce `dist/apps/<app-name>.html`.
|
|
107
|
+
3. Add the app's URI constant to `src/server/constants.ts` and a
|
|
108
|
+
`register<App>App` helper in `src/server/apps/` that calls
|
|
109
|
+
`server.resource(...)` with `loadAppHtml('<app-name>.html')`.
|
|
110
|
+
4. Re-export the helper and URI constant from `src/server/index.ts`.
|
|
111
|
+
5. Add any UI strings to `src/locales/en.json` under a new app-scoped
|
|
112
|
+
key prefix.
|
|
113
|
+
|
|
114
|
+
## SDK version compatibility
|
|
115
|
+
|
|
116
|
+
`src/server/sdk-version.test.ts` asserts that the
|
|
117
|
+
`@modelcontextprotocol/sdk` version installed via the pnpm catalog satisfies
|
|
118
|
+
the peer range declared by `@modelcontextprotocol/ext-apps`. CI fails the
|
|
119
|
+
moment those two pins drift, so bumping one without the other is caught
|
|
120
|
+
immediately.
|
|
121
|
+
|
|
122
|
+
## Scripts
|
|
123
|
+
|
|
124
|
+
| Command | Description |
|
|
125
|
+
|--------------------|---------------------------------------------------------|
|
|
126
|
+
| `pnpm build` | Build UI apps and server helpers |
|
|
127
|
+
| `pnpm build:ui` | Build the Vue apps to inlined HTML in `dist/apps/` |
|
|
128
|
+
| `pnpm build:server`| Build the server entry to `dist/server/` |
|
|
129
|
+
| `pnpm typecheck` | Run `vue-tsc` over the UI and `tsc` over the server |
|
|
130
|
+
| `pnpm lint` | Lint with the shared ESLint config |
|
|
131
|
+
| `pnpm test` | Run unit tests with Vitest |
|
|
132
|
+
| `pnpm test:dev` | Run Vitest in watch mode |
|