@leanmcp/cli 0.2.11 → 0.2.13

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/bin/leanmcp.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  // Always prefer ESM build
4
4
  import('../dist/index.js');
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3
3
 
4
4
  // src/index.ts
5
5
  import { Command } from "commander";
6
- import chalk3 from "chalk";
7
- import fs5 from "fs-extra";
8
- import path5 from "path";
9
- import ora3 from "ora";
6
+ import chalk6 from "chalk";
7
+ import fs7 from "fs-extra";
8
+ import path7 from "path";
9
+ import ora6 from "ora";
10
10
  import { createRequire } from "module";
11
- import { confirm } from "@inquirer/prompts";
11
+ import { confirm as confirm3 } from "@inquirer/prompts";
12
12
  import { spawn as spawn3 } from "child_process";
13
13
 
14
14
  // src/commands/dev.ts
@@ -158,9 +158,9 @@ async function buildUIComponent(uiApp, projectDir, isDev = false) {
158
158
  /** @type {import('tailwindcss').Config} */
159
159
  module.exports = {
160
160
  content: [
161
- '${path2.join(projectDir, "**/*.{ts,tsx,js,jsx}").replace(/\\/g, "/")}',
162
- '${path2.join(projectDir, "mcp/**/*.{ts,tsx,js,jsx}").replace(/\\/g, "/")}',
163
- '${path2.join(projectDir, "node_modules/@leanmcp/ui/**/*.{js,mjs}").replace(/\\/g, "/")}',
161
+ '${path2.join(projectDir, "src/**/*.{ts,tsx}").replace(/\\/g, "/")}',
162
+ '${path2.join(projectDir, "mcp/**/*.{ts,tsx}").replace(/\\/g, "/")}',
163
+ '${path2.join(projectDir, "node_modules/@leanmcp/ui/dist/**/*.{js,mjs}").replace(/\\/g, "/")}',
164
164
  '${path2.join(projectDir, "../../packages/ui/src/**/*.{ts,tsx}").replace(/\\/g, "/")}',
165
165
  ],
166
166
  darkMode: ['class'],
@@ -544,6 +544,1001 @@ async function startCommand() {
544
544
  }
545
545
  __name(startCommand, "startCommand");
546
546
 
547
+ // src/commands/login.ts
548
+ import chalk3 from "chalk";
549
+ import ora3 from "ora";
550
+ import path5 from "path";
551
+ import fs5 from "fs-extra";
552
+ import os from "os";
553
+ import { input, confirm } from "@inquirer/prompts";
554
+ var DEBUG_MODE = false;
555
+ function setDebugMode(enabled) {
556
+ DEBUG_MODE = enabled;
557
+ }
558
+ __name(setDebugMode, "setDebugMode");
559
+ function debug(message, ...args) {
560
+ if (DEBUG_MODE) {
561
+ console.log(chalk3.gray(`[DEBUG] ${message}`), ...args);
562
+ }
563
+ }
564
+ __name(debug, "debug");
565
+ var CONFIG_DIR = path5.join(os.homedir(), ".leanmcp");
566
+ var CONFIG_FILE = path5.join(CONFIG_DIR, "config.json");
567
+ async function loadConfig() {
568
+ try {
569
+ if (await fs5.pathExists(CONFIG_FILE)) {
570
+ return await fs5.readJSON(CONFIG_FILE);
571
+ }
572
+ } catch (error) {
573
+ }
574
+ return {};
575
+ }
576
+ __name(loadConfig, "loadConfig");
577
+ async function saveConfig(config) {
578
+ await fs5.ensureDir(CONFIG_DIR);
579
+ await fs5.writeJSON(CONFIG_FILE, config, {
580
+ spaces: 2
581
+ });
582
+ }
583
+ __name(saveConfig, "saveConfig");
584
+ async function getApiKey() {
585
+ const config = await loadConfig();
586
+ return config.apiKey || null;
587
+ }
588
+ __name(getApiKey, "getApiKey");
589
+ var ALLOWED_API_URLS = [
590
+ "https://api.leanmcp.com",
591
+ "https://devapi.leanmcp.com",
592
+ "https://qaapi.leanmcp.com",
593
+ "http://localhost:3001"
594
+ ];
595
+ var DEFAULT_API_URL = "https://api.leanmcp.com";
596
+ function isValidApiUrl(url) {
597
+ return ALLOWED_API_URLS.includes(url);
598
+ }
599
+ __name(isValidApiUrl, "isValidApiUrl");
600
+ async function getApiUrl() {
601
+ const config = await loadConfig();
602
+ if (!config.apiUrl) {
603
+ return DEFAULT_API_URL;
604
+ }
605
+ if (!isValidApiUrl(config.apiUrl)) {
606
+ throw new Error(`Invalid API URL: ${config.apiUrl}
607
+ Allowed URLs:
608
+ - https://api.leanmcp.com
609
+ - https://devapi.leanmcp.com
610
+ - https://qaapi.leanmcp.com
611
+ - http://localhost:3001`);
612
+ }
613
+ return config.apiUrl;
614
+ }
615
+ __name(getApiUrl, "getApiUrl");
616
+ async function loginCommand() {
617
+ console.log(chalk3.cyan("\nLeanMCP Login\n"));
618
+ const existingConfig = await loadConfig();
619
+ if (existingConfig.apiKey) {
620
+ console.log(chalk3.yellow("You are already logged in."));
621
+ const shouldRelogin = await confirm({
622
+ message: "Do you want to replace the existing API key?",
623
+ default: false
624
+ });
625
+ if (!shouldRelogin) {
626
+ console.log(chalk3.gray("\nLogin cancelled. Existing API key preserved."));
627
+ return;
628
+ }
629
+ }
630
+ console.log(chalk3.white("To authenticate, you need an API key from LeanMCP.\n"));
631
+ console.log(chalk3.cyan("Steps:"));
632
+ console.log(chalk3.gray(" 1. Go to: ") + chalk3.blue.underline("https://ship.leanmcp.com/api-keys"));
633
+ console.log(chalk3.gray(' 2. Create a new API key with "BUILD_AND_DEPLOY" scope'));
634
+ console.log(chalk3.gray(" 3. Copy the API key and paste it below\n"));
635
+ const apiKey = await input({
636
+ message: "Enter your API key:",
637
+ validate: /* @__PURE__ */ __name((value) => {
638
+ if (!value || value.trim().length === 0) {
639
+ return "API key is required";
640
+ }
641
+ if (!value.startsWith("airtrain_")) {
642
+ return 'Invalid API key format. API key should start with "airtrain_"';
643
+ }
644
+ return true;
645
+ }, "validate")
646
+ });
647
+ const spinner = ora3("Validating API key...").start();
648
+ try {
649
+ const apiUrl = await getApiUrl();
650
+ const validateUrl = `${apiUrl}/api-keys/validate`;
651
+ debug("API URL:", apiUrl);
652
+ debug("Validate URL:", validateUrl);
653
+ debug("Making validation request...");
654
+ const response = await fetch(validateUrl, {
655
+ method: "GET",
656
+ headers: {
657
+ "Authorization": `Bearer ${apiKey.trim()}`,
658
+ "Content-Type": "application/json"
659
+ }
660
+ });
661
+ debug("Response status:", response.status);
662
+ debug("Response ok:", response.ok);
663
+ if (!response.ok) {
664
+ const errorText = await response.text();
665
+ debug("Error response:", errorText);
666
+ spinner.fail("Invalid API key");
667
+ console.error(chalk3.red("\nThe API key is invalid or has expired."));
668
+ console.log(chalk3.gray("Please check your API key and try again."));
669
+ if (DEBUG_MODE) {
670
+ console.log(chalk3.gray(`Debug: Status ${response.status}, Response: ${errorText}`));
671
+ }
672
+ process.exit(1);
673
+ }
674
+ await saveConfig({
675
+ apiKey: apiKey.trim(),
676
+ apiUrl,
677
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
678
+ });
679
+ spinner.succeed("API key validated and saved");
680
+ console.log(chalk3.green("\nLogin successful!"));
681
+ console.log(chalk3.gray(` Config saved to: ${CONFIG_FILE}
682
+ `));
683
+ console.log(chalk3.cyan("You can now use:"));
684
+ console.log(chalk3.gray(" leanmcp deploy <folder> - Deploy your MCP server"));
685
+ console.log(chalk3.gray(" leanmcp logout - Remove your API key"));
686
+ } catch (error) {
687
+ spinner.fail("Failed to validate API key");
688
+ debug("Error:", error);
689
+ if (error instanceof Error && error.message.includes("fetch")) {
690
+ console.error(chalk3.red("\nCould not connect to LeanMCP servers."));
691
+ console.log(chalk3.gray("Please check your internet connection and try again."));
692
+ } else {
693
+ console.error(chalk3.red(`
694
+ Error: ${error instanceof Error ? error.message : String(error)}`));
695
+ }
696
+ if (DEBUG_MODE) {
697
+ console.log(chalk3.gray(`
698
+ Debug: Full error: ${error}`));
699
+ }
700
+ process.exit(1);
701
+ }
702
+ }
703
+ __name(loginCommand, "loginCommand");
704
+ async function logoutCommand() {
705
+ console.log(chalk3.cyan("\nLeanMCP Logout\n"));
706
+ const config = await loadConfig();
707
+ if (!config.apiKey) {
708
+ console.log(chalk3.yellow("You are not currently logged in."));
709
+ return;
710
+ }
711
+ const shouldLogout = await confirm({
712
+ message: "Are you sure you want to logout and remove your API key?",
713
+ default: false
714
+ });
715
+ if (!shouldLogout) {
716
+ console.log(chalk3.gray("\nLogout cancelled."));
717
+ return;
718
+ }
719
+ await saveConfig({
720
+ ...config,
721
+ apiKey: void 0,
722
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
723
+ });
724
+ console.log(chalk3.green("\nLogged out successfully!"));
725
+ console.log(chalk3.gray(` API key removed from: ${CONFIG_FILE}`));
726
+ }
727
+ __name(logoutCommand, "logoutCommand");
728
+ async function whoamiCommand() {
729
+ const config = await loadConfig();
730
+ if (!config.apiKey) {
731
+ console.log(chalk3.yellow("\nYou are not logged in."));
732
+ console.log(chalk3.gray("Run `leanmcp login` to authenticate.\n"));
733
+ return;
734
+ }
735
+ console.log(chalk3.cyan("\nLeanMCP Authentication Status\n"));
736
+ console.log(chalk3.green("Logged in"));
737
+ console.log(chalk3.gray(` API Key: ${config.apiKey.substring(0, 15)}...`));
738
+ console.log(chalk3.gray(` API URL: ${config.apiUrl || "https://ship.leanmcp.com"}`));
739
+ if (config.lastUpdated) {
740
+ console.log(chalk3.gray(` Last updated: ${new Date(config.lastUpdated).toLocaleString()}`));
741
+ }
742
+ console.log();
743
+ }
744
+ __name(whoamiCommand, "whoamiCommand");
745
+
746
+ // src/commands/deploy.ts
747
+ import chalk4 from "chalk";
748
+ import ora4 from "ora";
749
+ import path6 from "path";
750
+ import fs6 from "fs-extra";
751
+ import os2 from "os";
752
+ import archiver from "archiver";
753
+ import { input as input2, confirm as confirm2, select } from "@inquirer/prompts";
754
+
755
+ // src/utils/name-generator.ts
756
+ var ADJECTIVES = [
757
+ "swift",
758
+ "bright",
759
+ "calm",
760
+ "bold",
761
+ "cool",
762
+ "crisp",
763
+ "dark",
764
+ "dawn",
765
+ "deep",
766
+ "fair",
767
+ "fast",
768
+ "fine",
769
+ "glad",
770
+ "gold",
771
+ "good",
772
+ "gray",
773
+ "green",
774
+ "happy",
775
+ "keen",
776
+ "kind",
777
+ "late",
778
+ "lean",
779
+ "light",
780
+ "long",
781
+ "loud",
782
+ "mild",
783
+ "neat",
784
+ "new",
785
+ "nice",
786
+ "old",
787
+ "pale",
788
+ "pink",
789
+ "plain",
790
+ "prime",
791
+ "pure",
792
+ "quick",
793
+ "quiet",
794
+ "rare",
795
+ "red",
796
+ "rich",
797
+ "rough",
798
+ "royal",
799
+ "safe",
800
+ "sharp",
801
+ "shy",
802
+ "silver",
803
+ "slim",
804
+ "slow",
805
+ "smart",
806
+ "smooth",
807
+ "soft",
808
+ "solid",
809
+ "still",
810
+ "sunny",
811
+ "super",
812
+ "sweet",
813
+ "tall",
814
+ "tidy",
815
+ "tiny",
816
+ "true",
817
+ "warm",
818
+ "wild",
819
+ "wise",
820
+ "young"
821
+ ];
822
+ var SCIENTISTS = [
823
+ // AI & Computer Science
824
+ "turing",
825
+ "shannon",
826
+ "mccarthy",
827
+ "minsky",
828
+ "newell",
829
+ "simon",
830
+ "dijkstra",
831
+ "knuth",
832
+ "hopper",
833
+ "lovelace",
834
+ "hinton",
835
+ "lecun",
836
+ "bengio",
837
+ "schmidhuber",
838
+ "hochreiter",
839
+ "sutskever",
840
+ "salakhutdinov",
841
+ "goodfellow",
842
+ "vaswani",
843
+ "bahdanau",
844
+ "mikolov",
845
+ "pearl",
846
+ "jordan",
847
+ "bishop",
848
+ "russell",
849
+ "norvig",
850
+ "ng",
851
+ "koller",
852
+ "murphy",
853
+ "bottou",
854
+ "hassabis",
855
+ "silver",
856
+ "hopfield",
857
+ "feifei",
858
+ "karpathy",
859
+ "li",
860
+ // Physics
861
+ "einstein",
862
+ "newton",
863
+ "hawking",
864
+ "feynman",
865
+ "bohr",
866
+ "planck",
867
+ "dirac",
868
+ "heisenberg",
869
+ "schrodinger",
870
+ "maxwell",
871
+ "faraday",
872
+ "curie",
873
+ "fermi",
874
+ "tesla",
875
+ "oppenheimer",
876
+ "pauli",
877
+ "born",
878
+ "yang",
879
+ "lee",
880
+ "wu",
881
+ "chandrasekhar",
882
+ "raman",
883
+ "bose",
884
+ "salam",
885
+ "weinberg",
886
+ "gell-mann",
887
+ "higgs",
888
+ "penrose",
889
+ // Mathematics
890
+ "euler",
891
+ "gauss",
892
+ "riemann",
893
+ "hilbert",
894
+ "godel",
895
+ "turing",
896
+ "nash",
897
+ "ramanujan",
898
+ "erdos",
899
+ "noether",
900
+ "galois",
901
+ "cauchy",
902
+ "laplace",
903
+ "fourier",
904
+ "leibniz",
905
+ "pascal",
906
+ "fermat",
907
+ "descartes",
908
+ "archimedes",
909
+ "euclid",
910
+ "pythagoras",
911
+ "fibonacci",
912
+ "cantor",
913
+ "poincare",
914
+ "kolmogorov",
915
+ "bayes",
916
+ "markov",
917
+ "rao",
918
+ "tao",
919
+ "mirzakhani",
920
+ "grothendieck",
921
+ "wiles",
922
+ "perelman"
923
+ ];
924
+ function generateProjectName() {
925
+ const adj = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)];
926
+ const scientist = SCIENTISTS[Math.floor(Math.random() * SCIENTISTS.length)];
927
+ const num = Math.floor(Math.random() * 100);
928
+ return `${adj}-${scientist}-${num}`;
929
+ }
930
+ __name(generateProjectName, "generateProjectName");
931
+
932
+ // src/commands/deploy.ts
933
+ var DEBUG_MODE2 = false;
934
+ function setDeployDebugMode(enabled) {
935
+ DEBUG_MODE2 = enabled;
936
+ }
937
+ __name(setDeployDebugMode, "setDeployDebugMode");
938
+ function debug2(message, ...args) {
939
+ if (DEBUG_MODE2) {
940
+ console.log(chalk4.gray(`[DEBUG] ${message}`), ...args);
941
+ }
942
+ }
943
+ __name(debug2, "debug");
944
+ async function debugFetch(url, options = {}) {
945
+ debug2(`HTTP ${options.method || "GET"} ${url}`);
946
+ if (options.body && typeof options.body === "string") {
947
+ try {
948
+ const body = JSON.parse(options.body);
949
+ debug2("Request body:", JSON.stringify(body, null, 2));
950
+ } catch {
951
+ debug2("Request body:", options.body);
952
+ }
953
+ }
954
+ const startTime = Date.now();
955
+ const response = await fetch(url, options);
956
+ const duration = Date.now() - startTime;
957
+ debug2(`Response: ${response.status} ${response.statusText} (${duration}ms)`);
958
+ return response;
959
+ }
960
+ __name(debugFetch, "debugFetch");
961
+ var API_ENDPOINTS = {
962
+ // Projects
963
+ projects: "/api/projects",
964
+ getUploadUrl: "/api/projects",
965
+ // Lambda builds
966
+ triggerBuild: "/api/lambda-builds/trigger",
967
+ getBuild: "/api/lambda-builds",
968
+ // Lambda deployments
969
+ createDeployment: "/api/lambda-deploy",
970
+ getDeployment: "/api/lambda-deploy",
971
+ // Lambda mapping
972
+ checkSubdomain: "/api/lambda-mapping/check",
973
+ createMapping: "/api/lambda-mapping"
974
+ };
975
+ async function createZipArchive(folderPath, outputPath) {
976
+ return new Promise((resolve, reject) => {
977
+ const output = fs6.createWriteStream(outputPath);
978
+ const archive = archiver("zip", {
979
+ zlib: {
980
+ level: 9
981
+ }
982
+ });
983
+ output.on("close", () => resolve(archive.pointer()));
984
+ archive.on("error", reject);
985
+ archive.pipe(output);
986
+ archive.glob("**/*", {
987
+ cwd: folderPath,
988
+ ignore: [
989
+ "node_modules/**",
990
+ ".git/**",
991
+ "dist/**",
992
+ ".next/**",
993
+ ".nuxt/**",
994
+ "__pycache__/**",
995
+ "*.log",
996
+ ".env.local",
997
+ ".DS_Store"
998
+ ]
999
+ });
1000
+ archive.finalize();
1001
+ });
1002
+ }
1003
+ __name(createZipArchive, "createZipArchive");
1004
+ async function waitForBuild(apiUrl, apiKey, buildId, spinner) {
1005
+ const maxAttempts = 60;
1006
+ let attempts = 0;
1007
+ while (attempts < maxAttempts) {
1008
+ const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getBuild}/${buildId}`, {
1009
+ headers: {
1010
+ "Authorization": `Bearer ${apiKey}`
1011
+ }
1012
+ });
1013
+ if (!response.ok) {
1014
+ throw new Error(`Failed to get build status: ${response.statusText}`);
1015
+ }
1016
+ const build2 = await response.json();
1017
+ spinner.text = `Building... (${build2.status || "pending"})`;
1018
+ if (build2.status === "succeeded" || build2.status === "SUCCEEDED") {
1019
+ return {
1020
+ imageUri: build2.imageUri,
1021
+ status: "succeeded"
1022
+ };
1023
+ }
1024
+ if (build2.status === "failed" || build2.status === "FAILED") {
1025
+ throw new Error(`Build failed: ${build2.errorMessage || "Unknown error"}`);
1026
+ }
1027
+ await new Promise((r) => setTimeout(r, 5e3));
1028
+ attempts++;
1029
+ }
1030
+ throw new Error("Build timed out after 5 minutes");
1031
+ }
1032
+ __name(waitForBuild, "waitForBuild");
1033
+ async function waitForDeployment(apiUrl, apiKey, deploymentId, spinner) {
1034
+ const maxAttempts = 60;
1035
+ let attempts = 0;
1036
+ while (attempts < maxAttempts) {
1037
+ const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getDeployment}/${deploymentId}`, {
1038
+ headers: {
1039
+ "Authorization": `Bearer ${apiKey}`
1040
+ }
1041
+ });
1042
+ if (!response.ok) {
1043
+ throw new Error(`Failed to get deployment status: ${response.statusText}`);
1044
+ }
1045
+ const deployment = await response.json();
1046
+ spinner.text = `Deploying... (${deployment.status || "pending"})`;
1047
+ if (deployment.status === "RUNNING") {
1048
+ return {
1049
+ functionUrl: deployment.functionUrl,
1050
+ status: "running"
1051
+ };
1052
+ }
1053
+ if (deployment.status === "FAILED") {
1054
+ throw new Error(`Deployment failed: ${deployment.errorMessage || "Unknown error"}`);
1055
+ }
1056
+ await new Promise((r) => setTimeout(r, 5e3));
1057
+ attempts++;
1058
+ }
1059
+ throw new Error("Deployment timed out after 5 minutes");
1060
+ }
1061
+ __name(waitForDeployment, "waitForDeployment");
1062
+ async function deployCommand(folderPath, options = {}) {
1063
+ const deployStartTime = Date.now();
1064
+ console.log(chalk4.cyan("\nLeanMCP Deploy\n"));
1065
+ debug2("Starting deployment...");
1066
+ const apiKey = await getApiKey();
1067
+ if (!apiKey) {
1068
+ console.error(chalk4.red("Not logged in."));
1069
+ console.log(chalk4.gray("Run `leanmcp login` first to authenticate.\n"));
1070
+ process.exit(1);
1071
+ }
1072
+ const apiUrl = await getApiUrl();
1073
+ debug2("API URL:", apiUrl);
1074
+ const absolutePath = path6.resolve(process.cwd(), folderPath);
1075
+ if (!await fs6.pathExists(absolutePath)) {
1076
+ console.error(chalk4.red(`Folder not found: ${absolutePath}`));
1077
+ process.exit(1);
1078
+ }
1079
+ const hasMainTs = await fs6.pathExists(path6.join(absolutePath, "main.ts"));
1080
+ const hasPackageJson = await fs6.pathExists(path6.join(absolutePath, "package.json"));
1081
+ if (!hasMainTs && !hasPackageJson) {
1082
+ console.error(chalk4.red("Not a valid project folder."));
1083
+ console.log(chalk4.gray("Expected main.ts or package.json in the folder.\n"));
1084
+ process.exit(1);
1085
+ }
1086
+ debug2("Fetching existing projects...");
1087
+ let existingProjects = [];
1088
+ try {
1089
+ const projectsResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.projects}`, {
1090
+ headers: {
1091
+ "Authorization": `Bearer ${apiKey}`
1092
+ }
1093
+ });
1094
+ if (projectsResponse.ok) {
1095
+ existingProjects = await projectsResponse.json();
1096
+ debug2(`Found ${existingProjects.length} existing projects`);
1097
+ }
1098
+ } catch (e) {
1099
+ debug2("Could not fetch existing projects");
1100
+ }
1101
+ let projectName;
1102
+ let existingProject = null;
1103
+ let isUpdate = false;
1104
+ let folderName = path6.basename(absolutePath);
1105
+ if (hasPackageJson) {
1106
+ try {
1107
+ const pkg2 = await fs6.readJSON(path6.join(absolutePath, "package.json"));
1108
+ folderName = pkg2.name || folderName;
1109
+ } catch (e) {
1110
+ }
1111
+ }
1112
+ const matchingProject = existingProjects.find((p) => p.name === folderName);
1113
+ if (matchingProject) {
1114
+ console.log(chalk4.yellow(`Project '${folderName}' already exists.
1115
+ `));
1116
+ const choice = await select({
1117
+ message: "What would you like to do?",
1118
+ choices: [
1119
+ {
1120
+ value: "update",
1121
+ name: `Update existing project '${folderName}'`
1122
+ },
1123
+ {
1124
+ value: "new",
1125
+ name: "Create a new project with a random name"
1126
+ },
1127
+ {
1128
+ value: "cancel",
1129
+ name: "Cancel deployment"
1130
+ }
1131
+ ]
1132
+ });
1133
+ if (choice === "cancel") {
1134
+ console.log(chalk4.gray("\nDeployment cancelled.\n"));
1135
+ return;
1136
+ }
1137
+ if (choice === "update") {
1138
+ existingProject = matchingProject;
1139
+ projectName = matchingProject.name;
1140
+ isUpdate = true;
1141
+ console.log(chalk4.yellow("\nWARNING: This will replace the existing deployment."));
1142
+ console.log(chalk4.gray("The previous version will be overwritten.\n"));
1143
+ } else {
1144
+ projectName = generateProjectName();
1145
+ console.log(chalk4.cyan(`
1146
+ Generated project name: ${chalk4.bold(projectName)}
1147
+ `));
1148
+ }
1149
+ } else {
1150
+ projectName = generateProjectName();
1151
+ console.log(chalk4.cyan(`Generated project name: ${chalk4.bold(projectName)}`));
1152
+ }
1153
+ console.log(chalk4.gray(`Path: ${absolutePath}
1154
+ `));
1155
+ let subdomain = options.subdomain;
1156
+ if (!subdomain) {
1157
+ const suggestedSubdomain = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
1158
+ subdomain = await input2({
1159
+ message: "Subdomain for your deployment:",
1160
+ default: suggestedSubdomain,
1161
+ validate: /* @__PURE__ */ __name((value) => {
1162
+ if (!value || value.trim().length === 0) {
1163
+ return "Subdomain is required";
1164
+ }
1165
+ if (!/^[a-z0-9-]+$/.test(value)) {
1166
+ return "Subdomain can only contain lowercase letters, numbers, and hyphens";
1167
+ }
1168
+ if (value.length < 3) {
1169
+ return "Subdomain must be at least 3 characters";
1170
+ }
1171
+ return true;
1172
+ }, "validate")
1173
+ });
1174
+ }
1175
+ const checkSpinner = ora4("Checking subdomain availability...").start();
1176
+ try {
1177
+ debug2("Checking subdomain:", subdomain);
1178
+ const checkResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.checkSubdomain}/${subdomain}`, {
1179
+ headers: {
1180
+ "Authorization": `Bearer ${apiKey}`
1181
+ }
1182
+ });
1183
+ if (checkResponse.ok) {
1184
+ const result = await checkResponse.json();
1185
+ if (!result.available) {
1186
+ checkSpinner.fail(`Subdomain '${subdomain}' is already taken`);
1187
+ console.log(chalk4.gray("\nPlease choose a different subdomain.\n"));
1188
+ process.exit(1);
1189
+ }
1190
+ }
1191
+ checkSpinner.succeed(`Subdomain '${subdomain}' is available`);
1192
+ } catch (error) {
1193
+ checkSpinner.warn("Could not verify subdomain availability");
1194
+ }
1195
+ if (!options.skipConfirm) {
1196
+ console.log(chalk4.cyan("\nDeployment Details:"));
1197
+ console.log(chalk4.gray(` Project: ${projectName}`));
1198
+ console.log(chalk4.gray(` Subdomain: ${subdomain}`));
1199
+ console.log(chalk4.gray(` URL: https://${subdomain}.leanmcp.dev
1200
+ `));
1201
+ const shouldDeploy = await confirm2({
1202
+ message: "Proceed with deployment?",
1203
+ default: true
1204
+ });
1205
+ if (!shouldDeploy) {
1206
+ console.log(chalk4.gray("\nDeployment cancelled.\n"));
1207
+ return;
1208
+ }
1209
+ }
1210
+ console.log();
1211
+ let projectId;
1212
+ if (isUpdate && existingProject) {
1213
+ projectId = existingProject.id;
1214
+ console.log(chalk4.gray(`Using existing project: ${projectId.substring(0, 8)}...`));
1215
+ } else {
1216
+ const projectSpinner = ora4("Creating project...").start();
1217
+ try {
1218
+ debug2("Step 1: Creating project:", projectName);
1219
+ const createResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.projects}`, {
1220
+ method: "POST",
1221
+ headers: {
1222
+ "Authorization": `Bearer ${apiKey}`,
1223
+ "Content-Type": "application/json"
1224
+ },
1225
+ body: JSON.stringify({
1226
+ name: projectName
1227
+ })
1228
+ });
1229
+ if (!createResponse.ok) {
1230
+ const error = await createResponse.text();
1231
+ throw new Error(`Failed to create project: ${error}`);
1232
+ }
1233
+ const project = await createResponse.json();
1234
+ projectId = project.id;
1235
+ projectSpinner.succeed(`Project created: ${projectId.substring(0, 8)}...`);
1236
+ } catch (error) {
1237
+ projectSpinner.fail("Failed to create project");
1238
+ console.error(chalk4.red(`
1239
+ ${error instanceof Error ? error.message : String(error)}`));
1240
+ process.exit(1);
1241
+ }
1242
+ }
1243
+ const uploadSpinner = ora4("Packaging and uploading...").start();
1244
+ try {
1245
+ const tempZip = path6.join(os2.tmpdir(), `leanmcp-${Date.now()}.zip`);
1246
+ const zipSize = await createZipArchive(absolutePath, tempZip);
1247
+ uploadSpinner.text = `Packaging... (${Math.round(zipSize / 1024)}KB)`;
1248
+ debug2("Step 2a: Getting upload URL for project:", projectId);
1249
+ const uploadUrlResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.projects}/${projectId}/upload-url`, {
1250
+ method: "POST",
1251
+ headers: {
1252
+ "Authorization": `Bearer ${apiKey}`,
1253
+ "Content-Type": "application/json"
1254
+ },
1255
+ body: JSON.stringify({
1256
+ fileName: `${subdomain}.zip`,
1257
+ fileType: "application/zip",
1258
+ fileSize: zipSize
1259
+ })
1260
+ });
1261
+ if (!uploadUrlResponse.ok) {
1262
+ throw new Error("Failed to get upload URL");
1263
+ }
1264
+ const uploadResult = await uploadUrlResponse.json();
1265
+ const uploadUrl = uploadResult.url || uploadResult.uploadUrl;
1266
+ const s3Location = uploadResult.s3Location;
1267
+ debug2("Upload URL response:", JSON.stringify(uploadResult));
1268
+ if (!uploadUrl) {
1269
+ throw new Error("Backend did not return upload URL");
1270
+ }
1271
+ debug2("Step 2b: Uploading to S3...");
1272
+ const zipBuffer = await fs6.readFile(tempZip);
1273
+ const s3Response = await fetch(uploadUrl, {
1274
+ method: "PUT",
1275
+ body: zipBuffer,
1276
+ headers: {
1277
+ "Content-Type": "application/zip"
1278
+ }
1279
+ });
1280
+ debug2("S3 upload response:", s3Response.status);
1281
+ if (!s3Response.ok) {
1282
+ throw new Error("Failed to upload to S3");
1283
+ }
1284
+ debug2("Step 2c: Updating project with S3 location:", s3Location);
1285
+ await debugFetch(`${apiUrl}${API_ENDPOINTS.projects}/${projectId}`, {
1286
+ method: "PATCH",
1287
+ headers: {
1288
+ "Authorization": `Bearer ${apiKey}`,
1289
+ "Content-Type": "application/json"
1290
+ },
1291
+ body: JSON.stringify({
1292
+ s3Location
1293
+ })
1294
+ });
1295
+ await fs6.remove(tempZip);
1296
+ uploadSpinner.succeed("Project uploaded");
1297
+ } catch (error) {
1298
+ uploadSpinner.fail("Failed to upload");
1299
+ console.error(chalk4.red(`
1300
+ ${error instanceof Error ? error.message : String(error)}`));
1301
+ process.exit(1);
1302
+ }
1303
+ const buildSpinner = ora4("Building...").start();
1304
+ const buildStartTime = Date.now();
1305
+ let buildId;
1306
+ let imageUri;
1307
+ try {
1308
+ debug2("Step 3: Triggering build for project:", projectId);
1309
+ const buildResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.triggerBuild}/${projectId}`, {
1310
+ method: "POST",
1311
+ headers: {
1312
+ "Authorization": `Bearer ${apiKey}`
1313
+ }
1314
+ });
1315
+ if (!buildResponse.ok) {
1316
+ const error = await buildResponse.text();
1317
+ throw new Error(`Failed to trigger build: ${error}`);
1318
+ }
1319
+ const build2 = await buildResponse.json();
1320
+ buildId = build2.id;
1321
+ const buildResult = await waitForBuild(apiUrl, apiKey, buildId, buildSpinner);
1322
+ imageUri = buildResult.imageUri;
1323
+ const buildDuration = Math.round((Date.now() - buildStartTime) / 1e3);
1324
+ buildSpinner.succeed(`Build complete (${buildDuration}s)`);
1325
+ } catch (error) {
1326
+ buildSpinner.fail("Build failed");
1327
+ console.error(chalk4.red(`
1328
+ ${error instanceof Error ? error.message : String(error)}`));
1329
+ process.exit(1);
1330
+ }
1331
+ const deploySpinner = ora4("Deploying to LeanMCP...").start();
1332
+ let deploymentId;
1333
+ let functionUrl;
1334
+ try {
1335
+ debug2("Step 4: Creating deployment for build:", buildId);
1336
+ const deployResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.createDeployment}`, {
1337
+ method: "POST",
1338
+ headers: {
1339
+ "Authorization": `Bearer ${apiKey}`,
1340
+ "Content-Type": "application/json"
1341
+ },
1342
+ body: JSON.stringify({
1343
+ buildId
1344
+ })
1345
+ });
1346
+ if (!deployResponse.ok) {
1347
+ const error = await deployResponse.text();
1348
+ throw new Error(`Failed to create deployment: ${error}`);
1349
+ }
1350
+ const deployment = await deployResponse.json();
1351
+ deploymentId = deployment.id;
1352
+ const deployResult = await waitForDeployment(apiUrl, apiKey, deploymentId, deploySpinner);
1353
+ functionUrl = deployResult.functionUrl;
1354
+ deploySpinner.succeed("Deployed");
1355
+ } catch (error) {
1356
+ deploySpinner.fail("Deployment failed");
1357
+ console.error(chalk4.red(`
1358
+ ${error instanceof Error ? error.message : String(error)}`));
1359
+ process.exit(1);
1360
+ }
1361
+ const mappingSpinner = ora4("Configuring subdomain...").start();
1362
+ try {
1363
+ debug2("Step 5: Creating subdomain mapping:", subdomain);
1364
+ const mappingResponse = await debugFetch(`${apiUrl}${API_ENDPOINTS.createMapping}`, {
1365
+ method: "POST",
1366
+ headers: {
1367
+ "Authorization": `Bearer ${apiKey}`,
1368
+ "Content-Type": "application/json"
1369
+ },
1370
+ body: JSON.stringify({
1371
+ subdomain,
1372
+ lambdaUrl: functionUrl,
1373
+ projectId,
1374
+ deploymentId
1375
+ })
1376
+ });
1377
+ if (!mappingResponse.ok) {
1378
+ mappingSpinner.warn("Subdomain mapping may need manual setup");
1379
+ } else {
1380
+ mappingSpinner.succeed("Subdomain configured");
1381
+ }
1382
+ } catch (error) {
1383
+ mappingSpinner.warn("Subdomain mapping may need manual setup");
1384
+ }
1385
+ console.log(chalk4.green("\n" + "=".repeat(60)));
1386
+ console.log(chalk4.green.bold(" DEPLOYMENT SUCCESSFUL!"));
1387
+ console.log(chalk4.green("=".repeat(60) + "\n"));
1388
+ console.log(chalk4.white(" Your MCP server is now live:\n"));
1389
+ console.log(chalk4.cyan(` URL: `) + chalk4.white.bold(`https://${subdomain}.leanmcp.dev`));
1390
+ console.log();
1391
+ console.log(chalk4.gray(" Test endpoints:"));
1392
+ console.log(chalk4.gray(` curl https://${subdomain}.leanmcp.dev/health`));
1393
+ console.log(chalk4.gray(` curl https://${subdomain}.leanmcp.dev/mcp`));
1394
+ console.log();
1395
+ const totalDuration = Math.round((Date.now() - deployStartTime) / 1e3);
1396
+ console.log(chalk4.gray(` Total time: ${totalDuration}s`));
1397
+ console.log();
1398
+ console.log(chalk4.gray(` Project ID: ${projectId}`));
1399
+ console.log(chalk4.gray(` Build ID: ${buildId}`));
1400
+ console.log(chalk4.gray(` Deployment ID: ${deploymentId}`));
1401
+ console.log();
1402
+ }
1403
+ __name(deployCommand, "deployCommand");
1404
+
1405
+ // src/commands/projects.ts
1406
+ import chalk5 from "chalk";
1407
+ import ora5 from "ora";
1408
+ var API_ENDPOINT = "/api/projects";
1409
+ async function projectsListCommand() {
1410
+ const apiKey = await getApiKey();
1411
+ if (!apiKey) {
1412
+ console.error(chalk5.red("\nNot logged in."));
1413
+ console.log(chalk5.gray("Run `leanmcp login` first to authenticate.\n"));
1414
+ process.exit(1);
1415
+ }
1416
+ const spinner = ora5("Fetching projects...").start();
1417
+ try {
1418
+ const apiUrl = await getApiUrl();
1419
+ const response = await fetch(`${apiUrl}${API_ENDPOINT}`, {
1420
+ headers: {
1421
+ "Authorization": `Bearer ${apiKey}`
1422
+ }
1423
+ });
1424
+ if (!response.ok) {
1425
+ throw new Error(`Failed to fetch projects: ${response.statusText}`);
1426
+ }
1427
+ const projects = await response.json();
1428
+ spinner.stop();
1429
+ if (projects.length === 0) {
1430
+ console.log(chalk5.yellow("\nNo projects found."));
1431
+ console.log(chalk5.gray("Create one with: leanmcp deploy <folder>\n"));
1432
+ return;
1433
+ }
1434
+ console.log(chalk5.cyan(`
1435
+ Your Projects (${projects.length})
1436
+ `));
1437
+ console.log(chalk5.gray("\u2500".repeat(60)));
1438
+ for (const project of projects) {
1439
+ const statusColor = project.status === "ACTIVE" ? chalk5.green : chalk5.yellow;
1440
+ console.log(chalk5.white.bold(` ${project.name}`));
1441
+ console.log(chalk5.gray(` ID: ${project.id}`));
1442
+ console.log(chalk5.gray(` Status: `) + statusColor(project.status));
1443
+ console.log(chalk5.gray(` Created: ${new Date(project.createdAt).toLocaleDateString()}`));
1444
+ console.log();
1445
+ }
1446
+ } catch (error) {
1447
+ spinner.fail("Failed to fetch projects");
1448
+ console.error(chalk5.red(`
1449
+ ${error instanceof Error ? error.message : String(error)}`));
1450
+ process.exit(1);
1451
+ }
1452
+ }
1453
+ __name(projectsListCommand, "projectsListCommand");
1454
+ async function projectsGetCommand(projectId) {
1455
+ const apiKey = await getApiKey();
1456
+ if (!apiKey) {
1457
+ console.error(chalk5.red("\nNot logged in."));
1458
+ console.log(chalk5.gray("Run `leanmcp login` first to authenticate.\n"));
1459
+ process.exit(1);
1460
+ }
1461
+ const spinner = ora5("Fetching project...").start();
1462
+ try {
1463
+ const apiUrl = await getApiUrl();
1464
+ const response = await fetch(`${apiUrl}${API_ENDPOINT}/${projectId}`, {
1465
+ headers: {
1466
+ "Authorization": `Bearer ${apiKey}`
1467
+ }
1468
+ });
1469
+ if (!response.ok) {
1470
+ if (response.status === 404) {
1471
+ throw new Error(`Project not found: ${projectId}`);
1472
+ }
1473
+ throw new Error(`Failed to fetch project: ${response.statusText}`);
1474
+ }
1475
+ const project = await response.json();
1476
+ spinner.stop();
1477
+ console.log(chalk5.cyan("\nProject Details\n"));
1478
+ console.log(chalk5.gray("\u2500".repeat(60)));
1479
+ console.log(chalk5.white.bold(` Name: ${project.name}`));
1480
+ console.log(chalk5.gray(` ID: ${project.id}`));
1481
+ console.log(chalk5.gray(` Status: ${project.status}`));
1482
+ if (project.s3Location) {
1483
+ console.log(chalk5.gray(` S3 Location: ${project.s3Location}`));
1484
+ }
1485
+ console.log(chalk5.gray(` Created: ${new Date(project.createdAt).toLocaleString()}`));
1486
+ if (project.updatedAt) {
1487
+ console.log(chalk5.gray(` Updated: ${new Date(project.updatedAt).toLocaleString()}`));
1488
+ }
1489
+ console.log();
1490
+ } catch (error) {
1491
+ spinner.fail("Failed to fetch project");
1492
+ console.error(chalk5.red(`
1493
+ ${error instanceof Error ? error.message : String(error)}`));
1494
+ process.exit(1);
1495
+ }
1496
+ }
1497
+ __name(projectsGetCommand, "projectsGetCommand");
1498
+ async function projectsDeleteCommand(projectId, options = {}) {
1499
+ const apiKey = await getApiKey();
1500
+ if (!apiKey) {
1501
+ console.error(chalk5.red("\nNot logged in."));
1502
+ console.log(chalk5.gray("Run `leanmcp login` first to authenticate.\n"));
1503
+ process.exit(1);
1504
+ }
1505
+ if (!options.force) {
1506
+ const { confirm: confirm4 } = await import("@inquirer/prompts");
1507
+ const shouldDelete = await confirm4({
1508
+ message: `Are you sure you want to delete project ${projectId}?`,
1509
+ default: false
1510
+ });
1511
+ if (!shouldDelete) {
1512
+ console.log(chalk5.gray("\nDeletion cancelled.\n"));
1513
+ return;
1514
+ }
1515
+ }
1516
+ const spinner = ora5("Deleting project...").start();
1517
+ try {
1518
+ const apiUrl = await getApiUrl();
1519
+ const response = await fetch(`${apiUrl}${API_ENDPOINT}/${projectId}`, {
1520
+ method: "DELETE",
1521
+ headers: {
1522
+ "Authorization": `Bearer ${apiKey}`
1523
+ }
1524
+ });
1525
+ if (!response.ok) {
1526
+ if (response.status === 404) {
1527
+ throw new Error(`Project not found: ${projectId}`);
1528
+ }
1529
+ throw new Error(`Failed to delete project: ${response.statusText}`);
1530
+ }
1531
+ spinner.succeed("Project deleted successfully");
1532
+ console.log();
1533
+ } catch (error) {
1534
+ spinner.fail("Failed to delete project");
1535
+ console.error(chalk5.red(`
1536
+ ${error instanceof Error ? error.message : String(error)}`));
1537
+ process.exit(1);
1538
+ }
1539
+ }
1540
+ __name(projectsDeleteCommand, "projectsDeleteCommand");
1541
+
547
1542
  // src/index.ts
548
1543
  var require2 = createRequire(import.meta.url);
549
1544
  var pkg = require2("../package.json");
@@ -554,17 +1549,24 @@ __name(capitalize, "capitalize");
554
1549
  var program = new Command();
555
1550
  program.name("leanmcp").description("LeanMCP CLI \u2014 create production-ready MCP servers with Streamable HTTP").version(pkg.version).addHelpText("after", `
556
1551
  Examples:
557
- $ leanmcp create my-app --allow-all # Scaffold without interactive prompts
1552
+ $ leanmcp create my-app # Create new project (interactive)
1553
+ $ leanmcp create my-app --install # Create and install deps (non-interactive)
1554
+ $ leanmcp create my-app --no-install # Create without installing deps
1555
+ $ leanmcp dev # Start development server
1556
+ $ leanmcp login # Authenticate with LeanMCP cloud
1557
+ $ leanmcp deploy ./my-app # Deploy to LeanMCP cloud
1558
+ $ leanmcp projects list # List your cloud projects
1559
+ $ leanmcp projects delete <id> # Delete a cloud project
558
1560
  `);
559
- program.command("create <projectName>").description("Create a new LeanMCP project with Streamable HTTP transport").option("--allow-all", "Skip interactive confirmations and assume Yes").option("--no-dashboard", "Disable dashboard UI at / and /mcp GET endpoints").action(async (projectName, options) => {
560
- const spinner = ora3(`Creating project ${projectName}...`).start();
561
- const targetDir = path5.join(process.cwd(), projectName);
562
- if (fs5.existsSync(targetDir)) {
1561
+ program.command("create <projectName>").description("Create a new LeanMCP project with Streamable HTTP transport").option("--allow-all", "Skip interactive confirmations and assume Yes").option("--no-dashboard", "Disable dashboard UI at / and /mcp GET endpoints").option("--install", "Install dependencies automatically (non-interactive, no dev server)").option("--no-install", "Skip dependency installation (non-interactive)").action(async (projectName, options) => {
1562
+ const spinner = ora6(`Creating project ${projectName}...`).start();
1563
+ const targetDir = path7.join(process.cwd(), projectName);
1564
+ if (fs7.existsSync(targetDir)) {
563
1565
  spinner.fail(`Folder ${projectName} already exists.`);
564
1566
  process.exit(1);
565
1567
  }
566
- await fs5.mkdirp(targetDir);
567
- await fs5.mkdirp(path5.join(targetDir, "mcp", "example"));
1568
+ await fs7.mkdirp(targetDir);
1569
+ await fs7.mkdirp(path7.join(targetDir, "mcp", "example"));
568
1570
  const pkg2 = {
569
1571
  name: projectName,
570
1572
  version: "1.0.0",
@@ -595,7 +1597,7 @@ program.command("create <projectName>").description("Create a new LeanMCP projec
595
1597
  "typescript": "^5.6.3"
596
1598
  }
597
1599
  };
598
- await fs5.writeJSON(path5.join(targetDir, "package.json"), pkg2, {
1600
+ await fs7.writeJSON(path7.join(targetDir, "package.json"), pkg2, {
599
1601
  spaces: 2
600
1602
  });
601
1603
  const tsconfig = {
@@ -618,7 +1620,7 @@ program.command("create <projectName>").description("Create a new LeanMCP projec
618
1620
  "dist"
619
1621
  ]
620
1622
  };
621
- await fs5.writeJSON(path5.join(targetDir, "tsconfig.json"), tsconfig, {
1623
+ await fs7.writeJSON(path7.join(targetDir, "tsconfig.json"), tsconfig, {
622
1624
  spaces: 2
623
1625
  });
624
1626
  const dashboardLine = options.dashboard === false ? `
@@ -640,7 +1642,7 @@ await createHTTPServer({
640
1642
 
641
1643
  console.log("\\n${projectName} MCP Server");
642
1644
  `;
643
- await fs5.writeFile(path5.join(targetDir, "main.ts"), mainTs);
1645
+ await fs7.writeFile(path7.join(targetDir, "main.ts"), mainTs);
644
1646
  const exampleServiceTs = `import { Tool, Resource, Prompt, SchemaConstraint, Optional } from "@leanmcp/core";
645
1647
 
646
1648
  /**
@@ -760,7 +1762,7 @@ console.log("\\n${projectName} MCP Server");
760
1762
  }
761
1763
  }
762
1764
  `;
763
- await fs5.writeFile(path5.join(targetDir, "mcp", "example", "index.ts"), exampleServiceTs);
1765
+ await fs7.writeFile(path7.join(targetDir, "mcp", "example", "index.ts"), exampleServiceTs);
764
1766
  const gitignore = `# Logs
765
1767
  logs
766
1768
  *.log
@@ -909,8 +1911,8 @@ NODE_ENV=development
909
1911
 
910
1912
  # Add your environment variables here
911
1913
  `;
912
- await fs5.writeFile(path5.join(targetDir, ".gitignore"), gitignore);
913
- await fs5.writeFile(path5.join(targetDir, ".env"), env);
1914
+ await fs7.writeFile(path7.join(targetDir, ".gitignore"), gitignore);
1915
+ await fs7.writeFile(path7.join(targetDir, ".env"), env);
914
1916
  const readme = `# ${projectName}
915
1917
 
916
1918
  MCP Server with Streamable HTTP Transport built with LeanMCP SDK
@@ -996,18 +1998,26 @@ npx @modelcontextprotocol/inspector http://localhost:3001/mcp
996
1998
 
997
1999
  MIT
998
2000
  `;
999
- await fs5.writeFile(path5.join(targetDir, "README.md"), readme);
2001
+ await fs7.writeFile(path7.join(targetDir, "README.md"), readme);
1000
2002
  spinner.succeed(`Project ${projectName} created!`);
1001
- console.log(chalk3.green("\nSuccess! Your MCP server is ready.\n"));
1002
- console.log(chalk3.cyan(`Next, navigate to your project:
2003
+ console.log(chalk6.green("\nSuccess! Your MCP server is ready.\n"));
2004
+ console.log(chalk6.cyan(`Next, navigate to your project:
1003
2005
  cd ${projectName}
1004
2006
  `));
1005
- const shouldInstall = options.allowAll ? true : await confirm({
2007
+ const isNonInteractive = options.install !== void 0 || options.allowAll;
2008
+ if (options.install === false) {
2009
+ console.log(chalk6.cyan("\nTo get started:"));
2010
+ console.log(chalk6.gray(` cd ${projectName}`));
2011
+ console.log(chalk6.gray(` npm install`));
2012
+ console.log(chalk6.gray(` npm run dev`));
2013
+ return;
2014
+ }
2015
+ const shouldInstall = isNonInteractive ? true : await confirm3({
1006
2016
  message: "Would you like to install dependencies now?",
1007
2017
  default: true
1008
2018
  });
1009
2019
  if (shouldInstall) {
1010
- const installSpinner = ora3("Installing dependencies...").start();
2020
+ const installSpinner = ora6("Installing dependencies...").start();
1011
2021
  try {
1012
2022
  await new Promise((resolve, reject) => {
1013
2023
  const npmInstall = spawn3("npm", [
@@ -1027,12 +2037,18 @@ MIT
1027
2037
  npmInstall.on("error", reject);
1028
2038
  });
1029
2039
  installSpinner.succeed("Dependencies installed successfully!");
1030
- const shouldStartDev = options.allowAll ? true : await confirm({
2040
+ if (options.install === true) {
2041
+ console.log(chalk6.cyan("\nTo start the development server:"));
2042
+ console.log(chalk6.gray(` cd ${projectName}`));
2043
+ console.log(chalk6.gray(` npm run dev`));
2044
+ return;
2045
+ }
2046
+ const shouldStartDev = options.allowAll ? true : await confirm3({
1031
2047
  message: "Would you like to start the development server?",
1032
2048
  default: true
1033
2049
  });
1034
2050
  if (shouldStartDev) {
1035
- console.log(chalk3.cyan("\nStarting development server...\n"));
2051
+ console.log(chalk6.cyan("\nStarting development server...\n"));
1036
2052
  const devServer = spawn3("npm", [
1037
2053
  "run",
1038
2054
  "dev"
@@ -1046,38 +2062,38 @@ MIT
1046
2062
  process.exit(0);
1047
2063
  });
1048
2064
  } else {
1049
- console.log(chalk3.cyan("\nTo start the development server later:"));
1050
- console.log(chalk3.gray(` cd ${projectName}`));
1051
- console.log(chalk3.gray(` npm run dev`));
2065
+ console.log(chalk6.cyan("\nTo start the development server later:"));
2066
+ console.log(chalk6.gray(` cd ${projectName}`));
2067
+ console.log(chalk6.gray(` npm run dev`));
1052
2068
  }
1053
2069
  } catch (error) {
1054
2070
  installSpinner.fail("Failed to install dependencies");
1055
- console.error(chalk3.red(error instanceof Error ? error.message : String(error)));
1056
- console.log(chalk3.cyan("\nYou can install dependencies manually:"));
1057
- console.log(chalk3.gray(` cd ${projectName}`));
1058
- console.log(chalk3.gray(` npm install`));
2071
+ console.error(chalk6.red(error instanceof Error ? error.message : String(error)));
2072
+ console.log(chalk6.cyan("\nYou can install dependencies manually:"));
2073
+ console.log(chalk6.gray(` cd ${projectName}`));
2074
+ console.log(chalk6.gray(` npm install`));
1059
2075
  }
1060
2076
  } else {
1061
- console.log(chalk3.cyan("\nTo get started:"));
1062
- console.log(chalk3.gray(` cd ${projectName}`));
1063
- console.log(chalk3.gray(` npm install`));
1064
- console.log(chalk3.gray(` npm run dev`));
2077
+ console.log(chalk6.cyan("\nTo get started:"));
2078
+ console.log(chalk6.gray(` cd ${projectName}`));
2079
+ console.log(chalk6.gray(` npm install`));
2080
+ console.log(chalk6.gray(` npm run dev`));
1065
2081
  }
1066
2082
  });
1067
2083
  program.command("add <serviceName>").description("Add a new MCP service to your project").action(async (serviceName) => {
1068
2084
  const cwd = process.cwd();
1069
- const mcpDir = path5.join(cwd, "mcp");
1070
- if (!fs5.existsSync(path5.join(cwd, "main.ts"))) {
1071
- console.error(chalk3.red("ERROR: Not a LeanMCP project (main.ts missing)."));
2085
+ const mcpDir = path7.join(cwd, "mcp");
2086
+ if (!fs7.existsSync(path7.join(cwd, "main.ts"))) {
2087
+ console.error(chalk6.red("ERROR: Not a LeanMCP project (main.ts missing)."));
1072
2088
  process.exit(1);
1073
2089
  }
1074
- const serviceDir = path5.join(mcpDir, serviceName);
1075
- const serviceFile = path5.join(serviceDir, "index.ts");
1076
- if (fs5.existsSync(serviceDir)) {
1077
- console.error(chalk3.red(`ERROR: Service ${serviceName} already exists.`));
2090
+ const serviceDir = path7.join(mcpDir, serviceName);
2091
+ const serviceFile = path7.join(serviceDir, "index.ts");
2092
+ if (fs7.existsSync(serviceDir)) {
2093
+ console.error(chalk6.red(`ERROR: Service ${serviceName} already exists.`));
1078
2094
  process.exit(1);
1079
2095
  }
1080
- await fs5.mkdirp(serviceDir);
2096
+ await fs7.mkdirp(serviceDir);
1081
2097
  const indexTs = `import { Tool, Resource, Prompt, Optional, SchemaConstraint } from "@leanmcp/core";
1082
2098
 
1083
2099
  // Input schema for greeting
@@ -1137,14 +2153,37 @@ export class ${capitalize(serviceName)}Service {
1137
2153
  }
1138
2154
  }
1139
2155
  `;
1140
- await fs5.writeFile(serviceFile, indexTs);
1141
- console.log(chalk3.green(`\\nCreated new service: ${chalk3.bold(serviceName)}`));
1142
- console.log(chalk3.gray(` File: mcp/${serviceName}/index.ts`));
1143
- console.log(chalk3.gray(` Tool: greet`));
1144
- console.log(chalk3.gray(` Prompt: welcomePrompt`));
1145
- console.log(chalk3.gray(` Resource: getStatus`));
1146
- console.log(chalk3.green(`\\nService will be automatically discovered on next server start!`));
2156
+ await fs7.writeFile(serviceFile, indexTs);
2157
+ console.log(chalk6.green(`\\nCreated new service: ${chalk6.bold(serviceName)}`));
2158
+ console.log(chalk6.gray(` File: mcp/${serviceName}/index.ts`));
2159
+ console.log(chalk6.gray(` Tool: greet`));
2160
+ console.log(chalk6.gray(` Prompt: welcomePrompt`));
2161
+ console.log(chalk6.gray(` Resource: getStatus`));
2162
+ console.log(chalk6.green(`\\nService will be automatically discovered on next server start!`));
1147
2163
  });
1148
2164
  program.command("dev").description("Start development server with UI hot-reload (builds @UIApp components)").action(devCommand);
1149
2165
  program.command("start").description("Build UI components and start production server").action(startCommand);
2166
+ program.command("login").description("Authenticate with LeanMCP cloud using an API key").option("--debug", "Enable debug logging").action(async (options) => {
2167
+ if (options.debug) {
2168
+ setDebugMode(true);
2169
+ }
2170
+ await loginCommand();
2171
+ });
2172
+ program.command("logout").description("Remove stored API key and logout from LeanMCP cloud").action(logoutCommand);
2173
+ program.command("whoami").description("Show current authentication status").action(whoamiCommand);
2174
+ program.command("deploy [folder]").description("Deploy an MCP server to LeanMCP cloud").option("-s, --subdomain <subdomain>", "Subdomain for deployment").option("-y, --yes", "Skip confirmation prompts").option("--debug", "Enable debug logging for network calls").action(async (folder, options) => {
2175
+ if (options.debug) {
2176
+ setDebugMode(true);
2177
+ setDeployDebugMode(true);
2178
+ }
2179
+ const targetFolder = folder || ".";
2180
+ await deployCommand(targetFolder, {
2181
+ subdomain: options.subdomain,
2182
+ skipConfirm: options.yes
2183
+ });
2184
+ });
2185
+ var projectsCmd = program.command("projects").description("Manage LeanMCP cloud projects");
2186
+ projectsCmd.command("list").alias("ls").description("List all your projects").action(projectsListCommand);
2187
+ projectsCmd.command("get <projectId>").description("Get details of a specific project").action(projectsGetCommand);
2188
+ projectsCmd.command("delete <projectId>").alias("rm").description("Delete a project").option("-f, --force", "Skip confirmation prompt").action((projectId, options) => projectsDeleteCommand(projectId, options));
1150
2189
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leanmcp/cli",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Command-line interface for scaffolding LeanMCP projects",
5
5
  "bin": {
6
6
  "leanmcp": "bin/leanmcp.js"
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@inquirer/prompts": "^7.0.1",
31
31
  "@vitejs/plugin-react": "^4.3.0",
32
+ "archiver": "^7.0.1",
32
33
  "autoprefixer": "^10.4.16",
33
34
  "chalk": "^5.3.0",
34
35
  "chokidar": "^4.0.0",
@@ -42,6 +43,7 @@
42
43
  "vite-plugin-singlefile": "^2.3.0"
43
44
  },
44
45
  "devDependencies": {
46
+ "@types/archiver": "^6.0.3",
45
47
  "@types/fs-extra": "^11.0.4",
46
48
  "@types/node": "^25.0.2",
47
49
  "rimraf": "^6.1.2"