Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3548972

Browse files
committed
feat(starters): mcp-app support
Signed-off-by: Cory Rylan <[email protected]>
1 parent 02fa6b5 commit 3548972

21 files changed

Lines changed: 422 additions & 1 deletion

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"./projects/starters/hugo:ci",
9090
"./projects/starters/importmaps:ci",
9191
"./projects/starters/lit-library:ci",
92+
"./projects/starters/mcp-app:ci",
9293
"./projects/starters/mpa:ci",
9394
"./projects/starters/nextjs:ci",
9495
"./projects/starters/nuxt:ci",

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ packages:
99
- projects/starters/hugo
1010
- projects/starters/importmaps
1111
- projects/starters/lit-library
12+
- projects/starters/mcp-app
1213
- projects/starters/mpa
1314
- projects/starters/nextjs
1415
- projects/starters/nuxt
@@ -132,6 +133,7 @@ minimumReleaseAgeExclude:
132133
- vite
133134

134135
allowBuilds:
136+
'@modelcontextprotocol/ext-apps': true
135137
'@bundled-es-modules/glob': true
136138
'@parcel/watcher': true
137139
bun: true

projects/internals/tools/src/project/starters.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('startersData', () => {
5050
expect(startersData.bundles.cli).toBe(true);
5151
expect(startersData.importmaps.cli).toBe(false);
5252
expect(startersData.lit.cli).toBe(false);
53+
expect(startersData['mcp-app'].cli).toBe(true);
5354
expect(startersData.extensions.cli).toBe(false);
5455
expect(startersData.preact.cli).toBe(false);
5556
});
@@ -65,6 +66,7 @@ describe('startersData', () => {
6566
expect(startersData.eleventy.zip).toContain('eleventy.zip');
6667
expect(startersData.importmaps.zip).toContain('importmaps.zip');
6768
expect(startersData.bundles.zip).toContain('bundles.zip');
69+
expect(startersData['mcp-app'].zip).toContain('mcp-app.zip');
6870
expect(startersData.extensions.zip).toContain('scoped-registry.zip');
6971
expect(startersData.hugo.zip).toContain('hugo.zip');
7072
});

projects/internals/tools/src/project/starters.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type Starter =
2828
| 'importmaps'
2929
| 'lit-library'
3030
| 'lit'
31+
| 'mcp-app'
3132
| 'nextjs'
3233
| 'nuxt'
3334
| 'preact'
@@ -76,6 +77,10 @@ export const startersData = {
7677
zip: null,
7778
cli: false
7879
},
80+
'mcp-app': {
81+
zip: `${ELEMENTS_PAGES_BASE_URL}/starters/download/mcp-app.zip`,
82+
cli: true
83+
},
7984
nextjs: {
8085
zip: `${ELEMENTS_PAGES_BASE_URL}/starters/download/nextjs.zip`,
8186
cli: true
@@ -136,7 +141,7 @@ async function zipProject(outDir: string) {
136141

137142
/* istanbul ignore next -- @preserve */
138143
function copyProject(projectDir: string) {
139-
const ignoreDirs = new Set(['dist', 'node_modules', '.wireit']);
144+
const ignoreDirs = new Set(['dist', 'node_modules', '.wireit', '.eslintcache']);
140145
cpSync(projectDir, join('dist', projectDir), {
141146
recursive: true,
142147
filter: src => !ignoreDirs.has(basename(src))

projects/pages/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ cpSync('../starters/angular/dist/angular-starter/browser/', './dist/starters/ang
3333
cpSync('../starters/bundles/dist/', './dist/starters/bundles/', { recursive: true });
3434
cpSync('../starters/importmaps/dist/', './dist/starters/importmaps/', { recursive: true });
3535
cpSync('../starters/eleventy/dist/', './dist/starters/eleventy/', { recursive: true });
36+
cpSync('../starters/mcp-app/dist/', './dist/starters/mcp-app/', { recursive: true });
3637
cpSync('../starters/mpa/dist/', './dist/starters/mpa/', { recursive: true });
3738
cpSync('../starters/nextjs/dist/', './dist/starters/nextjs/', { recursive: true });
3839
cpSync('../starters/react/dist/', './dist/starters/react/', { recursive: true });

projects/starters/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This directory contains a suite of standardized starter apps for kickstarting an
77
- `/bundles` - Minimal tooling example leveraging pre-built JS/CSS bundles.
88
- `/extensions` - Build setup for highly reusable and resilient Web Components.
99
- `/go` - Minimal Go web server leveraging Elements pre-built bundles.
10+
- `/mcp-app` - Minimal MCP App using Elements, TypeScript, and Vite.
1011
- `/mpa` - Multi Page App setup for when you just need something simple.
1112
- `/nextjs` - Experimental NextJS demo.
1213
- `/react` - React app built with [Create React App](https://create-react-app.dev/)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
.eslintcache
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Elements MCP App Starter
2+
3+
This file only covers how this starter wires Elements into an MCP App. For component APIs, template validation, and project setup commands, use the Elements CLI/MCP documentation instead.
4+
5+
## Integration Points
6+
7+
- Register Elements in `src/mcp-app.ts`.
8+
- Keep global Elements CSS in `src/mcp-app.css`.
9+
- Keep the MCP App HTML entry in `mcp-app.html`.
10+
- Keep `server.ts` as the single place that registers MCP tools and app resources.
11+
- Keep `main.ts` limited to stdio transport startup.
12+
13+
## MCP App Usage
14+
15+
- Register one MCP tool with `_meta.ui.resourceUri`.
16+
- Register a matching `ui://` app resource with `registerAppResource`.
17+
- Keep the app resource bundled as one HTML file with `vite-plugin-singlefile`.
18+
- Use `App` from `@modelcontextprotocol/ext-apps` in browser code.
19+
20+
## Verification
21+
22+
- Run `pnpm run build` in `projects/starters/mcp-app` after HTML, TypeScript, CSS, or Vite changes.
23+
- Run `pnpm run lint` after TypeScript edits.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# NVIDIA Elements MCP App Starter
2+
3+
A minimal MCP App using NVIDIA Elements, TypeScript, and Vite.
4+
5+
## Getting Started
6+
7+
```shell
8+
npm i
9+
npm run dev
10+
```
11+
12+
## MCP Client Configuration
13+
14+
After building the app, configure a local MCP client with the compiled stdio entrypoint:
15+
16+
```json
17+
{
18+
"mcpServers": {
19+
"elements-mcp-app": {
20+
"command": "node",
21+
"args": ["/path/to/mcp-app/dist/main.js"]
22+
}
23+
}
24+
}
25+
```
26+
27+
## Tasks
28+
29+
| Command | Description |
30+
| --------------- | ------------------------------------------------ |
31+
| `npm run build` | Build the single-file app resource and server JS |
32+
| `npm run dev` | Build, then open the MCP Inspector |
33+
| `npm run lint` | Run eslint |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { elementsRecommended } from '@nvidia-elements/lint/eslint';
2+
3+
/** @type {import('eslint').Linter.Config[]} */
4+
export default [...elementsRecommended];

0 commit comments

Comments
 (0)