@mcp-use/cli 2.18.0-canary.2 → 2.18.0-canary.3
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.cjs +37 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -30
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -4969,6 +4969,37 @@ async function findServerFile(projectPath) {
|
|
|
4969
4969
|
}
|
|
4970
4970
|
throw new Error("No server file found");
|
|
4971
4971
|
}
|
|
4972
|
+
async function generateToolRegistryTypesForServer(projectPath, serverFileRelative) {
|
|
4973
|
+
const serverFile = import_node_path8.default.join(projectPath, serverFileRelative);
|
|
4974
|
+
const serverFileExists = await (0, import_promises7.access)(serverFile).then(() => true).catch(() => false);
|
|
4975
|
+
if (!serverFileExists) {
|
|
4976
|
+
throw new Error(`Server file not found: ${serverFile}`);
|
|
4977
|
+
}
|
|
4978
|
+
const previousHmrMode = globalThis.__mcpUseHmrMode;
|
|
4979
|
+
try {
|
|
4980
|
+
globalThis.__mcpUseHmrMode = true;
|
|
4981
|
+
globalThis.__mcpUseLastServer = void 0;
|
|
4982
|
+
const { tsImport } = await import("tsx/esm/api");
|
|
4983
|
+
await tsImport(serverFile, {
|
|
4984
|
+
parentURL: importMetaUrl,
|
|
4985
|
+
tsconfig: import_node_path8.default.join(projectPath, "tsconfig.json")
|
|
4986
|
+
});
|
|
4987
|
+
const server = globalThis.__mcpUseLastServer;
|
|
4988
|
+
if (!server) {
|
|
4989
|
+
throw new Error(
|
|
4990
|
+
"No MCPServer instance found. Make sure your server file creates an MCPServer instance."
|
|
4991
|
+
);
|
|
4992
|
+
}
|
|
4993
|
+
const mcpUsePath = import_node_path8.default.join(projectPath, "node_modules", "mcp-use");
|
|
4994
|
+
const { generateToolRegistryTypes } = await import(import_node_path8.default.join(mcpUsePath, "dist", "src", "server", "index.js")).then((mod) => mod);
|
|
4995
|
+
if (!generateToolRegistryTypes) {
|
|
4996
|
+
throw new Error("generateToolRegistryTypes not found in mcp-use package");
|
|
4997
|
+
}
|
|
4998
|
+
await generateToolRegistryTypes(server.registrations.tools, projectPath);
|
|
4999
|
+
} finally {
|
|
5000
|
+
globalThis.__mcpUseHmrMode = previousHmrMode ?? false;
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
4972
5003
|
async function buildWidgets(projectPath, options = {}) {
|
|
4973
5004
|
const { inline = true } = options;
|
|
4974
5005
|
const { promises: fs10 } = await import("fs");
|
|
@@ -5457,6 +5488,11 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
|
|
|
5457
5488
|
sourceServerFile = await findServerFile(projectPath);
|
|
5458
5489
|
} catch {
|
|
5459
5490
|
}
|
|
5491
|
+
if (sourceServerFile) {
|
|
5492
|
+
console.log(source_default.gray("Generating tool registry types..."));
|
|
5493
|
+
await generateToolRegistryTypesForServer(projectPath, sourceServerFile);
|
|
5494
|
+
console.log(source_default.green("\u2713 Tool registry types generated"));
|
|
5495
|
+
}
|
|
5460
5496
|
console.log(source_default.gray("Building TypeScript..."));
|
|
5461
5497
|
await runCommand(
|
|
5462
5498
|
"node",
|
|
@@ -6231,36 +6267,9 @@ program.command("generate-types").description(
|
|
|
6231
6267
|
"Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
|
|
6232
6268
|
).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {
|
|
6233
6269
|
const projectPath = import_node_path8.default.resolve(options.path);
|
|
6234
|
-
const serverFile = import_node_path8.default.join(projectPath, options.server);
|
|
6235
6270
|
try {
|
|
6236
|
-
if (!await (0, import_promises7.access)(serverFile).then(() => true).catch(() => false)) {
|
|
6237
|
-
console.error(source_default.red(`Server file not found: ${serverFile}`));
|
|
6238
|
-
process.exit(1);
|
|
6239
|
-
}
|
|
6240
6271
|
console.log(source_default.blue("Generating tool registry types..."));
|
|
6241
|
-
|
|
6242
|
-
const { tsImport } = await import("tsx/esm/api");
|
|
6243
|
-
await tsImport(serverFile, {
|
|
6244
|
-
parentURL: importMetaUrl,
|
|
6245
|
-
tsconfig: import_node_path8.default.join(projectPath, "tsconfig.json")
|
|
6246
|
-
});
|
|
6247
|
-
const server = globalThis.__mcpUseLastServer;
|
|
6248
|
-
if (!server) {
|
|
6249
|
-
console.error(
|
|
6250
|
-
source_default.red(
|
|
6251
|
-
"No MCPServer instance found. Make sure your server file creates an MCPServer instance."
|
|
6252
|
-
)
|
|
6253
|
-
);
|
|
6254
|
-
process.exit(1);
|
|
6255
|
-
}
|
|
6256
|
-
const mcpUsePath = import_node_path8.default.join(projectPath, "node_modules", "mcp-use");
|
|
6257
|
-
const { generateToolRegistryTypes } = await import(import_node_path8.default.join(mcpUsePath, "dist", "src", "server", "index.js")).then((mod) => mod);
|
|
6258
|
-
if (!generateToolRegistryTypes) {
|
|
6259
|
-
throw new Error(
|
|
6260
|
-
"generateToolRegistryTypes not found in mcp-use package"
|
|
6261
|
-
);
|
|
6262
|
-
}
|
|
6263
|
-
await generateToolRegistryTypes(server.registrations.tools, projectPath);
|
|
6272
|
+
await generateToolRegistryTypesForServer(projectPath, options.server);
|
|
6264
6273
|
console.log(source_default.green("\u2713 Tool registry types generated successfully"));
|
|
6265
6274
|
process.exit(0);
|
|
6266
6275
|
} catch (error) {
|
|
@@ -6272,8 +6281,6 @@ program.command("generate-types").description(
|
|
|
6272
6281
|
console.error(source_default.gray(error.stack));
|
|
6273
6282
|
}
|
|
6274
6283
|
process.exit(1);
|
|
6275
|
-
} finally {
|
|
6276
|
-
globalThis.__mcpUseHmrMode = false;
|
|
6277
6284
|
}
|
|
6278
6285
|
});
|
|
6279
6286
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|