@mastra/editor 0.7.22-alpha.0 → 0.7.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.7.22
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix MCP client support in the agent editor: ([#15945](https://github.com/mastra-ai/mastra/pull/15945))
8
+ - MCP client form dirty state: Save button now enables after adding/removing MCP clients
9
+ - MCP tool name matching: Both bare and namespaced tool names are matched correctly
10
+ - Auth token forwarding: Token from cookie or header is forwarded to auth-protected MCP servers
11
+ - String interpolation: Request context variables in system prompts now resolve correctly
12
+ - Updated dependencies [[`920c757`](https://github.com/mastra-ai/mastra/commit/920c75799c6bd71787d86deaf654a35af4c839ca), [`d587199`](https://github.com/mastra-ai/mastra/commit/d5871993c0371bde2b0717d6b47194755baa1443), [`1fe2533`](https://github.com/mastra-ai/mastra/commit/1fe2533c4382ca6858aac7c4b63e888c2eac6541), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8), [`4b2e4f3`](https://github.com/mastra-ai/mastra/commit/4b2e4f3bc9f5a63dcbfccfa54f9474340c3cea58)]:
13
+ - @mastra/core@1.30.0
14
+ - @mastra/memory@1.17.4
15
+
16
+ ## 0.7.22-alpha.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Fix MCP client support in the agent editor: ([#15945](https://github.com/mastra-ai/mastra/pull/15945))
21
+ - MCP client form dirty state: Save button now enables after adding/removing MCP clients
22
+ - MCP tool name matching: Both bare and namespaced tool names are matched correctly
23
+ - Auth token forwarding: Token from cookie or header is forwarded to auth-protected MCP servers
24
+ - String interpolation: Request context variables in system prompts now resolve correctly
25
+ - Updated dependencies [[`920c757`](https://github.com/mastra-ai/mastra/commit/920c75799c6bd71787d86deaf654a35af4c839ca), [`1fe2533`](https://github.com/mastra-ai/mastra/commit/1fe2533c4382ca6858aac7c4b63e888c2eac6541), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8)]:
26
+ - @mastra/core@1.30.0-alpha.1
27
+
3
28
  ## 0.7.22-alpha.0
4
29
 
5
30
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -541,7 +541,7 @@ var EditorMCPNamespace = class _EditorMCPNamespace extends CrudEditorNamespace {
541
541
  * Converts `url` from string to URL for HTTP servers.
542
542
  * Returns a plain object — callers must pass it to `new MCPClient()`.
543
543
  */
544
- static toMCPServerDefinition(serverConfig) {
544
+ static toMCPServerDefinition(serverConfig, requestInit) {
545
545
  if (serverConfig.type === "stdio") {
546
546
  return {
547
547
  command: serverConfig.command,
@@ -552,16 +552,17 @@ var EditorMCPNamespace = class _EditorMCPNamespace extends CrudEditorNamespace {
552
552
  }
553
553
  return {
554
554
  url: new URL(serverConfig.url),
555
- timeout: serverConfig.timeout
555
+ timeout: serverConfig.timeout,
556
+ ...requestInit ? { requestInit } : {}
556
557
  };
557
558
  }
558
559
  /**
559
560
  * Convert all servers in a stored MCP client to MCPClientOptions shape.
560
561
  */
561
- static toMCPClientOptions(config) {
562
+ static toMCPClientOptions(config, requestInit) {
562
563
  const servers = {};
563
564
  for (const [name, serverConfig] of Object.entries(config.servers)) {
564
- servers[name] = _EditorMCPNamespace.toMCPServerDefinition(serverConfig);
565
+ servers[name] = _EditorMCPNamespace.toMCPServerDefinition(serverConfig, requestInit);
565
566
  }
566
567
  return { id: config.id, servers };
567
568
  }
@@ -659,7 +660,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
659
660
  * they may contain SDK instances or dynamic functions that cannot be safely serialized.
660
661
  * Returns the (possibly mutated) agent.
661
662
  */
662
- async applyStoredOverrides(agent, options) {
663
+ async applyStoredOverrides(agent, options, requestContext) {
663
664
  let storedConfig = null;
664
665
  try {
665
666
  this.ensureRegistered();
@@ -697,9 +698,9 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
697
698
  const isDynamicTools = hasConditionalTools || hasConditionalMCPClients || hasConditionalIntegrationTools;
698
699
  if (isDynamicTools) {
699
700
  const originalTools = fork.listTools.bind(fork);
700
- const toolsFn = async ({ requestContext }) => {
701
- const codeTools = await originalTools({ requestContext });
702
- const ctx = requestContext.toJSON();
701
+ const toolsFn = async ({ requestContext: requestContext2 }) => {
702
+ const codeTools = await originalTools({ requestContext: requestContext2 });
703
+ const ctx = requestContext2.toJSON();
703
704
  const resolvedToolsConfig = hasConditionalTools ? this.accumulateObjectVariants(
704
705
  storedConfig.tools,
705
706
  ctx
@@ -709,7 +710,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
709
710
  storedConfig.mcpClients,
710
711
  ctx
711
712
  ) : storedConfig.mcpClients;
712
- const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig);
713
+ const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig, requestContext2);
713
714
  const resolvedIntegrationToolsConfig = hasConditionalIntegrationTools ? this.accumulateObjectVariants(
714
715
  storedConfig.integrationTools,
715
716
  ctx
@@ -724,7 +725,8 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
724
725
  storedConfig.tools
725
726
  );
726
727
  const mcpTools = await this.resolveStoredMCPTools(
727
- storedConfig.mcpClients
728
+ storedConfig.mcpClients,
729
+ requestContext
728
730
  );
729
731
  const integrationTools = await this.resolveStoredIntegrationTools(
730
732
  storedConfig.integrationTools
@@ -809,7 +811,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
809
811
  storedAgent.mcpClients,
810
812
  ctx
811
813
  ) : storedAgent.mcpClients;
812
- const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig);
814
+ const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig, requestContext);
813
815
  const resolvedIntegrationToolsConfig = hasConditionalIntegrationTools ? this.accumulateObjectVariants(
814
816
  storedAgent.integrationTools,
815
817
  ctx
@@ -1042,10 +1044,12 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1042
1044
  * When `clientToolsConfig.tools` is an empty object `{}`, all tools from the source are included.
1043
1045
  * When specified with keys, only listed tools are included with optional description overrides.
1044
1046
  */
1045
- async resolveStoredMCPTools(mcpClients) {
1047
+ async resolveStoredMCPTools(mcpClients, requestContext) {
1046
1048
  if (!mcpClients || Object.keys(mcpClients).length === 0) return {};
1047
1049
  if (!this.mastra) return {};
1048
1050
  const allTools = {};
1051
+ const authToken = requestContext?.get("mastra__authToken");
1052
+ const authRequestInit = authToken ? { headers: { Authorization: `Bearer ${authToken}` } } : void 0;
1049
1053
  let MCPClient;
1050
1054
  for (const [clientId, clientToolsConfig] of Object.entries(mcpClients)) {
1051
1055
  try {
@@ -1064,7 +1068,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1064
1068
  continue;
1065
1069
  }
1066
1070
  }
1067
- const clientOptions = EditorMCPNamespace.toMCPClientOptions(storedClient);
1071
+ const clientOptions = EditorMCPNamespace.toMCPClientOptions(storedClient, authRequestInit);
1068
1072
  const client = new MCPClient(clientOptions);
1069
1073
  tools = await client.listTools();
1070
1074
  this.logger?.debug(`[resolveStoredMCPTools] Loaded tools from stored MCP client "${clientId}"`);
@@ -1089,9 +1093,10 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1089
1093
  if (!(bareToolName in clientServers[serverName].tools)) continue;
1090
1094
  }
1091
1095
  const hasAgentFilter = agentAllowedTools && Object.keys(agentAllowedTools).length > 0;
1092
- if (hasAgentFilter && !(namespacedToolName in agentAllowedTools)) continue;
1096
+ if (hasAgentFilter && !(namespacedToolName in agentAllowedTools) && !(bareToolName in agentAllowedTools))
1097
+ continue;
1093
1098
  const serverToolConfig = serverName ? clientServers?.[serverName]?.tools?.[bareToolName] : void 0;
1094
- const description = agentAllowedTools?.[namespacedToolName]?.description ?? serverToolConfig?.description;
1099
+ const description = agentAllowedTools?.[namespacedToolName]?.description ?? agentAllowedTools?.[bareToolName]?.description ?? serverToolConfig?.description;
1095
1100
  if (description) {
1096
1101
  allTools[namespacedToolName] = { ...tool, description };
1097
1102
  } else {
package/dist/index.d.cts CHANGED
@@ -119,7 +119,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
119
119
  status?: 'draft' | 'published';
120
120
  } | {
121
121
  versionId: string;
122
- }): Promise<Agent>;
122
+ }, requestContext?: RequestContext): Promise<Agent>;
123
123
  /**
124
124
  * Detect whether a StorageConditionalField value is a conditional variant array
125
125
  * (as opposed to the plain static value T).
@@ -215,11 +215,15 @@ declare class EditorMCPNamespace extends CrudEditorNamespace<StorageCreateMCPCli
215
215
  * Converts `url` from string to URL for HTTP servers.
216
216
  * Returns a plain object — callers must pass it to `new MCPClient()`.
217
217
  */
218
- static toMCPServerDefinition(serverConfig: StorageMCPServerConfig): Record<string, unknown>;
218
+ static toMCPServerDefinition(serverConfig: StorageMCPServerConfig, requestInit?: {
219
+ headers: Record<string, string>;
220
+ }): Record<string, unknown>;
219
221
  /**
220
222
  * Convert all servers in a stored MCP client to MCPClientOptions shape.
221
223
  */
222
- static toMCPClientOptions(config: StorageResolvedMCPClientType): {
224
+ static toMCPClientOptions(config: StorageResolvedMCPClientType, requestInit?: {
225
+ headers: Record<string, string>;
226
+ }): {
223
227
  id: string;
224
228
  servers: Record<string, Record<string, unknown>>;
225
229
  };
package/dist/index.d.ts CHANGED
@@ -119,7 +119,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
119
119
  status?: 'draft' | 'published';
120
120
  } | {
121
121
  versionId: string;
122
- }): Promise<Agent>;
122
+ }, requestContext?: RequestContext): Promise<Agent>;
123
123
  /**
124
124
  * Detect whether a StorageConditionalField value is a conditional variant array
125
125
  * (as opposed to the plain static value T).
@@ -215,11 +215,15 @@ declare class EditorMCPNamespace extends CrudEditorNamespace<StorageCreateMCPCli
215
215
  * Converts `url` from string to URL for HTTP servers.
216
216
  * Returns a plain object — callers must pass it to `new MCPClient()`.
217
217
  */
218
- static toMCPServerDefinition(serverConfig: StorageMCPServerConfig): Record<string, unknown>;
218
+ static toMCPServerDefinition(serverConfig: StorageMCPServerConfig, requestInit?: {
219
+ headers: Record<string, string>;
220
+ }): Record<string, unknown>;
219
221
  /**
220
222
  * Convert all servers in a stored MCP client to MCPClientOptions shape.
221
223
  */
222
- static toMCPClientOptions(config: StorageResolvedMCPClientType): {
224
+ static toMCPClientOptions(config: StorageResolvedMCPClientType, requestInit?: {
225
+ headers: Record<string, string>;
226
+ }): {
223
227
  id: string;
224
228
  servers: Record<string, Record<string, unknown>>;
225
229
  };
package/dist/index.js CHANGED
@@ -493,7 +493,7 @@ var EditorMCPNamespace = class _EditorMCPNamespace extends CrudEditorNamespace {
493
493
  * Converts `url` from string to URL for HTTP servers.
494
494
  * Returns a plain object — callers must pass it to `new MCPClient()`.
495
495
  */
496
- static toMCPServerDefinition(serverConfig) {
496
+ static toMCPServerDefinition(serverConfig, requestInit) {
497
497
  if (serverConfig.type === "stdio") {
498
498
  return {
499
499
  command: serverConfig.command,
@@ -504,16 +504,17 @@ var EditorMCPNamespace = class _EditorMCPNamespace extends CrudEditorNamespace {
504
504
  }
505
505
  return {
506
506
  url: new URL(serverConfig.url),
507
- timeout: serverConfig.timeout
507
+ timeout: serverConfig.timeout,
508
+ ...requestInit ? { requestInit } : {}
508
509
  };
509
510
  }
510
511
  /**
511
512
  * Convert all servers in a stored MCP client to MCPClientOptions shape.
512
513
  */
513
- static toMCPClientOptions(config) {
514
+ static toMCPClientOptions(config, requestInit) {
514
515
  const servers = {};
515
516
  for (const [name, serverConfig] of Object.entries(config.servers)) {
516
- servers[name] = _EditorMCPNamespace.toMCPServerDefinition(serverConfig);
517
+ servers[name] = _EditorMCPNamespace.toMCPServerDefinition(serverConfig, requestInit);
517
518
  }
518
519
  return { id: config.id, servers };
519
520
  }
@@ -611,7 +612,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
611
612
  * they may contain SDK instances or dynamic functions that cannot be safely serialized.
612
613
  * Returns the (possibly mutated) agent.
613
614
  */
614
- async applyStoredOverrides(agent, options) {
615
+ async applyStoredOverrides(agent, options, requestContext) {
615
616
  let storedConfig = null;
616
617
  try {
617
618
  this.ensureRegistered();
@@ -649,9 +650,9 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
649
650
  const isDynamicTools = hasConditionalTools || hasConditionalMCPClients || hasConditionalIntegrationTools;
650
651
  if (isDynamicTools) {
651
652
  const originalTools = fork.listTools.bind(fork);
652
- const toolsFn = async ({ requestContext }) => {
653
- const codeTools = await originalTools({ requestContext });
654
- const ctx = requestContext.toJSON();
653
+ const toolsFn = async ({ requestContext: requestContext2 }) => {
654
+ const codeTools = await originalTools({ requestContext: requestContext2 });
655
+ const ctx = requestContext2.toJSON();
655
656
  const resolvedToolsConfig = hasConditionalTools ? this.accumulateObjectVariants(
656
657
  storedConfig.tools,
657
658
  ctx
@@ -661,7 +662,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
661
662
  storedConfig.mcpClients,
662
663
  ctx
663
664
  ) : storedConfig.mcpClients;
664
- const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig);
665
+ const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig, requestContext2);
665
666
  const resolvedIntegrationToolsConfig = hasConditionalIntegrationTools ? this.accumulateObjectVariants(
666
667
  storedConfig.integrationTools,
667
668
  ctx
@@ -676,7 +677,8 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
676
677
  storedConfig.tools
677
678
  );
678
679
  const mcpTools = await this.resolveStoredMCPTools(
679
- storedConfig.mcpClients
680
+ storedConfig.mcpClients,
681
+ requestContext
680
682
  );
681
683
  const integrationTools = await this.resolveStoredIntegrationTools(
682
684
  storedConfig.integrationTools
@@ -761,7 +763,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
761
763
  storedAgent.mcpClients,
762
764
  ctx
763
765
  ) : storedAgent.mcpClients;
764
- const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig);
766
+ const mcpTools = await this.resolveStoredMCPTools(resolvedMCPClientsConfig, requestContext);
765
767
  const resolvedIntegrationToolsConfig = hasConditionalIntegrationTools ? this.accumulateObjectVariants(
766
768
  storedAgent.integrationTools,
767
769
  ctx
@@ -994,10 +996,12 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
994
996
  * When `clientToolsConfig.tools` is an empty object `{}`, all tools from the source are included.
995
997
  * When specified with keys, only listed tools are included with optional description overrides.
996
998
  */
997
- async resolveStoredMCPTools(mcpClients) {
999
+ async resolveStoredMCPTools(mcpClients, requestContext) {
998
1000
  if (!mcpClients || Object.keys(mcpClients).length === 0) return {};
999
1001
  if (!this.mastra) return {};
1000
1002
  const allTools = {};
1003
+ const authToken = requestContext?.get("mastra__authToken");
1004
+ const authRequestInit = authToken ? { headers: { Authorization: `Bearer ${authToken}` } } : void 0;
1001
1005
  let MCPClient;
1002
1006
  for (const [clientId, clientToolsConfig] of Object.entries(mcpClients)) {
1003
1007
  try {
@@ -1016,7 +1020,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1016
1020
  continue;
1017
1021
  }
1018
1022
  }
1019
- const clientOptions = EditorMCPNamespace.toMCPClientOptions(storedClient);
1023
+ const clientOptions = EditorMCPNamespace.toMCPClientOptions(storedClient, authRequestInit);
1020
1024
  const client = new MCPClient(clientOptions);
1021
1025
  tools = await client.listTools();
1022
1026
  this.logger?.debug(`[resolveStoredMCPTools] Loaded tools from stored MCP client "${clientId}"`);
@@ -1041,9 +1045,10 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1041
1045
  if (!(bareToolName in clientServers[serverName].tools)) continue;
1042
1046
  }
1043
1047
  const hasAgentFilter = agentAllowedTools && Object.keys(agentAllowedTools).length > 0;
1044
- if (hasAgentFilter && !(namespacedToolName in agentAllowedTools)) continue;
1048
+ if (hasAgentFilter && !(namespacedToolName in agentAllowedTools) && !(bareToolName in agentAllowedTools))
1049
+ continue;
1045
1050
  const serverToolConfig = serverName ? clientServers?.[serverName]?.tools?.[bareToolName] : void 0;
1046
- const description = agentAllowedTools?.[namespacedToolName]?.description ?? serverToolConfig?.description;
1051
+ const description = agentAllowedTools?.[namespacedToolName]?.description ?? agentAllowedTools?.[bareToolName]?.description ?? serverToolConfig?.description;
1047
1052
  if (description) {
1048
1053
  allTools[namespacedToolName] = { ...tool, description };
1049
1054
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/editor",
3
- "version": "0.7.22-alpha.0",
3
+ "version": "0.7.22",
4
4
  "description": "Mastra Editor for agent management and instantiation",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -65,8 +65,8 @@
65
65
  "@arcadeai/arcadejs": "^2.3.0",
66
66
  "@composio/core": "^0.6.5",
67
67
  "@composio/mastra": "^0.6.5",
68
- "@mastra/schema-compat": "1.2.9",
69
- "@mastra/memory": "1.17.4-alpha.0"
68
+ "@mastra/memory": "1.17.4",
69
+ "@mastra/schema-compat": "1.2.9"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@hono/node-server": "^1.19.11",
@@ -75,13 +75,13 @@
75
75
  "typescript": "^6.0.3",
76
76
  "vitest": "4.1.5",
77
77
  "zod": "^3.25.76",
78
- "@internal/ai-sdk-v4": "0.0.35",
79
- "@internal/ai-v6": "0.0.35",
80
- "@mastra/core": "1.29.2-alpha.0",
81
- "@mastra/hono": "1.4.10-alpha.0",
78
+ "@internal/ai-sdk-v4": "0.0.36",
79
+ "@internal/ai-sdk-v5": "0.0.36",
80
+ "@internal/ai-v6": "0.0.36",
82
81
  "@mastra/libsql": "1.9.0",
83
- "@mastra/mcp": "1.6.0",
84
- "@internal/ai-sdk-v5": "0.0.35"
82
+ "@mastra/core": "1.30.0",
83
+ "@mastra/hono": "1.4.10",
84
+ "@mastra/mcp": "1.6.0"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@mastra/core": ">=1.7.1-0 <2.0.0-0",