mcp-new 1.2.2 → 1.5.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/README.md +33 -1
- package/dist/{chunk-3JG4FVS2.js → chunk-YISSMIHU.js} +222 -46
- package/dist/cli.js +334 -15
- package/dist/index.d.ts +25 -7
- package/dist/index.js +17 -3
- package/package.json +1 -1
- package/templates/csharp/.env.example +6 -0
- package/templates/csharp/.gitignore.ejs +53 -0
- package/templates/csharp/McpServer.csproj.ejs +19 -0
- package/templates/csharp/README.md.ejs +136 -0
- package/templates/csharp/src/Program.cs.ejs +117 -0
- package/templates/elixir/.env.example +6 -0
- package/templates/elixir/.gitignore.ejs +33 -0
- package/templates/elixir/README.md.ejs +154 -0
- package/templates/elixir/config/config.exs.ejs +9 -0
- package/templates/elixir/config/dev.exs.ejs +3 -0
- package/templates/elixir/config/prod.exs.ejs +3 -0
- package/templates/elixir/lib/application.ex.ejs +19 -0
- package/templates/elixir/lib/cli.ex.ejs +17 -0
- package/templates/elixir/lib/server.ex.ejs +112 -0
- package/templates/elixir/mix.exs.ejs +32 -0
- package/templates/java/gradle/.env.example +6 -0
- package/templates/java/gradle/.gitignore.ejs +48 -0
- package/templates/java/gradle/README.md.ejs +132 -0
- package/templates/java/gradle/build.gradle.ejs +46 -0
- package/templates/java/gradle/settings.gradle.ejs +1 -0
- package/templates/java/gradle/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
- package/templates/java/gradle/src/main/resources/logback.xml +13 -0
- package/templates/java/maven/.env.example +6 -0
- package/templates/java/maven/.gitignore.ejs +53 -0
- package/templates/java/maven/README.md.ejs +131 -0
- package/templates/java/maven/pom.xml.ejs +86 -0
- package/templates/java/maven/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
- package/templates/java/maven/src/main/resources/logback.xml +13 -0
- package/templates/kotlin/gradle/.env.example +6 -0
- package/templates/kotlin/gradle/.gitignore.ejs +45 -0
- package/templates/kotlin/gradle/README.md.ejs +138 -0
- package/templates/kotlin/gradle/build.gradle.kts.ejs +48 -0
- package/templates/kotlin/gradle/settings.gradle.kts.ejs +1 -0
- package/templates/kotlin/gradle/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
- package/templates/kotlin/gradle/src/main/resources/logback.xml +13 -0
- package/templates/kotlin/maven/.env.example +6 -0
- package/templates/kotlin/maven/.gitignore.ejs +50 -0
- package/templates/kotlin/maven/README.md.ejs +96 -0
- package/templates/kotlin/maven/pom.xml.ejs +105 -0
- package/templates/kotlin/maven/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
- package/templates/kotlin/maven/src/main/resources/logback.xml +13 -0
package/dist/cli.js
CHANGED
|
@@ -3,10 +3,22 @@ import {
|
|
|
3
3
|
PRESETS,
|
|
4
4
|
addToolCommand,
|
|
5
5
|
createCommand,
|
|
6
|
+
createInitialCommit,
|
|
6
7
|
createSpinner,
|
|
8
|
+
ensureDir,
|
|
9
|
+
exists,
|
|
10
|
+
generateFromWizard,
|
|
7
11
|
initCommand,
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
initGitRepository,
|
|
13
|
+
isGitInstalled,
|
|
14
|
+
logger,
|
|
15
|
+
promptJavaBuildTool,
|
|
16
|
+
promptLanguage,
|
|
17
|
+
readDir,
|
|
18
|
+
readFile,
|
|
19
|
+
withSpinner,
|
|
20
|
+
writeFile
|
|
21
|
+
} from "./chunk-YISSMIHU.js";
|
|
10
22
|
|
|
11
23
|
// src/cli.ts
|
|
12
24
|
import { Command } from "commander";
|
|
@@ -347,7 +359,7 @@ async function upgradeNodePackage(projectDir, info) {
|
|
|
347
359
|
await fs2.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
348
360
|
await execa("npm", ["install"], { cwd: projectDir });
|
|
349
361
|
}
|
|
350
|
-
async function checkPythonPackage(
|
|
362
|
+
async function checkPythonPackage(_projectDir) {
|
|
351
363
|
const packageName = "mcp";
|
|
352
364
|
let current = null;
|
|
353
365
|
let latest = null;
|
|
@@ -421,6 +433,260 @@ async function upgradeRustPackage(projectDir, info) {
|
|
|
421
433
|
await execa("cargo", ["update", "-p", info.packageName], { cwd: projectDir });
|
|
422
434
|
}
|
|
423
435
|
|
|
436
|
+
// src/commands/monorepo.ts
|
|
437
|
+
import path3 from "path";
|
|
438
|
+
import inquirer from "inquirer";
|
|
439
|
+
async function monorepoInitCommand(workspaceName, options) {
|
|
440
|
+
try {
|
|
441
|
+
let name = workspaceName;
|
|
442
|
+
if (!name) {
|
|
443
|
+
const { inputName } = await inquirer.prompt([
|
|
444
|
+
{
|
|
445
|
+
type: "input",
|
|
446
|
+
name: "inputName",
|
|
447
|
+
message: "Workspace name:",
|
|
448
|
+
default: "mcp-workspace"
|
|
449
|
+
}
|
|
450
|
+
]);
|
|
451
|
+
name = inputName;
|
|
452
|
+
}
|
|
453
|
+
const outputDir = path3.resolve(process.cwd(), name);
|
|
454
|
+
if (await exists(outputDir)) {
|
|
455
|
+
const files = await readDir(outputDir);
|
|
456
|
+
if (files.length > 0 && !options.force) {
|
|
457
|
+
logger.error(
|
|
458
|
+
`Directory "${name}" already exists and is not empty. Use --force to override.`
|
|
459
|
+
);
|
|
460
|
+
process.exit(1);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
logger.title(`Creating MCP Monorepo: ${name}`);
|
|
464
|
+
await withSpinner(
|
|
465
|
+
"Creating workspace structure...",
|
|
466
|
+
async () => {
|
|
467
|
+
await ensureDir(outputDir);
|
|
468
|
+
await ensureDir(path3.join(outputDir, "packages"));
|
|
469
|
+
await ensureDir(path3.join(outputDir, "shared"));
|
|
470
|
+
},
|
|
471
|
+
"Workspace structure created"
|
|
472
|
+
);
|
|
473
|
+
const workspaceConfig = {
|
|
474
|
+
name,
|
|
475
|
+
packages: []
|
|
476
|
+
};
|
|
477
|
+
await withSpinner(
|
|
478
|
+
"Creating configuration files...",
|
|
479
|
+
async () => {
|
|
480
|
+
await writeFile(
|
|
481
|
+
path3.join(outputDir, "mcp.workspace.json"),
|
|
482
|
+
JSON.stringify(workspaceConfig, null, 2)
|
|
483
|
+
);
|
|
484
|
+
const packageJson = {
|
|
485
|
+
name,
|
|
486
|
+
version: "1.0.0",
|
|
487
|
+
private: true,
|
|
488
|
+
workspaces: ["packages/*", "shared/*"],
|
|
489
|
+
scripts: {
|
|
490
|
+
build: "npm run build --workspaces",
|
|
491
|
+
dev: "npm run dev --workspaces --if-present",
|
|
492
|
+
test: "npm run test --workspaces --if-present"
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
await writeFile(path3.join(outputDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
496
|
+
const readme = `# ${name}
|
|
497
|
+
|
|
498
|
+
MCP Monorepo Workspace
|
|
499
|
+
|
|
500
|
+
## Structure
|
|
501
|
+
|
|
502
|
+
\`\`\`
|
|
503
|
+
${name}/
|
|
504
|
+
\u251C\u2500\u2500 packages/ # MCP servers
|
|
505
|
+
\u251C\u2500\u2500 shared/ # Shared utilities and types
|
|
506
|
+
\u251C\u2500\u2500 mcp.workspace.json # Workspace configuration
|
|
507
|
+
\u2514\u2500\u2500 package.json # Root package.json
|
|
508
|
+
\`\`\`
|
|
509
|
+
|
|
510
|
+
## Commands
|
|
511
|
+
|
|
512
|
+
\`\`\`bash
|
|
513
|
+
# Add a new MCP server
|
|
514
|
+
mcp-new monorepo add <server-name>
|
|
515
|
+
|
|
516
|
+
# Build all packages
|
|
517
|
+
npm run build
|
|
518
|
+
|
|
519
|
+
# Run all dev servers
|
|
520
|
+
npm run dev
|
|
521
|
+
\`\`\`
|
|
522
|
+
|
|
523
|
+
## Packages
|
|
524
|
+
|
|
525
|
+
${workspaceConfig.packages.length === 0 ? "_No packages yet. Run `mcp-new monorepo add <name>` to create one._" : workspaceConfig.packages.map((p) => `- ${p}`).join("\n")}
|
|
526
|
+
`;
|
|
527
|
+
await writeFile(path3.join(outputDir, "README.md"), readme);
|
|
528
|
+
const gitignore = `# Dependencies
|
|
529
|
+
node_modules/
|
|
530
|
+
|
|
531
|
+
# Build outputs
|
|
532
|
+
dist/
|
|
533
|
+
build/
|
|
534
|
+
*.tsbuildinfo
|
|
535
|
+
|
|
536
|
+
# Environment
|
|
537
|
+
.env
|
|
538
|
+
.env.local
|
|
539
|
+
.env.*.local
|
|
540
|
+
|
|
541
|
+
# IDE
|
|
542
|
+
.idea/
|
|
543
|
+
.vscode/
|
|
544
|
+
*.swp
|
|
545
|
+
*.swo
|
|
546
|
+
|
|
547
|
+
# OS
|
|
548
|
+
.DS_Store
|
|
549
|
+
Thumbs.db
|
|
550
|
+
|
|
551
|
+
# Logs
|
|
552
|
+
*.log
|
|
553
|
+
npm-debug.log*
|
|
554
|
+
`;
|
|
555
|
+
await writeFile(path3.join(outputDir, ".gitignore"), gitignore);
|
|
556
|
+
},
|
|
557
|
+
"Configuration files created"
|
|
558
|
+
);
|
|
559
|
+
const gitInstalled = await isGitInstalled();
|
|
560
|
+
if (gitInstalled) {
|
|
561
|
+
await withSpinner(
|
|
562
|
+
"Initializing git repository...",
|
|
563
|
+
async () => {
|
|
564
|
+
await initGitRepository(outputDir);
|
|
565
|
+
await createInitialCommit(outputDir);
|
|
566
|
+
},
|
|
567
|
+
"Git repository initialized"
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
logger.success(`Monorepo workspace "${name}" created successfully!`);
|
|
571
|
+
logger.box("Next steps:", ["", ` cd ${name}`, ` mcp-new monorepo add my-first-server`, ""]);
|
|
572
|
+
} catch (error) {
|
|
573
|
+
if (error instanceof Error) {
|
|
574
|
+
logger.error(error.message);
|
|
575
|
+
} else {
|
|
576
|
+
logger.error("An unexpected error occurred");
|
|
577
|
+
}
|
|
578
|
+
process.exit(1);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
async function monorepoAddCommand(serverName, options) {
|
|
582
|
+
try {
|
|
583
|
+
const workspaceConfigPath = path3.resolve(process.cwd(), "mcp.workspace.json");
|
|
584
|
+
if (!await exists(workspaceConfigPath)) {
|
|
585
|
+
logger.error(
|
|
586
|
+
"Not in a monorepo workspace. Run `mcp-new monorepo init` first, or cd into an existing workspace."
|
|
587
|
+
);
|
|
588
|
+
process.exit(1);
|
|
589
|
+
}
|
|
590
|
+
let name = serverName || options.name;
|
|
591
|
+
if (!name) {
|
|
592
|
+
const { inputName } = await inquirer.prompt([
|
|
593
|
+
{
|
|
594
|
+
type: "input",
|
|
595
|
+
name: "inputName",
|
|
596
|
+
message: "Server name:",
|
|
597
|
+
default: "my-mcp-server"
|
|
598
|
+
}
|
|
599
|
+
]);
|
|
600
|
+
name = inputName;
|
|
601
|
+
}
|
|
602
|
+
let language;
|
|
603
|
+
const opts = options;
|
|
604
|
+
if (opts.typescript === true || opts.t === true) language = "typescript";
|
|
605
|
+
else if (opts.python === true || opts.p === true) language = "python";
|
|
606
|
+
else if (opts.go === true || opts.g === true) language = "go";
|
|
607
|
+
else if (opts.rust === true || opts.r === true) language = "rust";
|
|
608
|
+
else if (opts.java === true || opts.j === true) language = "java";
|
|
609
|
+
else if (opts.kotlin === true || opts.k === true) language = "kotlin";
|
|
610
|
+
else if (opts.csharp === true || opts.c === true) language = "csharp";
|
|
611
|
+
else if (opts.elixir === true || opts.e === true) language = "elixir";
|
|
612
|
+
if (!language) {
|
|
613
|
+
language = await promptLanguage();
|
|
614
|
+
}
|
|
615
|
+
let javaBuildTool;
|
|
616
|
+
if (language === "java" || language === "kotlin") {
|
|
617
|
+
javaBuildTool = options.maven ? "maven" : options.gradle ? "gradle" : await promptJavaBuildTool();
|
|
618
|
+
}
|
|
619
|
+
const outputDir = path3.join(process.cwd(), "packages", name);
|
|
620
|
+
if (await exists(outputDir)) {
|
|
621
|
+
logger.error(`Server "${name}" already exists in packages/`);
|
|
622
|
+
process.exit(1);
|
|
623
|
+
}
|
|
624
|
+
logger.title(`Adding MCP Server: ${name}`);
|
|
625
|
+
await generateFromWizard(
|
|
626
|
+
{
|
|
627
|
+
name,
|
|
628
|
+
description: "",
|
|
629
|
+
language,
|
|
630
|
+
transport: "stdio",
|
|
631
|
+
tools: [],
|
|
632
|
+
resources: [],
|
|
633
|
+
includeExampleTool: true,
|
|
634
|
+
skipInstall: options.skipInstall || false,
|
|
635
|
+
initGit: false,
|
|
636
|
+
// Don't init git for individual packages
|
|
637
|
+
javaBuildTool
|
|
638
|
+
},
|
|
639
|
+
outputDir
|
|
640
|
+
);
|
|
641
|
+
const workspaceConfigContent = await readFile(workspaceConfigPath);
|
|
642
|
+
const workspaceConfig = JSON.parse(workspaceConfigContent);
|
|
643
|
+
workspaceConfig.packages.push(name);
|
|
644
|
+
await writeFile(workspaceConfigPath, JSON.stringify(workspaceConfig, null, 2));
|
|
645
|
+
logger.success(`Server "${name}" added to packages/`);
|
|
646
|
+
logger.info(`Language: ${language}${javaBuildTool ? ` (${javaBuildTool})` : ""}`);
|
|
647
|
+
logger.box("Next steps:", [
|
|
648
|
+
"",
|
|
649
|
+
` cd packages/${name}`,
|
|
650
|
+
" # Start developing your MCP server",
|
|
651
|
+
""
|
|
652
|
+
]);
|
|
653
|
+
} catch (error) {
|
|
654
|
+
if (error instanceof Error) {
|
|
655
|
+
logger.error(error.message);
|
|
656
|
+
} else {
|
|
657
|
+
logger.error("An unexpected error occurred");
|
|
658
|
+
}
|
|
659
|
+
process.exit(1);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
async function monorepoListCommand() {
|
|
663
|
+
try {
|
|
664
|
+
const workspaceConfigPath = path3.resolve(process.cwd(), "mcp.workspace.json");
|
|
665
|
+
if (!await exists(workspaceConfigPath)) {
|
|
666
|
+
logger.error("Not in a monorepo workspace.");
|
|
667
|
+
process.exit(1);
|
|
668
|
+
}
|
|
669
|
+
const workspaceConfigContent = await readFile(workspaceConfigPath);
|
|
670
|
+
const workspaceConfig = JSON.parse(workspaceConfigContent);
|
|
671
|
+
logger.title(`Workspace: ${workspaceConfig.name}`);
|
|
672
|
+
if (workspaceConfig.packages.length === 0) {
|
|
673
|
+
logger.info("No packages yet. Run `mcp-new monorepo add <name>` to create one.");
|
|
674
|
+
} else {
|
|
675
|
+
logger.info("Packages:");
|
|
676
|
+
workspaceConfig.packages.forEach((pkg, index) => {
|
|
677
|
+
console.log(` ${index + 1}. ${pkg}`);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
} catch (error) {
|
|
681
|
+
if (error instanceof Error) {
|
|
682
|
+
logger.error(error.message);
|
|
683
|
+
} else {
|
|
684
|
+
logger.error("An unexpected error occurred");
|
|
685
|
+
}
|
|
686
|
+
process.exit(1);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
424
690
|
// src/cli.ts
|
|
425
691
|
var program = new Command();
|
|
426
692
|
var logo = `
|
|
@@ -464,15 +730,21 @@ ${chalk4.bold("Supported Languages:")}
|
|
|
464
730
|
${chalk4.green("-p, --python")} Python with pip
|
|
465
731
|
${chalk4.green("-g, --go")} Go with go modules
|
|
466
732
|
${chalk4.green("-r, --rust")} Rust with cargo
|
|
733
|
+
${chalk4.green("-j, --java")} Java with Maven/Gradle
|
|
734
|
+
${chalk4.green("-k, --kotlin")} Kotlin with Maven/Gradle
|
|
735
|
+
${chalk4.green("-c, --csharp")} C# with .NET
|
|
736
|
+
${chalk4.green("-e, --elixir")} Elixir with Mix
|
|
467
737
|
|
|
468
738
|
${chalk4.bold("Learn More:")}
|
|
469
739
|
|
|
470
740
|
Documentation: ${chalk4.underline("https://github.com/d1maash/mcp-new")}
|
|
471
741
|
MCP Spec: ${chalk4.underline("https://spec.modelcontextprotocol.io")}
|
|
472
742
|
`;
|
|
473
|
-
program.name("mcp-new").description("CLI tool for generating MCP (Model Context Protocol) servers").version("1.
|
|
474
|
-
program.argument("[project-name]", "Name of the project to create").option("-t, --typescript", "Use TypeScript template").option("-p, --python", "Use Python template").option("-g, --go", "Use Go template").option("-r, --rust", "Use Rust template").option("--skip-install", "Skip dependency installation").option("--from-openapi <path>", "Generate from OpenAPI/Swagger specification").option("--from-prompt", "Generate tools using AI from text description").option("--preset <name>", "Use a preset template (database, rest-api, filesystem)").option("-y, --yes", "Skip prompts and use defaults").action(createCommand);
|
|
475
|
-
program.command("init").description("Initialize MCP server in the current directory").option("-t, --typescript", "Use TypeScript template").option("-p, --python", "Use Python template").option("-g, --go", "Use Go template").option("-r, --rust", "Use Rust template").option("--skip-install", "Skip dependency installation").option("-f, --force", "Initialize even if directory contains files").addHelpText(
|
|
743
|
+
program.name("mcp-new").description("CLI tool for generating MCP (Model Context Protocol) servers").version("1.5.0").addHelpText("beforeAll", logo).addHelpText("after", examples);
|
|
744
|
+
program.argument("[project-name]", "Name of the project to create").option("-t, --typescript", "Use TypeScript template").option("-p, --python", "Use Python template").option("-g, --go", "Use Go template").option("-r, --rust", "Use Rust template").option("-j, --java", "Use Java template").option("-k, --kotlin", "Use Kotlin template").option("-c, --csharp", "Use C# (.NET) template").option("-e, --elixir", "Use Elixir template").option("--maven", "Use Maven build tool (for Java/Kotlin)").option("--gradle", "Use Gradle build tool (for Java/Kotlin)").option("--skip-install", "Skip dependency installation").option("--from-openapi <path>", "Generate from OpenAPI/Swagger specification").option("--from-prompt", "Generate tools using AI from text description").option("--preset <name>", "Use a preset template (database, rest-api, filesystem)").option("-y, --yes", "Skip prompts and use defaults").action(createCommand);
|
|
745
|
+
program.command("init").description("Initialize MCP server in the current directory").option("-t, --typescript", "Use TypeScript template").option("-p, --python", "Use Python template").option("-g, --go", "Use Go template").option("-r, --rust", "Use Rust template").option("-j, --java", "Use Java template").option("-k, --kotlin", "Use Kotlin template").option("-c, --csharp", "Use C# (.NET) template").option("-e, --elixir", "Use Elixir template").option("--maven", "Use Maven build tool (for Java/Kotlin)").option("--gradle", "Use Gradle build tool (for Java/Kotlin)").option("--skip-install", "Skip dependency installation").option("-f, --force", "Initialize even if directory contains files").addHelpText(
|
|
746
|
+
"after",
|
|
747
|
+
`
|
|
476
748
|
${chalk4.bold("Examples:")}
|
|
477
749
|
|
|
478
750
|
${chalk4.gray("# Initialize in current directory")}
|
|
@@ -483,8 +755,11 @@ ${chalk4.bold("Examples:")}
|
|
|
483
755
|
|
|
484
756
|
${chalk4.gray("# Force initialize (overwrite existing files)")}
|
|
485
757
|
${chalk4.cyan("$")} mcp-new init -f
|
|
486
|
-
`
|
|
487
|
-
|
|
758
|
+
`
|
|
759
|
+
).action(initCommand);
|
|
760
|
+
program.command("add-tool").description("Add a new tool to an existing MCP server").option("-n, --name <name>", "Tool name (snake_case)").addHelpText(
|
|
761
|
+
"after",
|
|
762
|
+
`
|
|
488
763
|
${chalk4.bold("Examples:")}
|
|
489
764
|
|
|
490
765
|
${chalk4.gray("# Add tool interactively")}
|
|
@@ -492,14 +767,20 @@ ${chalk4.bold("Examples:")}
|
|
|
492
767
|
|
|
493
768
|
${chalk4.gray("# Add tool with name")}
|
|
494
769
|
${chalk4.cyan("$")} mcp-new add-tool -n my_new_tool
|
|
495
|
-
`
|
|
496
|
-
|
|
770
|
+
`
|
|
771
|
+
).action(addToolCommand);
|
|
772
|
+
program.command("list-presets").description("List all available preset templates").addHelpText(
|
|
773
|
+
"after",
|
|
774
|
+
`
|
|
497
775
|
${chalk4.bold("Examples:")}
|
|
498
776
|
|
|
499
777
|
${chalk4.gray("# Show all presets with their tools")}
|
|
500
778
|
${chalk4.cyan("$")} mcp-new list-presets
|
|
501
|
-
`
|
|
502
|
-
|
|
779
|
+
`
|
|
780
|
+
).action(listPresetsCommand);
|
|
781
|
+
program.command("validate").description("Validate the current MCP server project").addHelpText(
|
|
782
|
+
"after",
|
|
783
|
+
`
|
|
503
784
|
${chalk4.bold("Examples:")}
|
|
504
785
|
|
|
505
786
|
${chalk4.gray("# Validate current project")}
|
|
@@ -510,8 +791,11 @@ ${chalk4.bold("Checks:")}
|
|
|
510
791
|
\u2022 MCP SDK dependency presence and version
|
|
511
792
|
\u2022 Entry point file existence
|
|
512
793
|
\u2022 Basic project structure
|
|
513
|
-
`
|
|
514
|
-
|
|
794
|
+
`
|
|
795
|
+
).action(validateCommand);
|
|
796
|
+
program.command("upgrade").description("Upgrade MCP SDK to the latest version").option("-c, --check", "Check for updates without installing").addHelpText(
|
|
797
|
+
"after",
|
|
798
|
+
`
|
|
515
799
|
${chalk4.bold("Examples:")}
|
|
516
800
|
|
|
517
801
|
${chalk4.gray("# Upgrade MCP SDK to latest version")}
|
|
@@ -525,7 +809,42 @@ ${chalk4.bold("Supported languages:")}
|
|
|
525
809
|
\u2022 Python (pip)
|
|
526
810
|
\u2022 Go (go modules)
|
|
527
811
|
\u2022 Rust (cargo)
|
|
528
|
-
`
|
|
812
|
+
`
|
|
813
|
+
).action(upgradeCommand);
|
|
814
|
+
var monorepo = program.command("monorepo").description("Manage MCP monorepo workspaces");
|
|
815
|
+
monorepo.command("init [workspace-name]").description("Initialize a new MCP monorepo workspace").option("-f, --force", "Initialize even if directory contains files").addHelpText(
|
|
816
|
+
"after",
|
|
817
|
+
`
|
|
818
|
+
${chalk4.bold("Examples:")}
|
|
819
|
+
|
|
820
|
+
${chalk4.gray("# Create a new monorepo workspace")}
|
|
821
|
+
${chalk4.cyan("$")} mcp-new monorepo init my-workspace
|
|
822
|
+
|
|
823
|
+
${chalk4.gray("# Create in current directory name")}
|
|
824
|
+
${chalk4.cyan("$")} mcp-new monorepo init
|
|
825
|
+
`
|
|
826
|
+
).action((_workspaceName, _options, command) => {
|
|
827
|
+
const opts = command.optsWithGlobals();
|
|
828
|
+
const workspaceName = command.args[0];
|
|
829
|
+
monorepoInitCommand(workspaceName, opts);
|
|
830
|
+
});
|
|
831
|
+
monorepo.command("add [server-name]").description("Add a new MCP server to the workspace").option("-n, --name <name>", "Server name").option("-t, --typescript", "Use TypeScript template").option("-p, --python", "Use Python template").option("-g, --go", "Use Go template").option("-r, --rust", "Use Rust template").option("-j, --java", "Use Java template").option("-k, --kotlin", "Use Kotlin template").option("-c, --csharp", "Use C# (.NET) template").option("-e, --elixir", "Use Elixir template").option("--maven", "Use Maven build tool (for Java/Kotlin)").option("--gradle", "Use Gradle build tool (for Java/Kotlin)").option("--skip-install", "Skip dependency installation").addHelpText(
|
|
832
|
+
"after",
|
|
833
|
+
`
|
|
834
|
+
${chalk4.bold("Examples:")}
|
|
835
|
+
|
|
836
|
+
${chalk4.gray("# Add a TypeScript server")}
|
|
837
|
+
${chalk4.cyan("$")} mcp-new monorepo add my-server -t
|
|
838
|
+
|
|
839
|
+
${chalk4.gray("# Add a Java server with Gradle")}
|
|
840
|
+
${chalk4.cyan("$")} mcp-new monorepo add api-server -j --gradle
|
|
841
|
+
`
|
|
842
|
+
).action((_serverName, _options, command) => {
|
|
843
|
+
const opts = command.optsWithGlobals();
|
|
844
|
+
const serverName = command.args[0];
|
|
845
|
+
monorepoAddCommand(serverName, opts);
|
|
846
|
+
});
|
|
847
|
+
monorepo.command("list").description("List all packages in the workspace").action(monorepoListCommand);
|
|
529
848
|
program.parse();
|
|
530
849
|
if (process.argv.length === 2) {
|
|
531
850
|
program.help();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const LanguageSchema: z.ZodEnum<["typescript", "python", "go", "rust"]>;
|
|
3
|
+
declare const LanguageSchema: z.ZodEnum<["typescript", "python", "go", "rust", "java", "kotlin", "csharp", "elixir"]>;
|
|
4
4
|
type Language = z.infer<typeof LanguageSchema>;
|
|
5
|
+
declare const JavaBuildToolSchema: z.ZodEnum<["maven", "gradle"]>;
|
|
6
|
+
type JavaBuildTool = z.infer<typeof JavaBuildToolSchema>;
|
|
5
7
|
declare const TransportSchema: z.ZodEnum<["stdio", "sse"]>;
|
|
6
8
|
type Transport = z.infer<typeof TransportSchema>;
|
|
7
9
|
declare const ToolParameterSchema: z.ZodObject<{
|
|
@@ -80,7 +82,7 @@ type ResourceConfig = z.infer<typeof ResourceConfigSchema>;
|
|
|
80
82
|
declare const ProjectConfigSchema: z.ZodObject<{
|
|
81
83
|
name: z.ZodString;
|
|
82
84
|
description: z.ZodDefault<z.ZodString>;
|
|
83
|
-
language: z.ZodEnum<["typescript", "python", "go", "rust"]>;
|
|
85
|
+
language: z.ZodEnum<["typescript", "python", "go", "rust", "java", "kotlin", "csharp", "elixir"]>;
|
|
84
86
|
transport: z.ZodEnum<["stdio", "sse"]>;
|
|
85
87
|
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
86
88
|
name: z.ZodString;
|
|
@@ -139,10 +141,11 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
139
141
|
includeExampleTool: z.ZodDefault<z.ZodBoolean>;
|
|
140
142
|
skipInstall: z.ZodDefault<z.ZodBoolean>;
|
|
141
143
|
initGit: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
javaBuildTool: z.ZodOptional<z.ZodEnum<["maven", "gradle"]>>;
|
|
142
145
|
}, "strip", z.ZodTypeAny, {
|
|
143
146
|
name: string;
|
|
144
147
|
description: string;
|
|
145
|
-
language: "typescript" | "python" | "go" | "rust";
|
|
148
|
+
language: "typescript" | "python" | "go" | "rust" | "java" | "kotlin" | "csharp" | "elixir";
|
|
146
149
|
transport: "stdio" | "sse";
|
|
147
150
|
tools: {
|
|
148
151
|
name: string;
|
|
@@ -163,9 +166,10 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
163
166
|
includeExampleTool: boolean;
|
|
164
167
|
skipInstall: boolean;
|
|
165
168
|
initGit: boolean;
|
|
169
|
+
javaBuildTool?: "maven" | "gradle" | undefined;
|
|
166
170
|
}, {
|
|
167
171
|
name: string;
|
|
168
|
-
language: "typescript" | "python" | "go" | "rust";
|
|
172
|
+
language: "typescript" | "python" | "go" | "rust" | "java" | "kotlin" | "csharp" | "elixir";
|
|
169
173
|
transport: "stdio" | "sse";
|
|
170
174
|
description?: string | undefined;
|
|
171
175
|
tools?: {
|
|
@@ -187,6 +191,7 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
187
191
|
includeExampleTool?: boolean | undefined;
|
|
188
192
|
skipInstall?: boolean | undefined;
|
|
189
193
|
initGit?: boolean | undefined;
|
|
194
|
+
javaBuildTool?: "maven" | "gradle" | undefined;
|
|
190
195
|
}>;
|
|
191
196
|
type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
|
|
192
197
|
interface GeneratorContext {
|
|
@@ -201,6 +206,12 @@ interface CLIOptions {
|
|
|
201
206
|
python?: boolean;
|
|
202
207
|
go?: boolean;
|
|
203
208
|
rust?: boolean;
|
|
209
|
+
java?: boolean;
|
|
210
|
+
kotlin?: boolean;
|
|
211
|
+
csharp?: boolean;
|
|
212
|
+
elixir?: boolean;
|
|
213
|
+
maven?: boolean;
|
|
214
|
+
gradle?: boolean;
|
|
204
215
|
skipInstall?: boolean;
|
|
205
216
|
fromOpenapi?: string;
|
|
206
217
|
fromPrompt?: boolean;
|
|
@@ -361,6 +372,9 @@ declare abstract class BaseGenerator {
|
|
|
361
372
|
private installPythonDependencies;
|
|
362
373
|
private installGoDependencies;
|
|
363
374
|
private installRustDependencies;
|
|
375
|
+
private installJavaDependencies;
|
|
376
|
+
private installDotnetDependencies;
|
|
377
|
+
private installElixirDependencies;
|
|
364
378
|
private checkCommand;
|
|
365
379
|
protected initializeGit(): Promise<void>;
|
|
366
380
|
protected checkOutputDir(): Promise<boolean>;
|
|
@@ -401,6 +415,7 @@ interface PresetGeneratorOptions {
|
|
|
401
415
|
language?: Language;
|
|
402
416
|
skipInstall?: boolean;
|
|
403
417
|
useDefaults?: boolean;
|
|
418
|
+
javaBuildTool?: JavaBuildTool;
|
|
404
419
|
}
|
|
405
420
|
declare function generateFromPreset(options: PresetGeneratorOptions): Promise<void>;
|
|
406
421
|
declare function validatePresetId(presetId: string): presetId is PresetId;
|
|
@@ -432,7 +447,7 @@ declare const logger: {
|
|
|
432
447
|
list: (items: string[]) => void;
|
|
433
448
|
code: (code: string) => void;
|
|
434
449
|
box: (title: string, content: string[]) => void;
|
|
435
|
-
nextSteps: (projectName: string, language: string) => void;
|
|
450
|
+
nextSteps: (projectName: string, language: string, javaBuildTool?: string) => void;
|
|
436
451
|
};
|
|
437
452
|
|
|
438
453
|
interface SpinnerInstance {
|
|
@@ -518,14 +533,17 @@ declare function promptGenerationMethod(): Promise<GenerationMethod>;
|
|
|
518
533
|
|
|
519
534
|
declare function promptPreset(): Promise<PresetId>;
|
|
520
535
|
|
|
536
|
+
declare function promptJavaBuildTool(): Promise<JavaBuildTool>;
|
|
537
|
+
|
|
521
538
|
interface WizardOptions {
|
|
522
539
|
defaultName?: string;
|
|
523
540
|
skipDescription?: boolean;
|
|
524
541
|
skipAdvanced?: boolean;
|
|
525
542
|
presetLanguage?: Language;
|
|
543
|
+
presetJavaBuildTool?: JavaBuildTool;
|
|
526
544
|
}
|
|
527
545
|
declare function runWizard(options?: WizardOptions): Promise<ProjectConfig>;
|
|
528
|
-
declare function runQuickWizard(defaultName?: string, presetLanguage?: Language): Promise<ProjectConfig>;
|
|
546
|
+
declare function runQuickWizard(defaultName?: string, presetLanguage?: Language, presetJavaBuildTool?: JavaBuildTool): Promise<ProjectConfig>;
|
|
529
547
|
|
|
530
548
|
declare function createCommand(projectName: string | undefined, options: CLIOptions): Promise<void>;
|
|
531
549
|
|
|
@@ -544,4 +562,4 @@ interface AddToolOptions {
|
|
|
544
562
|
}
|
|
545
563
|
declare function addToolCommand(options: AddToolOptions): Promise<void>;
|
|
546
564
|
|
|
547
|
-
export { BaseGenerator, type CLIOptions, type GenerationMethod, type GeneratorContext, type Language, LanguageSchema, type MCPPrompt, type MCPPromptArgument, type MCPPropertySchema, type MCPResource, type MCPServerCapabilities, type MCPServerInfo, type MCPTool, type MCPToolInputSchema, type OpenAPIComponents, OpenAPIGenerator, type OpenAPIInfo, type OpenAPIMediaType, type OpenAPIOperation, type OpenAPIParameter, type OpenAPIPathItem, type OpenAPIRequestBody, type OpenAPIResponse, type OpenAPISchema, type OpenAPIServer, type OpenAPISpec, type ParsedEndpoint, type ParsedParameter, type ParsedRequestBody, PresetGenerator, type PresetGeneratorOptions, type PresetId$1 as PresetId, PresetIdSchema, type ProjectConfig, ProjectConfigSchema, PromptGenerator, type ResourceConfig, ResourceConfigSchema, type SpinnerInstance, type ToolConfig, ToolConfigSchema, type ToolParameter, ToolParameterSchema, type Transport, TransportSchema, WizardGenerator, type WizardOptions, addToolCommand, copyDir, copyFile, createCommand, createGeneratorContext, createInitialCommit, createSpinner, endpointToMCPTool, ensureDir, exists, generateFromOpenAPI, generateFromPreset, generateFromPrompt, generateFromWizard, getGitUser, getTemplateDir, initCommand, initGitRepository, isDirectory, isGitInstalled, isInsideGitRepository, logger, parseAndValidate, parseOpenAPISpec, parsePostmanCollection, parseSwaggerSpec, projectNameRegex, promptAddResources, promptAddTools, promptGenerationMethod, promptIncludeExampleTool, promptLanguage, promptMultipleResources, promptMultipleTools, promptPreset, promptProjectDescription, promptProjectName, promptResourceConfig, promptToolConfig, promptTransport, readDir, readFile, remove, renderTemplate, renderTemplateToFile, resolveOutputPath, runQuickWizard, runWizard, safeParseAndValidate, selectEndpoints, validateFilePath, validatePresetId, validateProjectName, validateToolName, validateUrl, walkDir, withSpinner, writeFile };
|
|
565
|
+
export { BaseGenerator, type CLIOptions, type GenerationMethod, type GeneratorContext, type JavaBuildTool, JavaBuildToolSchema, type Language, LanguageSchema, type MCPPrompt, type MCPPromptArgument, type MCPPropertySchema, type MCPResource, type MCPServerCapabilities, type MCPServerInfo, type MCPTool, type MCPToolInputSchema, type OpenAPIComponents, OpenAPIGenerator, type OpenAPIInfo, type OpenAPIMediaType, type OpenAPIOperation, type OpenAPIParameter, type OpenAPIPathItem, type OpenAPIRequestBody, type OpenAPIResponse, type OpenAPISchema, type OpenAPIServer, type OpenAPISpec, type ParsedEndpoint, type ParsedParameter, type ParsedRequestBody, PresetGenerator, type PresetGeneratorOptions, type PresetId$1 as PresetId, PresetIdSchema, type ProjectConfig, ProjectConfigSchema, PromptGenerator, type ResourceConfig, ResourceConfigSchema, type SpinnerInstance, type ToolConfig, ToolConfigSchema, type ToolParameter, ToolParameterSchema, type Transport, TransportSchema, WizardGenerator, type WizardOptions, addToolCommand, copyDir, copyFile, createCommand, createGeneratorContext, createInitialCommit, createSpinner, endpointToMCPTool, ensureDir, exists, generateFromOpenAPI, generateFromPreset, generateFromPrompt, generateFromWizard, getGitUser, getTemplateDir, initCommand, initGitRepository, isDirectory, isGitInstalled, isInsideGitRepository, logger, parseAndValidate, parseOpenAPISpec, parsePostmanCollection, parseSwaggerSpec, projectNameRegex, promptAddResources, promptAddTools, promptGenerationMethod, promptIncludeExampleTool, promptJavaBuildTool, promptLanguage, promptMultipleResources, promptMultipleTools, promptPreset, promptProjectDescription, promptProjectName, promptResourceConfig, promptToolConfig, promptTransport, readDir, readFile, remove, renderTemplate, renderTemplateToFile, resolveOutputPath, runQuickWizard, runWizard, safeParseAndValidate, selectEndpoints, validateFilePath, validatePresetId, validateProjectName, validateToolName, validateUrl, walkDir, withSpinner, writeFile };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
promptAddTools,
|
|
34
34
|
promptGenerationMethod,
|
|
35
35
|
promptIncludeExampleTool,
|
|
36
|
+
promptJavaBuildTool,
|
|
36
37
|
promptLanguage,
|
|
37
38
|
promptMultipleResources,
|
|
38
39
|
promptMultipleTools,
|
|
@@ -60,11 +61,21 @@ import {
|
|
|
60
61
|
walkDir,
|
|
61
62
|
withSpinner,
|
|
62
63
|
writeFile
|
|
63
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-YISSMIHU.js";
|
|
64
65
|
|
|
65
66
|
// src/types/config.ts
|
|
66
67
|
import { z } from "zod";
|
|
67
|
-
var LanguageSchema = z.enum([
|
|
68
|
+
var LanguageSchema = z.enum([
|
|
69
|
+
"typescript",
|
|
70
|
+
"python",
|
|
71
|
+
"go",
|
|
72
|
+
"rust",
|
|
73
|
+
"java",
|
|
74
|
+
"kotlin",
|
|
75
|
+
"csharp",
|
|
76
|
+
"elixir"
|
|
77
|
+
]);
|
|
78
|
+
var JavaBuildToolSchema = z.enum(["maven", "gradle"]);
|
|
68
79
|
var TransportSchema = z.enum(["stdio", "sse"]);
|
|
69
80
|
var ToolParameterSchema = z.object({
|
|
70
81
|
name: z.string(),
|
|
@@ -92,7 +103,8 @@ var ProjectConfigSchema = z.object({
|
|
|
92
103
|
resources: z.array(ResourceConfigSchema).default([]),
|
|
93
104
|
includeExampleTool: z.boolean().default(true),
|
|
94
105
|
skipInstall: z.boolean().default(false),
|
|
95
|
-
initGit: z.boolean().default(true)
|
|
106
|
+
initGit: z.boolean().default(true),
|
|
107
|
+
javaBuildTool: JavaBuildToolSchema.optional()
|
|
96
108
|
});
|
|
97
109
|
var PresetIdSchema = z.enum(["database", "rest-api", "filesystem"]);
|
|
98
110
|
|
|
@@ -291,6 +303,7 @@ function nameToOperationId(name) {
|
|
|
291
303
|
}
|
|
292
304
|
export {
|
|
293
305
|
BaseGenerator,
|
|
306
|
+
JavaBuildToolSchema,
|
|
294
307
|
LanguageSchema,
|
|
295
308
|
OpenAPIGenerator,
|
|
296
309
|
PresetGenerator,
|
|
@@ -333,6 +346,7 @@ export {
|
|
|
333
346
|
promptAddTools,
|
|
334
347
|
promptGenerationMethod,
|
|
335
348
|
promptIncludeExampleTool,
|
|
349
|
+
promptJavaBuildTool,
|
|
336
350
|
promptLanguage,
|
|
337
351
|
promptMultipleResources,
|
|
338
352
|
promptMultipleTools,
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Build results
|
|
2
|
+
[Dd]ebug/
|
|
3
|
+
[Dd]ebugPublic/
|
|
4
|
+
[Rr]elease/
|
|
5
|
+
[Rr]eleases/
|
|
6
|
+
x64/
|
|
7
|
+
x86/
|
|
8
|
+
[Ww][Ii][Nn]32/
|
|
9
|
+
[Aa][Rr][Mm]/
|
|
10
|
+
[Aa][Rr][Mm]64/
|
|
11
|
+
bld/
|
|
12
|
+
[Bb]in/
|
|
13
|
+
[Oo]bj/
|
|
14
|
+
[Ll]og/
|
|
15
|
+
[Ll]ogs/
|
|
16
|
+
|
|
17
|
+
# Visual Studio
|
|
18
|
+
.vs/
|
|
19
|
+
*.user
|
|
20
|
+
*.userosscache
|
|
21
|
+
*.sln.docstates
|
|
22
|
+
*.suo
|
|
23
|
+
*.cache
|
|
24
|
+
*.sln.ide/
|
|
25
|
+
|
|
26
|
+
# Rider
|
|
27
|
+
.idea/
|
|
28
|
+
*.sln.iml
|
|
29
|
+
|
|
30
|
+
# NuGet
|
|
31
|
+
*.nupkg
|
|
32
|
+
*.snupkg
|
|
33
|
+
.nuget/
|
|
34
|
+
packages/
|
|
35
|
+
*.packages.targets
|
|
36
|
+
|
|
37
|
+
# dotnet
|
|
38
|
+
project.lock.json
|
|
39
|
+
project.fragment.lock.json
|
|
40
|
+
artifacts/
|
|
41
|
+
|
|
42
|
+
# Test results
|
|
43
|
+
[Tt]est[Rr]esult*/
|
|
44
|
+
[Bb]uild[Ll]og.*
|
|
45
|
+
|
|
46
|
+
# OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
Thumbs.db
|
|
49
|
+
|
|
50
|
+
# Environment
|
|
51
|
+
.env
|
|
52
|
+
.env.local
|
|
53
|
+
appsettings.Development.json
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<OutputType>Exe</OutputType>
|
|
5
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<Nullable>enable</Nullable>
|
|
8
|
+
<RootNamespace><%= namespace %></RootNamespace>
|
|
9
|
+
<AssemblyName><%= name %></AssemblyName>
|
|
10
|
+
</PropertyGroup>
|
|
11
|
+
|
|
12
|
+
<ItemGroup>
|
|
13
|
+
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.1" />
|
|
14
|
+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
|
15
|
+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
|
16
|
+
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
|
17
|
+
</ItemGroup>
|
|
18
|
+
|
|
19
|
+
</Project>
|