@mcp-use/cli 1.0.20 → 2.0.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/dist/build.d.mts +2 -0
- package/dist/build.d.mts.map +1 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +105 -0
- package/dist/build.js.map +1 -0
- package/dist/build.mjs +106 -0
- package/dist/build.mjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -85
- package/src/build.ts +118 -0
- package/src/index.ts +25 -0
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/LICENSE +0 -21
- package/dist/cli.js +0 -287920
- package/readme.md +0 -250
package/dist/build.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.mts","sourceRoot":"","sources":["../src/build.mts"],"names":[],"mappings":""}
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AA6CA,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,iBAuErD"}
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildWidgets = buildWidgets;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const esbuild_1 = require("esbuild");
|
|
10
|
+
const globby_1 = require("globby");
|
|
11
|
+
const ROUTE_PREFIX = '/mcp-use/widgets';
|
|
12
|
+
const SRC_DIR = 'resources';
|
|
13
|
+
const OUT_DIR = 'dist/resources';
|
|
14
|
+
function toRoute(file) {
|
|
15
|
+
const rel = file.replace(new RegExp(`^${SRC_DIR}/`), '').replace(/\.tsx?$/, '');
|
|
16
|
+
return `${ROUTE_PREFIX}/${rel}`;
|
|
17
|
+
}
|
|
18
|
+
function outDirForRoute(route) {
|
|
19
|
+
return node_path_1.default.join(OUT_DIR, route.replace(/^\//, ''));
|
|
20
|
+
}
|
|
21
|
+
function htmlTemplate({ title, scriptPath }) {
|
|
22
|
+
return `<!doctype html>
|
|
23
|
+
<html lang="en">
|
|
24
|
+
<head>
|
|
25
|
+
<meta charset="UTF-8" />
|
|
26
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
27
|
+
<title>${title} Widget</title>
|
|
28
|
+
<style>
|
|
29
|
+
body {
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 20px;
|
|
32
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
|
33
|
+
background: #f5f5f5;
|
|
34
|
+
}
|
|
35
|
+
#widget-root {
|
|
36
|
+
max-width: 1200px;
|
|
37
|
+
margin: 0 auto;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<div id="widget-root"></div>
|
|
43
|
+
<script type="module" src="${scriptPath}"></script>
|
|
44
|
+
</body>
|
|
45
|
+
</html>`;
|
|
46
|
+
}
|
|
47
|
+
async function buildWidgets(projectPath) {
|
|
48
|
+
console.log('🔨 Building UI widgets with esbuild...');
|
|
49
|
+
const srcDir = node_path_1.default.join(projectPath, SRC_DIR);
|
|
50
|
+
const outDir = node_path_1.default.join(projectPath, OUT_DIR);
|
|
51
|
+
// Clean dist
|
|
52
|
+
await node_fs_1.promises.rm(outDir, { recursive: true, force: true });
|
|
53
|
+
// Find all TSX entries
|
|
54
|
+
const entries = await (0, globby_1.globby)([`${srcDir}/**/*.tsx`]);
|
|
55
|
+
console.log(`📦 Found ${entries.length} widget files`);
|
|
56
|
+
// Build each entry as an isolated page with hashed output
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const relativePath = node_path_1.default.relative(projectPath, entry);
|
|
59
|
+
const route = toRoute(relativePath);
|
|
60
|
+
const pageOutDir = node_path_1.default.join(projectPath, outDirForRoute(route));
|
|
61
|
+
const baseName = node_path_1.default.parse(entry).name;
|
|
62
|
+
console.log(`🔨 Building ${baseName}...`);
|
|
63
|
+
// Build JS/CSS chunks for this page
|
|
64
|
+
await (0, esbuild_1.build)({
|
|
65
|
+
entryPoints: [entry],
|
|
66
|
+
bundle: true,
|
|
67
|
+
splitting: true,
|
|
68
|
+
format: 'esm',
|
|
69
|
+
platform: 'browser',
|
|
70
|
+
target: 'es2018',
|
|
71
|
+
sourcemap: false,
|
|
72
|
+
minify: true,
|
|
73
|
+
outdir: node_path_1.default.join(pageOutDir, 'assets'),
|
|
74
|
+
logLevel: 'silent',
|
|
75
|
+
loader: {
|
|
76
|
+
'.svg': 'file',
|
|
77
|
+
'.png': 'file',
|
|
78
|
+
'.jpg': 'file',
|
|
79
|
+
'.jpeg': 'file',
|
|
80
|
+
'.gif': 'file',
|
|
81
|
+
'.css': 'css',
|
|
82
|
+
},
|
|
83
|
+
entryNames: `[name]-[hash]`,
|
|
84
|
+
chunkNames: `chunk-[hash]`,
|
|
85
|
+
assetNames: `asset-[hash]`,
|
|
86
|
+
define: {
|
|
87
|
+
'process.env.NODE_ENV': '"production"',
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
// Find the main entry file name
|
|
91
|
+
const files = await node_fs_1.promises.readdir(node_path_1.default.join(pageOutDir, 'assets'));
|
|
92
|
+
const mainJs = files.find(f => f.startsWith(`${baseName}-`) && f.endsWith('.js'));
|
|
93
|
+
if (!mainJs)
|
|
94
|
+
throw new Error(`Failed to locate entry JS for ${entry}`);
|
|
95
|
+
// Write an index.html that points to the entry
|
|
96
|
+
await node_fs_1.promises.mkdir(pageOutDir, { recursive: true });
|
|
97
|
+
await node_fs_1.promises.writeFile(node_path_1.default.join(pageOutDir, 'index.html'), htmlTemplate({
|
|
98
|
+
title: baseName,
|
|
99
|
+
scriptPath: `./assets/${mainJs}`,
|
|
100
|
+
}), 'utf8');
|
|
101
|
+
console.log(`✅ Built ${baseName} -> ${route}`);
|
|
102
|
+
}
|
|
103
|
+
console.log('🎉 Build complete!');
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;AA6CA,oCAuEC;AApHD,qCAAwC;AACxC,0DAA4B;AAC5B,qCAA+B;AAC/B,mCAA+B;AAE/B,MAAM,YAAY,GAAG,kBAAkB,CAAA;AACvC,MAAM,OAAO,GAAG,WAAW,CAAA;AAC3B,MAAM,OAAO,GAAG,gBAAgB,CAAA;AAEhC,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC/E,OAAO,GAAG,YAAY,IAAI,GAAG,EAAE,CAAA;AACjC,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAA;AACrD,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,EAAyC;IAChF,OAAO;;;;;aAKI,KAAK;;;;;;;;;;;;;;;;iCAgBe,UAAU;;QAEnC,CAAA;AACR,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,WAAmB;IACpD,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAA;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
+
"use strict";
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
// Using: esbuild + node >= 18
|
|
5
|
+
import { build } from 'esbuild';
|
|
6
|
+
import { globby } from 'globby';
|
|
7
|
+
const ROUTE_PREFIX = '/mcp-use/widgets'; // <- MCP widget prefix
|
|
8
|
+
const SRC_DIR = 'resources';
|
|
9
|
+
const OUT_DIR = 'dist/resources';
|
|
10
|
+
function toRoute(file) {
|
|
11
|
+
// resources/kanban-board.tsx -> /mcp-use/widgets/kanban-board
|
|
12
|
+
// resources/dashboard/stats.tsx -> /mcp-use/widgets/dashboard/stats
|
|
13
|
+
const rel = file.replace(new RegExp(`^${SRC_DIR}/`), '').replace(/\.tsx?$/, '');
|
|
14
|
+
return `${ROUTE_PREFIX}/${rel}`;
|
|
15
|
+
}
|
|
16
|
+
function outDirForRoute(route) {
|
|
17
|
+
// dist/resources/mcp-use/widgets/kanban-board
|
|
18
|
+
return path.join(OUT_DIR, route.replace(/^\//, ''));
|
|
19
|
+
}
|
|
20
|
+
function htmlTemplate({ title, scriptPath }) {
|
|
21
|
+
return `<!doctype html>
|
|
22
|
+
<html lang="en">
|
|
23
|
+
<head>
|
|
24
|
+
<meta charset="UTF-8" />
|
|
25
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
26
|
+
<title>${title} Widget</title>
|
|
27
|
+
<style>
|
|
28
|
+
body {
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 20px;
|
|
31
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
|
32
|
+
background: #f5f5f5;
|
|
33
|
+
}
|
|
34
|
+
#widget-root {
|
|
35
|
+
max-width: 1200px;
|
|
36
|
+
margin: 0 auto;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
39
|
+
</head>
|
|
40
|
+
<body>
|
|
41
|
+
<div id="widget-root"></div>
|
|
42
|
+
<script type="module" src="${scriptPath}"></script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>`;
|
|
45
|
+
}
|
|
46
|
+
async function main() {
|
|
47
|
+
console.log('🔨 Building UI widgets with esbuild...');
|
|
48
|
+
// Clean dist
|
|
49
|
+
await fs.rm(OUT_DIR, { recursive: true, force: true });
|
|
50
|
+
// Find all TSX entries
|
|
51
|
+
const entries = await globby([`${SRC_DIR}/**/*.tsx`]);
|
|
52
|
+
console.log(`📦 Found ${entries.length} widget files`);
|
|
53
|
+
// Build each entry as an isolated page with hashed output
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
const route = toRoute(entry);
|
|
56
|
+
const pageOutDir = outDirForRoute(route);
|
|
57
|
+
const baseName = path.parse(entry).name;
|
|
58
|
+
console.log(`🔨 Building ${baseName}...`);
|
|
59
|
+
// Build JS/CSS chunks for this page
|
|
60
|
+
const _result = await build({
|
|
61
|
+
entryPoints: [entry],
|
|
62
|
+
bundle: true,
|
|
63
|
+
splitting: true,
|
|
64
|
+
format: 'esm',
|
|
65
|
+
platform: 'browser',
|
|
66
|
+
target: 'es2018',
|
|
67
|
+
sourcemap: false,
|
|
68
|
+
minify: true,
|
|
69
|
+
outdir: path.join(pageOutDir, 'assets'),
|
|
70
|
+
logLevel: 'silent',
|
|
71
|
+
loader: {
|
|
72
|
+
'.svg': 'file',
|
|
73
|
+
'.png': 'file',
|
|
74
|
+
'.jpg': 'file',
|
|
75
|
+
'.jpeg': 'file',
|
|
76
|
+
'.gif': 'file',
|
|
77
|
+
'.css': 'css',
|
|
78
|
+
},
|
|
79
|
+
// Unique chunk names per page to avoid collisions
|
|
80
|
+
entryNames: `[name]-[hash]`,
|
|
81
|
+
chunkNames: `chunk-[hash]`,
|
|
82
|
+
assetNames: `asset-[hash]`,
|
|
83
|
+
define: {
|
|
84
|
+
'process.env.NODE_ENV': '"production"',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
// Find the main entry file name
|
|
88
|
+
const files = await fs.readdir(path.join(pageOutDir, 'assets'));
|
|
89
|
+
const mainJs = files.find(f => f.startsWith(`${baseName}-`) && f.endsWith('.js'));
|
|
90
|
+
if (!mainJs)
|
|
91
|
+
throw new Error(`Failed to locate entry JS for ${entry}`);
|
|
92
|
+
// Write an index.html that points to the entry
|
|
93
|
+
await fs.mkdir(pageOutDir, { recursive: true });
|
|
94
|
+
await fs.writeFile(path.join(pageOutDir, 'index.html'), htmlTemplate({
|
|
95
|
+
title: baseName,
|
|
96
|
+
scriptPath: `./assets/${mainJs}`,
|
|
97
|
+
}), 'utf8');
|
|
98
|
+
console.log(`✅ Built ${baseName} -> ${route}`);
|
|
99
|
+
}
|
|
100
|
+
console.log('🎉 Build complete!');
|
|
101
|
+
}
|
|
102
|
+
main().catch((err) => {
|
|
103
|
+
console.error('❌ Build failed:', err);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=build.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.mjs","sourceRoot":"","sources":["../src/build.mts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,8BAA8B;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,YAAY,GAAG,kBAAkB,CAAA,CAAC,uBAAuB;AAC/D,MAAM,OAAO,GAAG,WAAW,CAAA;AAC3B,MAAM,OAAO,GAAG,gBAAgB,CAAA;AAEhC,SAAS,OAAO,CAAC,IAAY;IAC3B,8DAA8D;IAC9D,oEAAoE;IACpE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC/E,OAAO,GAAG,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AK,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACnC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const build_1 = require("./build");
|
|
6
|
+
const program = new commander_1.Command();
|
|
7
|
+
program
|
|
8
|
+
.name('mcp-use')
|
|
9
|
+
.description('MCP CLI tool')
|
|
10
|
+
.version('0.1.0');
|
|
11
|
+
program
|
|
12
|
+
.command('build')
|
|
13
|
+
.description('Build MCP UI widgets')
|
|
14
|
+
.option('-p, --path <path>', 'Path to project directory', process.cwd())
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
try {
|
|
17
|
+
await (0, build_1.buildWidgets)(options.path);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Build failed:', error);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
program.parse();
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,mCAAuC;AAEvC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,cAAc,CAAC;KAC3B,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KACvE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,IAAA,oBAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,86 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"build": "esbuild source/cli.tsx --bundle --platform=node --target=node16 --outfile=dist/cli.js --format=esm --banner:js=\"import { createRequire } from 'module';const require = createRequire(import.meta.url);\"",
|
|
30
|
-
"watch": "npm run build -- --watch",
|
|
31
|
-
"start": "node dist/cli.js",
|
|
32
|
-
"prepublishOnly": "npm run build",
|
|
33
|
-
"lint": "eslint",
|
|
34
|
-
"lint:fix": "eslint --fix",
|
|
35
|
-
"fmt": "eslint --fix",
|
|
36
|
-
"release": "npm version patch --tag-version-prefix=v && git push --follow-tags",
|
|
37
|
-
"release:minor": "npm version minor --tag-version-prefix=v && git push --follow-tags",
|
|
38
|
-
"release:major": "npm version major --tag-version-prefix=v && git push --follow-tags"
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"dist"
|
|
42
|
-
],
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@langchain/anthropic": "^0.3.23",
|
|
45
|
-
"@langchain/cohere": "^0.3.4",
|
|
46
|
-
"@langchain/community": "^0.3.47",
|
|
47
|
-
"@langchain/core": "0.3.58",
|
|
48
|
-
"@langchain/deepseek": "^0.0.2",
|
|
49
|
-
"@langchain/google-genai": "^0.2.14",
|
|
50
|
-
"@langchain/google-vertexai": "^0.2.14",
|
|
51
|
-
"@langchain/groq": "^0.2.3",
|
|
52
|
-
"@langchain/mistralai": "^0.2.1",
|
|
53
|
-
"@langchain/ollama": "^0.2.3",
|
|
54
|
-
"@langchain/xai": "^0.0.3",
|
|
55
|
-
"@modelcontextprotocol/sdk": "^1.13.2",
|
|
56
|
-
"@scarf/scarf": "^1.4.0",
|
|
57
|
-
"cli-spinners": "^3.2.0",
|
|
58
|
-
"dotenv": "^16.5.0",
|
|
59
|
-
"ink": "^5.2.1",
|
|
60
|
-
"ink-gradient": "^3.0.0",
|
|
61
|
-
"ink-link": "^4.1.0",
|
|
62
|
-
"mcp-use": "^0.1.2",
|
|
63
|
-
"meow": "^11.0.0",
|
|
64
|
-
"react": "^18.2.0"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@types/react": "^18.0.32",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
69
|
-
"@typescript-eslint/parser": "^8.35.0",
|
|
70
|
-
"@vdemedes/prettier-config": "^2.0.1",
|
|
71
|
-
"esbuild": "^0.25.5",
|
|
72
|
-
"eslint": "^9.30.0",
|
|
73
|
-
"eslint-config-prettier": "^9.1.0",
|
|
74
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
75
|
-
"prettier": "^3.3.3",
|
|
76
|
-
"react-devtools-core": "^4.28.5",
|
|
77
|
-
"typescript": "^5.0.3",
|
|
78
|
-
"typescript-eslint": "^8.35.0"
|
|
79
|
-
},
|
|
80
|
-
"prettier": "@vdemedes/prettier-config",
|
|
81
|
-
"scarfSettings": {
|
|
82
|
-
"enabled": true,
|
|
83
|
-
"defaultOptIn": true,
|
|
84
|
-
"allowTopLevel": true
|
|
85
|
-
}
|
|
86
|
-
}
|
|
2
|
+
"name": "@mcp-use/cli",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "MCP CLI package",
|
|
5
|
+
"bin": {
|
|
6
|
+
"mcp-use": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"commander": "^11.0.0",
|
|
10
|
+
"esbuild": "^0.19.0",
|
|
11
|
+
"globby": "^14.0.0",
|
|
12
|
+
"mcp-use": "0.2.0",
|
|
13
|
+
"@mcp-use/inspector": "0.1.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20.0.0",
|
|
17
|
+
"typescript": "^5.0.0",
|
|
18
|
+
"vitest": "^1.0.0"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"test": "vitest"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/build.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { build } from 'esbuild'
|
|
4
|
+
import { globby } from 'globby'
|
|
5
|
+
|
|
6
|
+
const ROUTE_PREFIX = '/mcp-use/widgets'
|
|
7
|
+
const SRC_DIR = 'resources'
|
|
8
|
+
const OUT_DIR = 'dist/resources'
|
|
9
|
+
|
|
10
|
+
function toRoute(file: string) {
|
|
11
|
+
const rel = file.replace(new RegExp(`^${SRC_DIR}/`), '').replace(/\.tsx?$/, '')
|
|
12
|
+
return `${ROUTE_PREFIX}/${rel}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function outDirForRoute(route: string) {
|
|
16
|
+
return path.join(OUT_DIR, route.replace(/^\//, ''))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function htmlTemplate({ title, scriptPath }: { title: string, scriptPath: string }) {
|
|
20
|
+
return `<!doctype html>
|
|
21
|
+
<html lang="en">
|
|
22
|
+
<head>
|
|
23
|
+
<meta charset="UTF-8" />
|
|
24
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
25
|
+
<title>${title} Widget</title>
|
|
26
|
+
<style>
|
|
27
|
+
body {
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 20px;
|
|
30
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
|
31
|
+
background: #f5f5f5;
|
|
32
|
+
}
|
|
33
|
+
#widget-root {
|
|
34
|
+
max-width: 1200px;
|
|
35
|
+
margin: 0 auto;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<div id="widget-root"></div>
|
|
41
|
+
<script type="module" src="${scriptPath}"></script>
|
|
42
|
+
</body>
|
|
43
|
+
</html>`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function buildWidgets(projectPath: string) {
|
|
47
|
+
console.log('🔨 Building UI widgets with esbuild...')
|
|
48
|
+
|
|
49
|
+
const srcDir = path.join(projectPath, SRC_DIR)
|
|
50
|
+
const outDir = path.join(projectPath, OUT_DIR)
|
|
51
|
+
|
|
52
|
+
// Clean dist
|
|
53
|
+
await fs.rm(outDir, { recursive: true, force: true })
|
|
54
|
+
|
|
55
|
+
// Find all TSX entries
|
|
56
|
+
const entries = await globby([`${srcDir}/**/*.tsx`])
|
|
57
|
+
console.log(`📦 Found ${entries.length} widget files`)
|
|
58
|
+
|
|
59
|
+
// Build each entry as an isolated page with hashed output
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
const relativePath = path.relative(projectPath, entry)
|
|
62
|
+
const route = toRoute(relativePath)
|
|
63
|
+
const pageOutDir = path.join(projectPath, outDirForRoute(route))
|
|
64
|
+
const baseName = path.parse(entry).name
|
|
65
|
+
|
|
66
|
+
console.log(`🔨 Building ${baseName}...`)
|
|
67
|
+
|
|
68
|
+
// Build JS/CSS chunks for this page
|
|
69
|
+
await build({
|
|
70
|
+
entryPoints: [entry],
|
|
71
|
+
bundle: true,
|
|
72
|
+
splitting: true,
|
|
73
|
+
format: 'esm',
|
|
74
|
+
platform: 'browser',
|
|
75
|
+
target: 'es2018',
|
|
76
|
+
sourcemap: false,
|
|
77
|
+
minify: true,
|
|
78
|
+
outdir: path.join(pageOutDir, 'assets'),
|
|
79
|
+
logLevel: 'silent',
|
|
80
|
+
loader: {
|
|
81
|
+
'.svg': 'file',
|
|
82
|
+
'.png': 'file',
|
|
83
|
+
'.jpg': 'file',
|
|
84
|
+
'.jpeg': 'file',
|
|
85
|
+
'.gif': 'file',
|
|
86
|
+
'.css': 'css',
|
|
87
|
+
},
|
|
88
|
+
entryNames: `[name]-[hash]`,
|
|
89
|
+
chunkNames: `chunk-[hash]`,
|
|
90
|
+
assetNames: `asset-[hash]`,
|
|
91
|
+
define: {
|
|
92
|
+
'process.env.NODE_ENV': '"production"',
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// Find the main entry file name
|
|
97
|
+
const files = await fs.readdir(path.join(pageOutDir, 'assets'))
|
|
98
|
+
const mainJs = files.find(f => f.startsWith(`${baseName}-`) && f.endsWith('.js'))
|
|
99
|
+
if (!mainJs)
|
|
100
|
+
throw new Error(`Failed to locate entry JS for ${entry}`)
|
|
101
|
+
|
|
102
|
+
// Write an index.html that points to the entry
|
|
103
|
+
await fs.mkdir(pageOutDir, { recursive: true })
|
|
104
|
+
await fs.writeFile(
|
|
105
|
+
path.join(pageOutDir, 'index.html'),
|
|
106
|
+
htmlTemplate({
|
|
107
|
+
title: baseName,
|
|
108
|
+
scriptPath: `./assets/${mainJs}`,
|
|
109
|
+
}),
|
|
110
|
+
'utf8',
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
console.log(`✅ Built ${baseName} -> ${route}`)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log('🎉 Build complete!')
|
|
117
|
+
}
|
|
118
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { buildWidgets } from './build';
|
|
4
|
+
|
|
5
|
+
const program = new Command();
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name('mcp-use')
|
|
9
|
+
.description('MCP CLI tool')
|
|
10
|
+
.version('0.1.0');
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.command('build')
|
|
14
|
+
.description('Build MCP UI widgets')
|
|
15
|
+
.option('-p, --path <path>', 'Path to project directory', process.cwd())
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
try {
|
|
18
|
+
await buildWidgets(options.path);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Build failed:', error);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
program.parse();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"resolveJsonModule": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
20
|
+
}
|