create-mastra 0.0.0-mastra-3123-mcp-server-20250419180157 → 0.0.0-mastra-2452-core-tracing-sentry-20250507205331
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 +0 -1
- package/dist/index.js +92 -14
- package/dist/index.js.map +1 -1
- package/dist/templates/dev.entry.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1030,20 +1030,41 @@ async function writeMergedConfig(configPath) {
|
|
|
1030
1030
|
});
|
|
1031
1031
|
}
|
|
1032
1032
|
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1033
|
+
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
1033
1034
|
async function installMastraDocsMCPServer({
|
|
1034
1035
|
editor,
|
|
1035
1036
|
directory
|
|
1036
1037
|
}) {
|
|
1037
|
-
if (editor === `cursor`)
|
|
1038
|
-
|
|
1039
|
-
|
|
1038
|
+
if (editor === `cursor`) {
|
|
1039
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
|
|
1040
|
+
}
|
|
1041
|
+
if (editor === `cursor-global`) {
|
|
1042
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1043
|
+
if (alreadyInstalled) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
await writeMergedConfig(cursorGlobalMCPConfigPath);
|
|
1047
|
+
}
|
|
1048
|
+
if (editor === `windsurf`) {
|
|
1049
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1050
|
+
if (alreadyInstalled) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
await writeMergedConfig(windsurfGlobalMCPConfigPath);
|
|
1054
|
+
}
|
|
1040
1055
|
}
|
|
1041
|
-
async function
|
|
1042
|
-
|
|
1056
|
+
async function globalMCPIsAlreadyInstalled(editor) {
|
|
1057
|
+
let configPath = ``;
|
|
1058
|
+
if (editor === "windsurf") {
|
|
1059
|
+
configPath = windsurfGlobalMCPConfigPath;
|
|
1060
|
+
} else if (editor === "cursor-global") {
|
|
1061
|
+
configPath = cursorGlobalMCPConfigPath;
|
|
1062
|
+
}
|
|
1063
|
+
if (!configPath || !existsSync(configPath)) {
|
|
1043
1064
|
return false;
|
|
1044
1065
|
}
|
|
1045
1066
|
try {
|
|
1046
|
-
const configContents = await readJSON(
|
|
1067
|
+
const configContents = await readJSON(configPath);
|
|
1047
1068
|
if (!configContents?.mcpServers) return false;
|
|
1048
1069
|
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
1049
1070
|
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
@@ -1219,6 +1240,8 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
|
1219
1240
|
const content = `
|
|
1220
1241
|
${providerImport}
|
|
1221
1242
|
import { Agent } from '@mastra/core/agent';
|
|
1243
|
+
import { Memory } from '@mastra/memory';
|
|
1244
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
1222
1245
|
${addExampleTool ? `import { weatherTool } from '../tools';` : ""}
|
|
1223
1246
|
|
|
1224
1247
|
export const weatherAgent = new Agent({
|
|
@@ -1226,6 +1249,18 @@ export const weatherAgent = new Agent({
|
|
|
1226
1249
|
instructions: \`${instructions}\`,
|
|
1227
1250
|
model: ${modelItem},
|
|
1228
1251
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
1252
|
+
memory: new Memory({
|
|
1253
|
+
storage: new LibSQLStore({
|
|
1254
|
+
url: "file:../mastra.db", // path is relative to the .mastra/output directory
|
|
1255
|
+
}),
|
|
1256
|
+
options: {
|
|
1257
|
+
lastMessages: 10,
|
|
1258
|
+
semanticRecall: false,
|
|
1259
|
+
threads: {
|
|
1260
|
+
generateTitle: false
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
})
|
|
1229
1264
|
});
|
|
1230
1265
|
`;
|
|
1231
1266
|
const formattedContent = await prettier.format(content, {
|
|
@@ -1480,11 +1515,16 @@ export const mastra = new Mastra()
|
|
|
1480
1515
|
`
|
|
1481
1516
|
import { Mastra } from '@mastra/core/mastra';
|
|
1482
1517
|
import { createLogger } from '@mastra/core/logger';
|
|
1518
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
1483
1519
|
${addWorkflow ? `import { weatherWorkflow } from './workflows';` : ""}
|
|
1484
1520
|
${addAgent ? `import { weatherAgent } from './agents';` : ""}
|
|
1485
1521
|
|
|
1486
1522
|
export const mastra = new Mastra({
|
|
1487
1523
|
${filteredExports.join("\n ")}
|
|
1524
|
+
storage: new LibSQLStore({
|
|
1525
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
1526
|
+
url: ":memory:",
|
|
1527
|
+
}),
|
|
1488
1528
|
logger: createLogger({
|
|
1489
1529
|
name: 'Mastra',
|
|
1490
1530
|
level: 'info',
|
|
@@ -1597,12 +1637,22 @@ var interactivePrompt = async () => {
|
|
|
1597
1637
|
initialValue: false
|
|
1598
1638
|
}),
|
|
1599
1639
|
configureEditorWithDocsMCP: async () => {
|
|
1600
|
-
const windsurfIsAlreadyInstalled = await
|
|
1640
|
+
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
1641
|
+
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
1601
1642
|
const editor = await le({
|
|
1602
1643
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
1603
1644
|
options: [
|
|
1604
1645
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
1605
|
-
{
|
|
1646
|
+
{
|
|
1647
|
+
value: "cursor",
|
|
1648
|
+
label: "Cursor (project only)",
|
|
1649
|
+
hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
|
|
1650
|
+
},
|
|
1651
|
+
{
|
|
1652
|
+
value: "cursor-global",
|
|
1653
|
+
label: "Cursor (global, all projects)",
|
|
1654
|
+
hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
|
|
1655
|
+
},
|
|
1606
1656
|
{
|
|
1607
1657
|
value: "windsurf",
|
|
1608
1658
|
label: "Windsurf",
|
|
@@ -1623,6 +1673,18 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
|
|
|
1623
1673
|
`
|
|
1624
1674
|
);
|
|
1625
1675
|
}
|
|
1676
|
+
if (editor === `cursor-global`) {
|
|
1677
|
+
const confirm2 = await le({
|
|
1678
|
+
message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
|
|
1679
|
+
options: [
|
|
1680
|
+
{ value: "yes", label: "Yes, I understand" },
|
|
1681
|
+
{ value: "skip", label: "No, skip for now" }
|
|
1682
|
+
]
|
|
1683
|
+
});
|
|
1684
|
+
if (confirm2 !== `yes`) {
|
|
1685
|
+
return void 0;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1626
1688
|
if (editor === `windsurf`) {
|
|
1627
1689
|
const confirm2 = await le({
|
|
1628
1690
|
message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
|
|
@@ -1684,6 +1746,15 @@ var init = async ({
|
|
|
1684
1746
|
(component) => writeCodeSample(dirPath, component, llmProvider, components)
|
|
1685
1747
|
)
|
|
1686
1748
|
]);
|
|
1749
|
+
const depService = new DepsService();
|
|
1750
|
+
const needsLibsql = await depService.checkDependencies(["@mastra/libsql"]) !== `ok`;
|
|
1751
|
+
if (needsLibsql) {
|
|
1752
|
+
await depService.installPackages(["@mastra/libsql"]);
|
|
1753
|
+
}
|
|
1754
|
+
const needsMemory = components.includes(`agents`) && await depService.checkDependencies(["@mastra/memory"]) !== `ok`;
|
|
1755
|
+
if (needsMemory) {
|
|
1756
|
+
await depService.installPackages(["@mastra/memory"]);
|
|
1757
|
+
}
|
|
1687
1758
|
}
|
|
1688
1759
|
const key = await getAPIKey(llmProvider || "openai");
|
|
1689
1760
|
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
@@ -1823,9 +1894,11 @@ var createMastraProject = async ({
|
|
|
1823
1894
|
const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
|
|
1824
1895
|
await installMastraDependency(pm, "mastra", versionTag, true, timeout);
|
|
1825
1896
|
s2.stop("mastra installed");
|
|
1826
|
-
s2.start("Installing
|
|
1897
|
+
s2.start("Installing dependencies");
|
|
1827
1898
|
await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
|
|
1828
|
-
|
|
1899
|
+
await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
|
|
1900
|
+
await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
|
|
1901
|
+
s2.stop("Dependencies installed");
|
|
1829
1902
|
s2.start("Adding .gitignore");
|
|
1830
1903
|
await exec3(`echo output.txt >> .gitignore`);
|
|
1831
1904
|
await exec3(`echo node_modules >> .gitignore`);
|
|
@@ -1846,8 +1919,8 @@ var create = async (args2) => {
|
|
|
1846
1919
|
createVersionTag: args2?.createVersionTag,
|
|
1847
1920
|
timeout: args2?.timeout
|
|
1848
1921
|
});
|
|
1849
|
-
const directory = "/
|
|
1850
|
-
if (
|
|
1922
|
+
const directory = args2.directory || "src/";
|
|
1923
|
+
if (args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0) {
|
|
1851
1924
|
const result = await interactivePrompt();
|
|
1852
1925
|
await init({
|
|
1853
1926
|
...result,
|
|
@@ -1913,7 +1986,11 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
|
|
|
1913
1986
|
} catch {
|
|
1914
1987
|
}
|
|
1915
1988
|
});
|
|
1916
|
-
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1989
|
+
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1990
|
+
"-p, --project-name <string>",
|
|
1991
|
+
"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) => {
|
|
1993
|
+
const projectName = projectNameArg || args.projectName;
|
|
1917
1994
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|
|
1918
1995
|
if (args.default) {
|
|
1919
1996
|
await create({
|
|
@@ -1932,7 +2009,8 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
|
|
|
1932
2009
|
llmApiKey: args["llm-api-key"],
|
|
1933
2010
|
createVersionTag,
|
|
1934
2011
|
timeout,
|
|
1935
|
-
projectName
|
|
2012
|
+
projectName,
|
|
2013
|
+
directory: args.dir
|
|
1936
2014
|
});
|
|
1937
2015
|
});
|
|
1938
2016
|
program.parse(process.argv);
|