@@ -147,7 +147,7 @@ export async function loadMcpServerConfigs(
147147}
148148
149149const DEFAULT_AGENT_RAW = `{
150- "name": "amazon_q_default ",
150+ "name": "q_ide_default ",
151151 "description": "Default agent configuration",
152152 "prompt": "",
153153 "mcpServers": {},
@@ -179,7 +179,7 @@ const DEFAULT_AGENT_RAW = `{
179179 "agentSpawn": [],
180180 "userPromptSubmit": []
181181 },
182- "useLegacyMcpJson": false
182+ "useLegacyMcpJson": true
183183}`
184184
185185const DEFAULT_PERSONA_RAW = `{
@@ -222,6 +222,7 @@ const DEFAULT_PERSONA_RAW = `{
222222 * - Load global first (if exists), then workspace files—workspace overrides.
223223 * - Combines functionality of loadMcpServerConfigs and loadPersonaPermissions
224224 * - Handles server configurations and permissions from the same agent file
225+ * - Supports backwards compatibility with MCP config files when useLegacyMcpJson is true
225226 */
226227export async function loadAgentConfig (
227228 workspace : Workspace ,
@@ -240,13 +241,14 @@ export async function loadAgentConfig(
240241
241242 // Create base agent config
242243 const agentConfig : AgentConfig = {
243- name : 'amazon_q_default ' ,
244+ name : 'q_ide_default ' ,
244245 description : 'Agent configuration' ,
245246 mcpServers : { } ,
246247 tools : [ ] ,
247248 allowedTools : [ ] ,
248249 toolsSettings : { } ,
249250 resources : [ ] ,
251+ useLegacyMcpJson : true , // Default to true for backwards compatibility
250252 }
251253
252254 // Normalize paths
@@ -272,6 +274,9 @@ export async function loadAgentConfig(
272274 return 0
273275 } )
274276
277+ // Track useLegacyMcpJson value - workspace takes precedence over global
278+ let useLegacyMcpJsonValue : boolean | undefined
279+
275280 // Process each path like loadMcpServerConfigs
276281 for ( const fsPath of sortedPaths ) {
277282 // 1) Skip missing files or create default global
@@ -333,6 +338,17 @@ export async function loadAgentConfig(
333338 agentConfig . description = json . description || agentConfig . description
334339 }
335340
341+ // Track useLegacyMcpJson - workspace files take precedence
342+ if ( json . useLegacyMcpJson !== undefined ) {
343+ if ( fsPath !== globalConfigPath ) {
344+ // Workspace file - always takes precedence
345+ useLegacyMcpJsonValue = json . useLegacyMcpJson
346+ } else if ( useLegacyMcpJsonValue === undefined ) {
347+ // Global file - only use if no workspace value set
348+ useLegacyMcpJsonValue = json . useLegacyMcpJson
349+ }
350+ }
351+
336352 // 4) Process permissions (tools and allowedTools)
337353 if ( Array . isArray ( json . tools ) ) {
338354 for ( const tool of json . tools ) {
@@ -460,8 +476,46 @@ export async function loadAgentConfig(
460476 }
461477 }
462478
479+ // Set final useLegacyMcpJson value - default to true if not specified anywhere
480+ agentConfig . useLegacyMcpJson = useLegacyMcpJsonValue !== undefined ? useLegacyMcpJsonValue : true
481+
482+ // Load MCP config files if useLegacyMcpJson is true
483+ if ( agentConfig . useLegacyMcpJson ) {
484+ const wsUris = workspace . getAllWorkspaceFolders ( ) ?. map ( f => f . uri ) ?? [ ]
485+ const mcpPaths = [ ...getWorkspaceMcpConfigPaths ( wsUris ) , getGlobalMcpConfigPath ( workspace . fs . getUserHomeDir ( ) ) ]
486+
487+ const mcpResult = await loadMcpServerConfigs ( workspace , logging , mcpPaths )
488+
489+ // MCP configs have precedence over agent configs
490+ // Merge MCP servers into the result, overriding any from agent config
491+ for ( const [ sanitizedName , mcpConfig ] of mcpResult . servers ) {
492+ const originalName = mcpResult . serverNameMapping . get ( sanitizedName )
493+ if ( originalName ) {
494+ servers . set ( sanitizedName , mcpConfig )
495+ serverNameMapping . set ( sanitizedName , originalName )
496+
497+ // Add MCP server tools to agent config for permission management
498+ const serverPrefix = `@${ originalName } `
499+ if ( ! agentConfig . tools . includes ( serverPrefix ) ) {
500+ agentConfig . tools . push ( serverPrefix )
501+ }
502+
503+ logging . info ( `Loaded MCP server '${ originalName } ' from legacy MCP config` )
504+ }
505+ }
506+
507+ // Merge MCP config errors
508+ for ( const [ key , error ] of mcpResult . errors ) {
509+ configErrors . set ( `mcp_${ key } ` , error )
510+ }
511+
512+ logging . info ( `Loaded ${ mcpResult . servers . size } servers from legacy MCP configs` )
513+ }
514+
463515 // Return the agent config, servers, server name mapping, and errors
464- logging . info ( `Successfully processed ${ uniquePaths . length } agent config files` )
516+ logging . info (
517+ `Successfully processed ${ uniquePaths . length } agent config files and ${ agentConfig . useLegacyMcpJson ? 'legacy MCP configs' : 'no legacy MCP configs' } `
518+ )
465519 return {
466520 servers,
467521 serverNameMapping,
@@ -631,7 +685,7 @@ export function convertPersonaToAgent(
631685 featureAgent : Agent
632686) : AgentConfig {
633687 const agent : AgentConfig = {
634- name : 'amazon_q_default ' ,
688+ name : 'q_ide_default ' ,
635689 description : 'Default agent configuration' ,
636690 prompt : '' ,
637691 mcpServers : { } ,
@@ -644,7 +698,7 @@ export function convertPersonaToAgent(
644698 agentSpawn : [ ] ,
645699 userPromptSubmit : [ ] ,
646700 } ,
647- useLegacyMcpJson : false ,
701+ useLegacyMcpJson : true ,
648702 }
649703
650704 // Include all servers from MCP config
@@ -969,7 +1023,7 @@ export async function saveServerSpecificAgentConfig(
9691023 } catch {
9701024 // If file doesn't exist, create minimal config
9711025 existingConfig = {
972- name : 'amazon_q_default ' ,
1026+ name : 'q_ide_default ' ,
9731027 description : 'Agent configuration' ,
9741028 mcpServers : { } ,
9751029 tools : [ ] ,
@@ -995,11 +1049,12 @@ export async function saveServerSpecificAgentConfig(
9951049 } else {
9961050 // Update or add server
9971051 existingConfig . mcpServers [ serverName ] = serverConfig
998- // Add new server tools
999- existingConfig . tools . push ( ...serverTools )
1000- existingConfig . allowedTools . push ( ...serverAllowedTools )
10011052 }
10021053
1054+ // Add new server tools
1055+ existingConfig . tools . push ( ...serverTools )
1056+ existingConfig . allowedTools . push ( ...serverAllowedTools )
1057+
10031058 await workspace . fs . writeFile ( configPath , JSON . stringify ( existingConfig , null , 2 ) )
10041059 logging . info ( `Saved server-specific agent config for ${ serverName } to ${ configPath } ` )
10051060 } catch ( err : any ) {
@@ -1025,9 +1080,9 @@ export async function migrateAgentConfigToCLIFormat(
10251080
10261081 let updated = false
10271082
1028- // Rename default-agent to amazon_q_default
1029- if ( config . name === 'default-agent ') {
1030- config . name = 'amazon_q_default '
1083+ // Rename default-agent to q_ide_default
1084+ if ( config . name !== 'q_ide_default ') {
1085+ config . name = 'q_ide_default '
10311086 updated = true
10321087 }
10331088
@@ -1041,7 +1096,7 @@ export async function migrateAgentConfigToCLIFormat(
10411096 updated = true
10421097 }
10431098 if ( ! config . hasOwnProperty ( 'useLegacyMcpJson' ) ) {
1044- config . useLegacyMcpJson = false
1099+ config . useLegacyMcpJson = true
10451100 updated = true
10461101 }
10471102
0 commit comments