create-mastra 0.3.2-alpha.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1001,29 +1001,55 @@ function getPackageManagerInstallCommand(pm) {
1001
1001
  }
1002
1002
  }
1003
1003
  var args = ["-y", "@mastra/mcp-docs-server@latest"];
1004
- var mcpConfig = {
1005
- mcpServers: {
1006
- mastra: process.platform === `win32` ? {
1007
- command: "cmd",
1008
- args: ["/c", "npx", ...args]
1009
- } : {
1010
- command: "npx",
1011
- args
1012
- }
1004
+ var createMcpConfig = (editor) => {
1005
+ if (editor === "vscode") {
1006
+ return {
1007
+ servers: {
1008
+ mastra: process.platform === `win32` ? {
1009
+ command: "cmd",
1010
+ args: ["/c", "npx", ...args],
1011
+ type: "stdio"
1012
+ } : {
1013
+ command: "npx",
1014
+ args,
1015
+ type: "stdio"
1016
+ }
1017
+ }
1018
+ };
1013
1019
  }
1020
+ return {
1021
+ mcpServers: {
1022
+ mastra: process.platform === `win32` ? {
1023
+ command: "cmd",
1024
+ args: ["/c", "npx", ...args]
1025
+ } : {
1026
+ command: "npx",
1027
+ args
1028
+ }
1029
+ }
1030
+ };
1014
1031
  };
1015
- function makeConfig(original) {
1032
+ function makeConfig(original, editor) {
1033
+ if (editor === "vscode") {
1034
+ return {
1035
+ ...original,
1036
+ servers: {
1037
+ ...original?.servers || {},
1038
+ ...createMcpConfig(editor).servers
1039
+ }
1040
+ };
1041
+ }
1016
1042
  return {
1017
1043
  ...original,
1018
1044
  mcpServers: {
1019
1045
  ...original?.mcpServers || {},
1020
- ...mcpConfig.mcpServers
1046
+ ...createMcpConfig(editor).mcpServers
1021
1047
  }
1022
1048
  };
1023
1049
  }
1024
- async function writeMergedConfig(configPath) {
1050
+ async function writeMergedConfig(configPath, editor) {
1025
1051
  const configExists = existsSync(configPath);
1026
- const config = makeConfig(configExists ? await readJSON(configPath) : {});
1052
+ const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor);
1027
1053
  await ensureFile(configPath);
1028
1054
  await writeJSON(configPath, config, {
1029
1055
  spaces: 2
@@ -1031,26 +1057,27 @@ async function writeMergedConfig(configPath) {
1031
1057
  }
1032
1058
  var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1033
1059
  var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
1034
- async function installMastraDocsMCPServer({
1035
- editor,
1036
- directory
1037
- }) {
1060
+ path.join(process.cwd(), ".vscode", "mcp.json");
1061
+ async function installMastraDocsMCPServer({ editor, directory }) {
1038
1062
  if (editor === `cursor`) {
1039
- await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
1063
+ await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
1064
+ }
1065
+ if (editor === `vscode`) {
1066
+ await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
1040
1067
  }
1041
1068
  if (editor === `cursor-global`) {
1042
1069
  const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
1043
1070
  if (alreadyInstalled) {
1044
1071
  return;
1045
1072
  }
1046
- await writeMergedConfig(cursorGlobalMCPConfigPath);
1073
+ await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global");
1047
1074
  }
1048
1075
  if (editor === `windsurf`) {
1049
1076
  const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
1050
1077
  if (alreadyInstalled) {
1051
1078
  return;
1052
1079
  }
1053
- await writeMergedConfig(windsurfGlobalMCPConfigPath);
1080
+ await writeMergedConfig(windsurfGlobalMCPConfigPath, editor);
1054
1081
  }
1055
1082
  }
1056
1083
  async function globalMCPIsAlreadyInstalled(editor) {
@@ -1935,7 +1962,8 @@ var create = async (args2) => {
1935
1962
  components,
1936
1963
  llmProvider,
1937
1964
  addExample,
1938
- llmApiKey
1965
+ llmApiKey,
1966
+ configureEditorWithDocsMCP: args2.mcpServer
1939
1967
  });
1940
1968
  postCreate({ projectName });
1941
1969
  };
@@ -1989,16 +2017,17 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
1989
2017
  program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
1990
2018
  "-p, --project-name <string>",
1991
2019
  "Project name that will be used in package.json and as the project directory name."
1992
- ).option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").action(async (projectNameArg, args) => {
2020
+ ).option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").option("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").action(async (projectNameArg, args) => {
1993
2021
  const projectName = projectNameArg || args.projectName;
1994
2022
  const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
1995
2023
  if (args.default) {
1996
2024
  await create({
1997
2025
  components: ["agents", "tools", "workflows"],
1998
2026
  llmProvider: "openai",
1999
- addExample: false,
2027
+ addExample: true,
2000
2028
  createVersionTag,
2001
- timeout
2029
+ timeout,
2030
+ mcpServer: args.mcp
2002
2031
  });
2003
2032
  return;
2004
2033
  }
@@ -2010,7 +2039,8 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
2010
2039
  createVersionTag,
2011
2040
  timeout,
2012
2041
  projectName,
2013
- directory: args.dir
2042
+ directory: args.dir,
2043
+ mcpServer: args.mcp
2014
2044
  });
2015
2045
  });
2016
2046
  program.parse(process.argv);