init-xmcp 0.6.8 → 0.6.10
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/.turbo/turbo-build.log
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type Framework = "nextjs" | "nestjs" | "express";
|
|
1
|
+
export type Framework = "nextjs" | "nestjs" | "express" | "fastify";
|
|
2
2
|
export declare function detectFramework(projectRoot: string): Framework;
|
|
3
3
|
export declare function detectTypeScript(projectRoot: string): boolean;
|
|
@@ -5,13 +5,19 @@ import { readTsConfigFile } from "../utils/read-config-file.js";
|
|
|
5
5
|
export function detectFramework(projectRoot) {
|
|
6
6
|
const packageJson = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf-8"));
|
|
7
7
|
// Check for NestJS
|
|
8
|
-
if (packageJson.dependencies?.["@nestjs/core"] ||
|
|
8
|
+
if (packageJson.dependencies?.["@nestjs/core"] ||
|
|
9
|
+
packageJson.devDependencies?.["@nestjs/core"]) {
|
|
9
10
|
return "nestjs";
|
|
10
11
|
}
|
|
11
12
|
// Check for Next.js
|
|
12
13
|
if (packageJson.dependencies?.next || packageJson.devDependencies?.next) {
|
|
13
14
|
return "nextjs";
|
|
14
15
|
}
|
|
16
|
+
// Check for Fastify
|
|
17
|
+
if (packageJson.dependencies?.fastify ||
|
|
18
|
+
packageJson.devDependencies?.fastify) {
|
|
19
|
+
return "fastify";
|
|
20
|
+
}
|
|
15
21
|
// Default to express
|
|
16
22
|
return "express";
|
|
17
23
|
}
|
package/dist/index.js
CHANGED
|
@@ -289,7 +289,7 @@ const program = new Command()
|
|
|
289
289
|
console.log(` • tsconfig.json`);
|
|
290
290
|
console.log(chalk.blue("\nNext steps:"));
|
|
291
291
|
// code integration for express projects
|
|
292
|
-
if (detectedFramework
|
|
292
|
+
if (detectedFramework === "express") {
|
|
293
293
|
const integrationCode = `import { xmcpHandler } from '@xmcp/adapter';
|
|
294
294
|
|
|
295
295
|
myApp.post("/mcp", xmcpHandler);
|
|
@@ -304,6 +304,23 @@ myApp.get("/mcp", xmcpHandler);`;
|
|
|
304
304
|
});
|
|
305
305
|
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
306
306
|
}
|
|
307
|
+
// code integration for Fastify projects
|
|
308
|
+
if (detectedFramework === "fastify") {
|
|
309
|
+
const integrationCode = `import { xmcpHandler } from '@xmcp/adapter';
|
|
310
|
+
|
|
311
|
+
app.post("/mcp", xmcpHandler);
|
|
312
|
+
app.get("/mcp", xmcpHandler);`;
|
|
313
|
+
const lines = integrationCode.split("\n");
|
|
314
|
+
const maxLength = Math.max(...lines.map((line) => line.length)) + 2;
|
|
315
|
+
console.log("\nTo get started with the xmcpHandler in your Fastify application, add this code to your server:\n");
|
|
316
|
+
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
317
|
+
lines.forEach((line) => {
|
|
318
|
+
const padding = " ".repeat(maxLength - line.length);
|
|
319
|
+
console.log(chalk.green(chalk.bgBlack(` ${line}${padding}`)));
|
|
320
|
+
});
|
|
321
|
+
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
322
|
+
console.log(chalk.yellow("\nNote: for browser clients, add CORS and OPTIONS handling at the app level (e.g. @fastify/cors).\n"));
|
|
323
|
+
}
|
|
307
324
|
// code integration for NestJS projects
|
|
308
325
|
if (detectedFramework === "nestjs") {
|
|
309
326
|
const integrationCode = `import { XmcpModule } from "./xmcp/xmcp.module";
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "fs-extra";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { readTsConfigFile } from "../utils/read-config-file.js";
|
|
5
5
|
|
|
6
|
-
export type Framework = "nextjs" | "nestjs" | "express";
|
|
6
|
+
export type Framework = "nextjs" | "nestjs" | "express" | "fastify";
|
|
7
7
|
|
|
8
8
|
export function detectFramework(projectRoot: string): Framework {
|
|
9
9
|
const packageJson = JSON.parse(
|
|
@@ -11,7 +11,10 @@ export function detectFramework(projectRoot: string): Framework {
|
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
// Check for NestJS
|
|
14
|
-
if (
|
|
14
|
+
if (
|
|
15
|
+
packageJson.dependencies?.["@nestjs/core"] ||
|
|
16
|
+
packageJson.devDependencies?.["@nestjs/core"]
|
|
17
|
+
) {
|
|
15
18
|
return "nestjs";
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -20,6 +23,14 @@ export function detectFramework(projectRoot: string): Framework {
|
|
|
20
23
|
return "nextjs";
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
// Check for Fastify
|
|
27
|
+
if (
|
|
28
|
+
packageJson.dependencies?.fastify ||
|
|
29
|
+
packageJson.devDependencies?.fastify
|
|
30
|
+
) {
|
|
31
|
+
return "fastify";
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
// Default to express
|
|
24
35
|
return "express";
|
|
25
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -365,7 +365,7 @@ const program = new Command()
|
|
|
365
365
|
console.log(chalk.blue("\nNext steps:"));
|
|
366
366
|
|
|
367
367
|
// code integration for express projects
|
|
368
|
-
if (detectedFramework
|
|
368
|
+
if (detectedFramework === "express") {
|
|
369
369
|
const integrationCode = `import { xmcpHandler } from '@xmcp/adapter';
|
|
370
370
|
|
|
371
371
|
myApp.post("/mcp", xmcpHandler);
|
|
@@ -385,6 +385,32 @@ myApp.get("/mcp", xmcpHandler);`;
|
|
|
385
385
|
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
// code integration for Fastify projects
|
|
389
|
+
if (detectedFramework === "fastify") {
|
|
390
|
+
const integrationCode = `import { xmcpHandler } from '@xmcp/adapter';
|
|
391
|
+
|
|
392
|
+
app.post("/mcp", xmcpHandler);
|
|
393
|
+
app.get("/mcp", xmcpHandler);`;
|
|
394
|
+
|
|
395
|
+
const lines = integrationCode.split("\n");
|
|
396
|
+
const maxLength = Math.max(...lines.map((line) => line.length)) + 2;
|
|
397
|
+
|
|
398
|
+
console.log(
|
|
399
|
+
"\nTo get started with the xmcpHandler in your Fastify application, add this code to your server:\n"
|
|
400
|
+
);
|
|
401
|
+
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
402
|
+
lines.forEach((line) => {
|
|
403
|
+
const padding = " ".repeat(maxLength - line.length);
|
|
404
|
+
console.log(chalk.green(chalk.bgBlack(` ${line}${padding}`)));
|
|
405
|
+
});
|
|
406
|
+
console.log(chalk.green(chalk.bgBlack(` ${" ".repeat(maxLength)}`)));
|
|
407
|
+
console.log(
|
|
408
|
+
chalk.yellow(
|
|
409
|
+
"\nNote: for browser clients, add CORS and OPTIONS handling at the app level (e.g. @fastify/cors).\n"
|
|
410
|
+
)
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
388
414
|
// code integration for NestJS projects
|
|
389
415
|
if (detectedFramework === "nestjs") {
|
|
390
416
|
const integrationCode = `import { XmcpModule } from "./xmcp/xmcp.module";
|