Skip to content

Commit 81e3202

Browse files
committed
fix: use type-safe cast in vended cdk.ts for MCP fields
The vended CDK project reads gateway fields from agentcore.json but the published @aws/agentcore-cdk type doesn't include them yet. Use 'as any' cast for forward-compatibility.
1 parent f479459 commit 81e3202

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,17 @@ async function main() {
7373
const spec = await configIO.readProjectSpec();
7474
const targets = await configIO.readAWSDeploymentTargets();
7575
76-
// Extract MCP configuration from project spec
77-
const mcpSpec = spec.agentCoreGateways?.length
76+
// Extract MCP configuration from project spec.
77+
// Gateway fields are stored in agentcore.json but may not yet be on the
78+
// AgentCoreProjectSpec type from @aws/agentcore-cdk, so we read them
79+
// dynamically and cast the resulting object.
80+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
81+
const specAny = spec as any;
82+
const mcpSpec = specAny.agentCoreGateways?.length
7883
? {
79-
agentCoreGateways: spec.agentCoreGateways,
80-
mcpRuntimeTools: spec.mcpRuntimeTools,
81-
unassignedTargets: spec.unassignedTargets,
84+
agentCoreGateways: specAny.agentCoreGateways,
85+
mcpRuntimeTools: specAny.mcpRuntimeTools,
86+
unassignedTargets: specAny.unassignedTargets,
8287
}
8388
: undefined;
8489

src/assets/cdk/bin/cdk.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ async function main() {
2828
const spec = await configIO.readProjectSpec();
2929
const targets = await configIO.readAWSDeploymentTargets();
3030

31-
// Extract MCP configuration from project spec
32-
const mcpSpec = spec.agentCoreGateways?.length
31+
// Extract MCP configuration from project spec.
32+
// Gateway fields are stored in agentcore.json but may not yet be on the
33+
// AgentCoreProjectSpec type from @aws/agentcore-cdk, so we read them
34+
// dynamically and cast the resulting object.
35+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
36+
const specAny = spec as any;
37+
const mcpSpec = specAny.agentCoreGateways?.length
3338
? {
34-
agentCoreGateways: spec.agentCoreGateways,
35-
mcpRuntimeTools: spec.mcpRuntimeTools,
36-
unassignedTargets: spec.unassignedTargets,
39+
agentCoreGateways: specAny.agentCoreGateways,
40+
mcpRuntimeTools: specAny.mcpRuntimeTools,
41+
unassignedTargets: specAny.unassignedTargets,
3742
}
3843
: undefined;
3944

0 commit comments

Comments
 (0)