Skip to content

feat!: merge mcp.json into agentcore.json#605

Merged
notgitika merged 4 commits intoaws:mainfrom
notgitika:feat/merge-mcp-into-agentcore-json
Mar 24, 2026
Merged

feat!: merge mcp.json into agentcore.json#605
notgitika merged 4 commits intoaws:mainfrom
notgitika:feat/merge-mcp-into-agentcore-json

Conversation

@notgitika
Copy link
Contributor

@notgitika notgitika commented Mar 23, 2026

Description

Merges the separate mcp.json configuration file into agentcore.json as a breaking change. Gateway and MCP tool definitions are now stored alongside the rest of the project spec in a single file, simplifying configuration management.

CDK PR: https://github.com/aws/agentcore-l3-cdk-constructs/pull/99

Key changes:

  • Removed readMcpSpec() / writeMcpSpec() from ConfigIO; all reads/writes go through readProjectSpec() / writeProjectSpec()
  • Added agentCoreGateways and mcpRuntimeTools fields to AgentCoreProjectSpecSchema with .default([])
  • Added extractMcpSpec() helper for backwards-compatible MCP type extraction
  • Removed getMcpConfigPath() from PathResolver
  • Updated all primitives, operations, TUI screens, and tests to use the unified spec

Related Issue

Closes #611

Documentation PR

N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@notgitika notgitika requested a review from a team March 23, 2026 17:00
@github-actions github-actions bot added the size/xl PR size: XL label Mar 23, 2026
Merge upstream policyEngines feature with mcp.json→agentcore.json migration.
Update PolicyEnginePrimitive to use readProjectSpec instead of readMcpSpec.
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 23, 2026
@jesseturner21 jesseturner21 marked this pull request as draft March 23, 2026 21:54
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.
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 23, 2026
@notgitika notgitika marked this pull request as ready for review March 23, 2026 23:06
@tejaskash
Copy link
Contributor

Code review

Found 4 issues:

  1. Wrong return type format: save function uses { ok: boolean; error?: string } instead of the required { success: Boolean, error?: string } format (AGENTS.md says "Wheverever there is a requirement to use something that returns a success result and an error message you must use this format { success: Boolean, error?:string}")

// Wrap save to merge MCP fields back into the full project spec
const save = async (mcpContent: string): Promise<{ ok: boolean; error?: string }> => {
if (!projectSpec) return { ok: false, error: 'No project spec loaded' };
const mcpData = JSON.parse(mcpContent) as AgentCoreMcpSpec;

  1. Inline type used instead of existing type: { agentCoreGateways: typeof context.projectSpec.agentCoreGateways } should use Pick<AgentCoreMcpSpec, 'agentCoreGateways'> or similar (AGENTS.md says "Always look for existing types before creating a new type inline.")

// Read project spec for gateway information (used later for deploy step name and outputs)
let mcpSpec: { agentCoreGateways: typeof context.projectSpec.agentCoreGateways } | null = null;
try {

  1. Missing uniqueBy validation on new arrays: agentCoreGateways, mcpRuntimeTools, and unassignedTargets are added without .superRefine(uniqueBy(...)), while every other resource array in the schema (agents, memories, credentials, evaluators, onlineEvalConfigs, policyEngines) has this validation. Duplicate names would pass schema validation but fail at deploy time. This same pattern gap was flagged in PR feat: add policy engine and policy support #579 for policyEngines.

// MCP / Gateway resources (previously in mcp.json)
agentCoreGateways: z.array(AgentCoreGatewaySchema).default([]),
mcpRuntimeTools: z.array(AgentCoreMcpRuntimeToolSchema).optional(),
unassignedTargets: z.array(AgentCoreGatewayTargetSchema).optional(),

  1. Loss of strict validation for MCP fields: AgentCoreMcpSpecSchema previously had .strict() to reject unknown fields (with a dedicated test "rejects extra fields"). The fields are now embedded in AgentCoreProjectSpecSchema which is not strict, so typos in MCP field names (e.g. agentCoreGatways) will be silently ignored instead of rejected.

// MCP / Gateway resources (previously in mcp.json)
agentCoreGateways: z.array(AgentCoreGatewaySchema).default([]),
mcpRuntimeTools: z.array(AgentCoreMcpRuntimeToolSchema).optional(),
unassignedTargets: z.array(AgentCoreGatewayTargetSchema).optional(),

- Use SaveDocumentResult type instead of inline { ok, error } in McpGuidedEditor
- Use Pick<AgentCoreMcpSpec, 'agentCoreGateways'> instead of inline type in deploy actions
- Add uniqueBy validation to agentCoreGateways, mcpRuntimeTools, unassignedTargets arrays
- Add .strict() to AgentCoreProjectSpecSchema to reject unknown fields
@github-actions github-actions bot removed the size/xl PR size: XL label Mar 24, 2026
@github-actions github-actions bot added the size/xl PR size: XL label Mar 24, 2026
@notgitika
Copy link
Contributor Author

Fixed all 4 in ef28a16:

  1. Swapped to SaveDocumentResult type
  2. Using Pick<AgentCoreMcpSpec, 'agentCoreGateways'> now
  3. Added uniqueBy validation on all three MCP arrays
  4. Added .strict() to AgentCoreProjectSpecSchema

Copy link
Contributor

@tejaskash tejaskash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 4 review comments addressed. The ok vs success naming in SaveDocumentResult is a pre-existing issue beyond this PR's scope — can be tracked separately.

@notgitika notgitika merged commit 23df9fe into aws:main Mar 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combine mcp.json into agentcore.json to have one unified config file

2 participants