create-mcp-use-app 0.4.2 → 0.4.3-canary.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/dist/index.js +32 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,32 +40,22 @@ function renderLogo() {
|
|
|
40
40
|
var packageJson = JSON.parse(
|
|
41
41
|
readFileSync(join(__dirname, "../package.json"), "utf-8")
|
|
42
42
|
);
|
|
43
|
-
function getCurrentPackageVersions() {
|
|
43
|
+
function getCurrentPackageVersions(isDevelopment = false, useCanary = false) {
|
|
44
44
|
const versions = {};
|
|
45
45
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (existsSync(join(root, "packages/mcp-use/package.json"))) {
|
|
59
|
-
workspaceRoot = root;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!workspaceRoot) {
|
|
64
|
-
throw new Error("Workspace root not found");
|
|
46
|
+
if (isDevelopment) {
|
|
47
|
+
versions["mcp-use"] = "workspace:*";
|
|
48
|
+
versions["@mcp-use/cli"] = "workspace:*";
|
|
49
|
+
versions["@mcp-use/inspector"] = "workspace:*";
|
|
50
|
+
} else if (useCanary) {
|
|
51
|
+
versions["mcp-use"] = "canary";
|
|
52
|
+
versions["@mcp-use/cli"] = "canary";
|
|
53
|
+
versions["@mcp-use/inspector"] = "canary";
|
|
54
|
+
} else {
|
|
55
|
+
versions["mcp-use"] = "latest";
|
|
56
|
+
versions["@mcp-use/cli"] = "latest";
|
|
57
|
+
versions["@mcp-use/inspector"] = "latest";
|
|
65
58
|
}
|
|
66
|
-
versions["mcp-use"] = "latest";
|
|
67
|
-
versions["@mcp-use/cli"] = "latest";
|
|
68
|
-
versions["@mcp-use/inspector"] = "latest";
|
|
69
59
|
} catch (error) {
|
|
70
60
|
if (process.env.NODE_ENV === "development") {
|
|
71
61
|
console.warn("\u26A0\uFE0F Could not read workspace package versions, using defaults");
|
|
@@ -77,26 +67,29 @@ function getCurrentPackageVersions() {
|
|
|
77
67
|
}
|
|
78
68
|
return versions;
|
|
79
69
|
}
|
|
80
|
-
function processTemplateFile(filePath, versions, isDevelopment = false) {
|
|
70
|
+
function processTemplateFile(filePath, versions, isDevelopment = false, useCanary = false) {
|
|
81
71
|
const content = readFileSync(filePath, "utf-8");
|
|
82
72
|
let processedContent = content;
|
|
83
73
|
for (const [packageName, version] of Object.entries(versions)) {
|
|
84
74
|
const placeholder = `{{${packageName}_version}}`;
|
|
85
|
-
|
|
86
|
-
processedContent = processedContent.replace(new RegExp(placeholder, "g"), versionPrefix);
|
|
75
|
+
processedContent = processedContent.replace(new RegExp(placeholder, "g"), version);
|
|
87
76
|
}
|
|
88
77
|
if (isDevelopment) {
|
|
89
78
|
processedContent = processedContent.replace(/"mcp-use": "\^[^"]+"/, '"mcp-use": "workspace:*"');
|
|
90
79
|
processedContent = processedContent.replace(/"@mcp-use\/cli": "\^[^"]+"/, '"@mcp-use/cli": "workspace:*"');
|
|
91
80
|
processedContent = processedContent.replace(/"@mcp-use\/inspector": "\^[^"]+"/, '"@mcp-use/inspector": "workspace:*"');
|
|
81
|
+
} else if (useCanary) {
|
|
82
|
+
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "canary"`);
|
|
83
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "canary"`);
|
|
84
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "canary"`);
|
|
92
85
|
} else {
|
|
93
|
-
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "
|
|
94
|
-
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "
|
|
95
|
-
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "
|
|
86
|
+
processedContent = processedContent.replace(/"mcp-use": "workspace:\*"/, `"mcp-use": "${versions["mcp-use"] || "latest"}"`);
|
|
87
|
+
processedContent = processedContent.replace(/"@mcp-use\/cli": "workspace:\*"/, `"@mcp-use/cli": "${versions["@mcp-use/cli"] || "latest"}"`);
|
|
88
|
+
processedContent = processedContent.replace(/"@mcp-use\/inspector": "workspace:\*"/, `"@mcp-use/inspector": "${versions["@mcp-use/inspector"] || "latest"}"`);
|
|
96
89
|
}
|
|
97
90
|
return processedContent;
|
|
98
91
|
}
|
|
99
|
-
program.name("create-mcp-use-app").description("Create a new MCP server project").version(packageJson.version).argument("[project-name]", "Name of the MCP server project").option("-t, --template <template>", "Template to use", "simple").option("--no-install", "Skip installing dependencies").option("--dev", "Use workspace dependencies for development").action(async (projectName, options) => {
|
|
92
|
+
program.name("create-mcp-use-app").description("Create a new MCP server project").version(packageJson.version).argument("[project-name]", "Name of the MCP server project").option("-t, --template <template>", "Template to use", "simple").option("--no-install", "Skip installing dependencies").option("--dev", "Use workspace dependencies for development").option("--canary", "Use canary versions of packages").action(async (projectName, options) => {
|
|
100
93
|
try {
|
|
101
94
|
let selectedTemplate = options.template;
|
|
102
95
|
if (!projectName) {
|
|
@@ -134,8 +127,8 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
134
127
|
}
|
|
135
128
|
mkdirSync(projectPath, { recursive: true });
|
|
136
129
|
const validatedTemplate = validateTemplateName(selectedTemplate);
|
|
137
|
-
const versions = getCurrentPackageVersions();
|
|
138
|
-
await copyTemplate(projectPath, validatedTemplate, versions, options.dev);
|
|
130
|
+
const versions = getCurrentPackageVersions(options.dev, options.canary);
|
|
131
|
+
await copyTemplate(projectPath, validatedTemplate, versions, options.dev, options.canary);
|
|
139
132
|
updatePackageJson(projectPath, sanitizedProjectName);
|
|
140
133
|
if (options.install) {
|
|
141
134
|
const spinner = ora("Installing packages...").start();
|
|
@@ -157,6 +150,8 @@ program.name("create-mcp-use-app").description("Create a new MCP server project"
|
|
|
157
150
|
console.log(chalk.green("\u2705 MCP server created successfully!"));
|
|
158
151
|
if (options.dev) {
|
|
159
152
|
console.log(chalk.yellow("\u{1F527} Development mode: Using workspace dependencies"));
|
|
153
|
+
} else if (options.canary) {
|
|
154
|
+
console.log(chalk.blue("\u{1F680} Canary mode: Using canary versions of packages"));
|
|
160
155
|
}
|
|
161
156
|
console.log("");
|
|
162
157
|
console.log(chalk.bold("\u{1F4C1} Project structure:"));
|
|
@@ -208,7 +203,7 @@ function validateTemplateName(template) {
|
|
|
208
203
|
}
|
|
209
204
|
return sanitized;
|
|
210
205
|
}
|
|
211
|
-
async function copyTemplate(projectPath, template, versions, isDevelopment = false) {
|
|
206
|
+
async function copyTemplate(projectPath, template, versions, isDevelopment = false, useCanary = false) {
|
|
212
207
|
const templatePath = join(__dirname, "templates", template);
|
|
213
208
|
if (!existsSync(templatePath)) {
|
|
214
209
|
console.error(chalk.red(`\u274C Template "${template}" not found!`));
|
|
@@ -223,19 +218,19 @@ async function copyTemplate(projectPath, template, versions, isDevelopment = fal
|
|
|
223
218
|
console.log('\u{1F4A1} Tip: Use "uiresource" template for UI resources and advanced server examples');
|
|
224
219
|
process.exit(1);
|
|
225
220
|
}
|
|
226
|
-
copyDirectoryWithProcessing(templatePath, projectPath, versions, isDevelopment);
|
|
221
|
+
copyDirectoryWithProcessing(templatePath, projectPath, versions, isDevelopment, useCanary);
|
|
227
222
|
}
|
|
228
|
-
function copyDirectoryWithProcessing(src, dest, versions, isDevelopment) {
|
|
223
|
+
function copyDirectoryWithProcessing(src, dest, versions, isDevelopment, useCanary = false) {
|
|
229
224
|
const entries = readdirSync(src, { withFileTypes: true });
|
|
230
225
|
for (const entry of entries) {
|
|
231
226
|
const srcPath = join(src, entry.name);
|
|
232
227
|
const destPath = join(dest, entry.name);
|
|
233
228
|
if (entry.isDirectory()) {
|
|
234
229
|
mkdirSync(destPath, { recursive: true });
|
|
235
|
-
copyDirectoryWithProcessing(srcPath, destPath, versions, isDevelopment);
|
|
230
|
+
copyDirectoryWithProcessing(srcPath, destPath, versions, isDevelopment, useCanary);
|
|
236
231
|
} else {
|
|
237
232
|
if (entry.name === "package.json" || entry.name.endsWith(".json")) {
|
|
238
|
-
const processedContent = processTemplateFile(srcPath, versions, isDevelopment);
|
|
233
|
+
const processedContent = processTemplateFile(srcPath, versions, isDevelopment, useCanary);
|
|
239
234
|
writeFileSync(destPath, processedContent);
|
|
240
235
|
} else {
|
|
241
236
|
copyFileSync(srcPath, destPath);
|