Skip to content

Commit 698d06c

Browse files
authored
fix(amazonq): update to the agent config format to bring parity with Q CLI (aws#2202)
1 parent cf585cd commit 698d06c

File tree

7 files changed

+138
-73
lines changed

7 files changed

+138
-73
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpEventHandler.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ describe('McpEventHandler error handling', () => {
5959
getConnectionMetadata: sinon.stub().returns({}),
6060
},
6161
runtime: {
62-
serverInfo: {
63-
version: '1.0.0',
64-
},
62+
serverInfo: {},
6563
},
6664
}
6765

@@ -100,7 +98,6 @@ describe('McpEventHandler error handling', () => {
10098
errors: mockErrors,
10199
agentConfig: {
102100
name: 'test-agent',
103-
version: '1.0.0',
104101
description: 'Test agent',
105102
mcpServers: {},
106103
tools: [],
@@ -157,7 +154,6 @@ describe('McpEventHandler error handling', () => {
157154
errors: new Map([['errorServer', 'Missing command error']]),
158155
agentConfig: {
159156
name: 'test-agent',
160-
version: '1.0.0',
161157
description: 'Test agent',
162158
mcpServers: { errorServer: { command: '' } },
163159
tools: ['@errorServer'],
@@ -215,7 +211,6 @@ describe('McpEventHandler error handling', () => {
215211
errors: new Map(),
216212
agentConfig: {
217213
name: 'test-agent',
218-
version: '1.0.0',
219214
description: 'Test agent',
220215
mcpServers: {},
221216
tools: [],
@@ -259,7 +254,6 @@ describe('McpEventHandler error handling', () => {
259254
errors: new Map(),
260255
agentConfig: {
261256
name: 'test-agent',
262-
version: '1.0.0',
263257
description: 'Test agent',
264258
mcpServers: {},
265259
tools: [],
@@ -292,7 +286,6 @@ describe('McpEventHandler error handling', () => {
292286
errors: mockErrors,
293287
agentConfig: {
294288
name: 'test-agent',
295-
version: '1.0.0',
296289
description: 'Test agent',
297290
mcpServers: {},
298291
tools: [],
@@ -326,7 +319,6 @@ describe('McpEventHandler error handling', () => {
326319
errors: new Map(),
327320
agentConfig: {
328321
name: 'test-agent',
329-
version: '1.0.0',
330322
description: 'Test agent',
331323
mcpServers: {},
332324
tools: [],

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpManager.test.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function stubAgentConfig(): sinon.SinonStub {
3737
errors: new Map(),
3838
agentConfig: {
3939
name: 'test-agent',
40-
version: '1.0.0',
4140
description: 'Test agent',
4241
mcpServers: {},
4342
tools: [],
@@ -157,7 +156,6 @@ describe('callTool()', () => {
157156
errors: new Map(),
158157
agentConfig: {
159158
name: 'test-agent',
160-
version: '1.0.0',
161159
description: 'Test agent',
162160
mcpServers: { s1: disabledCfg },
163161
tools: ['@s1'],
@@ -184,7 +182,6 @@ describe('callTool()', () => {
184182
errors: new Map(),
185183
agentConfig: {
186184
name: 'test-agent',
187-
version: '1.0.0',
188185
description: 'Test agent',
189186
mcpServers: { s1: enabledCfg },
190187
tools: ['@s1'],
@@ -210,7 +207,6 @@ describe('callTool()', () => {
210207
errors: new Map(),
211208
agentConfig: {
212209
name: 'test-agent',
213-
version: '1.0.0',
214210
description: 'Test agent',
215211
mcpServers: { s1: timeoutCfg },
216212
tools: ['@s1'],
@@ -279,7 +275,6 @@ describe('addServer()', () => {
279275
errors: new Map(),
280276
agentConfig: {
281277
name: 'test-agent',
282-
version: '1.0.0',
283278
description: 'Test agent',
284279
mcpServers: {},
285280
tools: [],
@@ -353,7 +348,6 @@ describe('removeServer()', () => {
353348
;(mgr as any).serverNameMapping.set('x', 'x')
354349
;(mgr as any).agentConfig = {
355350
name: 'test-agent',
356-
version: '1.0.0',
357351
description: 'Test agent',
358352
mcpServers: { x: {} },
359353
tools: ['@x'],
@@ -383,7 +377,6 @@ describe('removeServer()', () => {
383377
;(mgr as any).serverNameMapping.set('x', 'x')
384378
;(mgr as any).agentConfig = {
385379
name: 'test-agent',
386-
version: '1.0.0',
387380
description: 'Test agent',
388381
mcpServers: { x: {} },
389382
tools: ['@x'],
@@ -501,7 +494,6 @@ describe('updateServer()', () => {
501494
errors: new Map(),
502495
agentConfig: {
503496
name: 'test-agent',
504-
version: '1.0.0',
505497
description: 'Test agent',
506498
mcpServers: { u1: oldCfg },
507499
tools: ['@u1'],
@@ -544,7 +536,6 @@ describe('updateServer()', () => {
544536
errors: new Map(),
545537
agentConfig: {
546538
name: 'test-agent',
547-
version: '1.0.0',
548539
description: 'Test agent',
549540
mcpServers: { srv: oldCfg },
550541
tools: ['@srv'],
@@ -598,7 +589,6 @@ describe('requiresApproval()', () => {
598589
errors: new Map(),
599590
agentConfig: {
600591
name: 'test-agent',
601-
version: '1.0.0',
602592
description: 'Test agent',
603593
mcpServers: { s: cfg },
604594
tools: ['@s'],
@@ -639,7 +629,6 @@ describe('getAllServerConfigs()', () => {
639629
errors: new Map(),
640630
agentConfig: {
641631
name: 'test-agent',
642-
version: '1.0.0',
643632
description: 'Test agent',
644633
mcpServers: { srv: cfg },
645634
tools: ['@srv'],
@@ -687,7 +676,6 @@ describe('getServerState()', () => {
687676
errors: new Map(),
688677
agentConfig: {
689678
name: 'test-agent',
690-
version: '1.0.0',
691679
description: 'Test agent',
692680
mcpServers: { srv: cfg },
693681
tools: ['@srv'],
@@ -729,7 +717,6 @@ describe('getAllServerStates()', () => {
729717
errors: new Map(),
730718
agentConfig: {
731719
name: 'test-agent',
732-
version: '1.0.0',
733720
description: 'Test agent',
734721
mcpServers: { srv: cfg },
735722
tools: ['@srv'],
@@ -779,7 +766,6 @@ describe('getEnabledTools()', () => {
779766
errors: new Map(),
780767
agentConfig: {
781768
name: 'test-agent',
782-
version: '1.0.0',
783769
description: 'Test agent',
784770
mcpServers: { srv: cfg },
785771
tools: ['@srv'],
@@ -797,7 +783,6 @@ describe('getEnabledTools()', () => {
797783
if (!(mgr as any).agentConfig) {
798784
;(mgr as any).agentConfig = {
799785
name: 'test-agent',
800-
version: '1.0.0',
801786
description: 'Test agent',
802787
mcpServers: {},
803788
tools: [],
@@ -828,7 +813,6 @@ describe('getEnabledTools()', () => {
828813
errors: new Map(),
829814
agentConfig: {
830815
name: 'test-agent',
831-
version: '1.0.0',
832816
description: 'Test agent',
833817
mcpServers: { srv: disabledCfg },
834818
tools: ['@srv'],
@@ -866,7 +850,6 @@ describe('getAllToolsWithPermissions()', () => {
866850
errors: new Map(),
867851
agentConfig: {
868852
name: 'test-agent',
869-
version: '1.0.0',
870853
description: 'Test agent',
871854
mcpServers: { s1: cfg },
872855
tools: ['@s1'],
@@ -931,7 +914,6 @@ describe('isServerDisabled()', () => {
931914
errors: new Map(),
932915
agentConfig: {
933916
name: 'test-agent',
934-
version: '1.0.0',
935917
description: 'Test agent',
936918
mcpServers: { srv: disabledCfg },
937919
tools: ['@srv'],
@@ -962,7 +944,6 @@ describe('isServerDisabled()', () => {
962944
errors: new Map(),
963945
agentConfig: {
964946
name: 'test-agent',
965-
version: '1.0.0',
966947
description: 'Test agent',
967948
mcpServers: { srv: enabledCfg },
968949
tools: ['@srv'],
@@ -992,7 +973,6 @@ describe('isServerDisabled()', () => {
992973
errors: new Map(),
993974
agentConfig: {
994975
name: 'test-agent',
995-
version: '1.0.0',
996976
description: 'Test agent',
997977
mcpServers: { srv: undefinedCfg },
998978
tools: ['@srv'],
@@ -1091,7 +1071,6 @@ describe('updateServerPermission()', () => {
10911071
errors: new Map(),
10921072
agentConfig: {
10931073
name: 'test-agent',
1094-
version: '1.0.0',
10951074
description: 'Test agent',
10961075
mcpServers: { srv: cfg },
10971076
tools: ['@srv'],
@@ -1156,7 +1135,6 @@ describe('reinitializeMcpServers()', () => {
11561135
errors: new Map(),
11571136
agentConfig: {
11581137
name: 'test-agent',
1159-
version: '1.0.0',
11601138
description: 'Test agent',
11611139
mcpServers: { srvA: cfg1 },
11621140
tools: ['@srvA'],
@@ -1173,7 +1151,6 @@ describe('reinitializeMcpServers()', () => {
11731151
errors: new Map(),
11741152
agentConfig: {
11751153
name: 'test-agent',
1176-
version: '1.0.0',
11771154
description: 'Test agent',
11781155
mcpServers: { srvB: cfg2 },
11791156
tools: ['@srvB'],
@@ -1279,7 +1256,6 @@ describe('concurrent server initialization', () => {
12791256
const serversMap = new Map(Object.entries(serverConfigs))
12801257
const agentConfig = {
12811258
name: 'test-agent',
1282-
version: '1.0.0',
12831259
description: 'Test agent',
12841260
mcpServers: Object.fromEntries(Object.entries(serverConfigs)),
12851261
tools: Object.keys(serverConfigs).map(name => `@${name}`),
@@ -1424,7 +1400,6 @@ describe('McpManager error handling', () => {
14241400
errors: mockErrors,
14251401
agentConfig: {
14261402
name: 'test-agent',
1427-
version: '1.0.0',
14281403
description: 'Test agent',
14291404
mcpServers: {},
14301405
tools: [],
@@ -1452,7 +1427,6 @@ describe('McpManager error handling', () => {
14521427
errors: new Map(),
14531428
agentConfig: {
14541429
name: 'test-agent',
1455-
version: '1.0.0',
14561430
description: 'Test agent',
14571431
mcpServers: {},
14581432
tools: [],
@@ -1478,7 +1452,6 @@ describe('McpManager error handling', () => {
14781452
errors: new Map(),
14791453
agentConfig: {
14801454
name: 'test-agent',
1481-
version: '1.0.0',
14821455
description: 'Test agent',
14831456
mcpServers: {},
14841457
tools: [],
@@ -1521,7 +1494,6 @@ describe('McpManager error handling', () => {
15211494
errors: new Map([['file1.json', 'Initial error']]),
15221495
agentConfig: {
15231496
name: 'test-agent',
1524-
version: '1.0.0',
15251497
description: 'Test agent',
15261498
mcpServers: {},
15271499
tools: [],
@@ -1539,7 +1511,6 @@ describe('McpManager error handling', () => {
15391511
errors: new Map(),
15401512
agentConfig: {
15411513
name: 'test-agent',
1542-
version: '1.0.0',
15431514
description: 'Test agent',
15441515
mcpServers: {},
15451516
tools: [],

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,7 @@ export class McpManager {
944944
this.mcpServers.clear()
945945
this.mcpServerStates.clear()
946946
this.agentConfig = {
947-
name: 'default-agent',
948-
version: '1.0.0',
947+
name: 'amazon_q_default',
949948
description: 'Agent configuration',
950949
mcpServers: {},
951950
tools: [],

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpTypes.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,26 @@ export interface MCPServerPermission {
4646

4747
export interface AgentConfig {
4848
name: string // Required: Agent name
49-
version: string // Required: Agent version (semver)
5049
description: string // Required: Agent description
50+
prompt?: string // Optional: High-level context for the agent
5151
model?: string // Optional: Model that backs the agent
5252
tags?: string[] // Optional: Tags for categorization
5353
inputSchema?: any // Optional: Schema for agent inputs
5454
mcpServers: Record<string, MCPServerConfig> // Map of server name to server config
5555
tools: string[] // List of enabled tools
56+
toolAliases?: Record<string, string> // Tool name remapping
5657
allowedTools: string[] // List of tools that don't require approval
5758
toolsSettings?: Record<string, any> // Tool-specific settings
58-
includedFiles?: string[] // Files to include in context
59-
createHooks?: string[] // Hooks to run at conversation start
60-
promptHooks?: string[] // Hooks to run per prompt
61-
resources?: string[] // Resources for the agent (prompts, files, etc.)
59+
resources?: string[] // Resources for the agent (file:// paths)
60+
hooks?: {
61+
agentSpawn?: Array<{ command: string }>
62+
userPromptSubmit?: Array<{ command: string }>
63+
} // Commands run at specific trigger points
64+
useLegacyMcpJson?: boolean // Whether to include legacy MCP configuration
65+
// Legacy fields for backward compatibility
66+
includedFiles?: string[] // Deprecated: use resources instead
67+
createHooks?: string[] // Deprecated: use hooks.agentSpawn instead
68+
promptHooks?: string[] // Deprecated: use hooks.userPromptSubmit instead
6269
}
6370

6471
export interface PersonaConfig {
@@ -71,20 +78,24 @@ export class AgentModel {
7178

7279
static fromJson(doc: any): AgentModel {
7380
const cfg: AgentConfig = {
74-
name: doc?.['name'] || 'default-agent',
75-
version: doc?.['version'] || '1.0.0',
81+
name: doc?.['name'] || 'amazon_q_default',
7682
description: doc?.['description'] || 'Default agent configuration',
83+
prompt: doc?.['prompt'],
7784
model: doc?.['model'],
7885
tags: Array.isArray(doc?.['tags']) ? doc['tags'] : undefined,
7986
inputSchema: doc?.['inputSchema'],
8087
mcpServers: typeof doc?.['mcpServers'] === 'object' ? doc['mcpServers'] : {},
8188
tools: Array.isArray(doc?.['tools']) ? doc['tools'] : [],
89+
toolAliases: typeof doc?.['toolAliases'] === 'object' ? doc['toolAliases'] : {},
8290
allowedTools: Array.isArray(doc?.['allowedTools']) ? doc['allowedTools'] : [],
8391
toolsSettings: typeof doc?.['toolsSettings'] === 'object' ? doc['toolsSettings'] : {},
92+
resources: Array.isArray(doc?.['resources']) ? doc['resources'] : [],
93+
hooks: typeof doc?.['hooks'] === 'object' ? doc['hooks'] : undefined,
94+
useLegacyMcpJson: doc?.['useLegacyMcpJson'],
95+
// Legacy fields
8496
includedFiles: Array.isArray(doc?.['includedFiles']) ? doc['includedFiles'] : [],
8597
createHooks: Array.isArray(doc?.['createHooks']) ? doc['createHooks'] : [],
8698
promptHooks: Array.isArray(doc?.['promptHooks']) ? doc['promptHooks'] : [],
87-
resources: Array.isArray(doc?.['resources']) ? doc['resources'] : [],
8899
}
89100
return new AgentModel(cfg)
90101
}

0 commit comments

Comments
 (0)