|
| 1 | +# AgentCore Project |
| 2 | + |
| 3 | +This project contains configuration and infrastructure for an Amazon Bedrock AgentCore application. |
| 4 | + |
| 5 | +The `agentcore/` directory serves as a declarative model of an AgentCore project along with a concrete implementation |
| 6 | +through the `agentcore/cdk/` project which is modeled to take the configs as input. The project models Agents and MCP |
| 7 | +setups with their own overloaded constructs. Agents are first-class. |
| 8 | + |
| 9 | +## Mental Model |
| 10 | + |
| 11 | +A good mental model for how this project works is a directed graph. We have a set of nodes: agents, memories, |
| 12 | +identities, gateways, tools, mcp servers, and future resources supported. There are rules about which nodes can connect |
| 13 | +to others in what direction. |
| 14 | + |
| 15 | +For example, stand-alone memory or identity resources cannot be modeled--they need to be owned by an agent and can be |
| 16 | +used by other agents. |
| 17 | + |
| 18 | +Wiring nodes creates an infrastructure and trust relationship but is not enough to complete end-to-end functionality. |
| 19 | +For example, attaching agentB as a remote tool for agentA means that agentA has permission to invoke agentB and that |
| 20 | +agentA has the ARN for agentB as an environment variable with the name specified in the agentcore.json schema. |
| 21 | + |
| 22 | +To complete a functional connection, the application code in agentA needs to construct the appropriate call to |
| 23 | +`invoke_agent_runtime` which will succeed based on the wiring declared in the schema and implemented in the `cdk/` |
| 24 | +directory. |
| 25 | + |
| 26 | +## Critical Invariants |
| 27 | + |
| 28 | +1. **Schema-First Authority:** The `.json` files are the absolute source of truth. Do not attempt to modify agent |
| 29 | + behavior by editing the generated CDK code in `cdk/`. |
| 30 | +2. **Resource Identity:** The `name` field in the schema determines the CloudFormation Logical ID. |
| 31 | + - **Renaming** an agent, gateway, or target will **destroy and recreate** that resource. |
| 32 | + - **Modifying** other fields (descriptions, prompts, runtime config) will update the resource **in-place**. |
| 33 | +3. **1:1 Validation:** The schema maps directly to valid CloudFormation. If your JSON conforms to the types in |
| 34 | + `.llm-context/`, it will deploy successfully. |
| 35 | + |
| 36 | +## Directory Structure |
| 37 | + |
| 38 | +``` |
| 39 | +myNewProject/ |
| 40 | +├── AGENTS.md # This file - AI coding assistant context |
| 41 | +├── agentcore/ # AgentCore configuration directory |
| 42 | +│ ├── agentcore.json # Main workspace config (AgentCoreWorkspaceSpec) |
| 43 | +│ ├── mcp.json # MCP gateways and tools (AgentCoreMcpSpec) |
| 44 | +│ ├── mcp-defs.json # Tool definitions (AgentCoreCliMcpDefs) |
| 45 | +│ ├── .llm-context/ # TypeScript type definitions for AI coding assistants |
| 46 | +│ │ ├── README.md # Guide to using the schema files |
| 47 | +│ │ ├── agentcore.ts # AgentCoreWorkspaceSpec types |
| 48 | +│ │ ├── agent-env.ts # AgentEnvSpec and runtime types |
| 49 | +│ │ ├── mcp.ts # MCP gateway and tool types |
| 50 | +│ │ └── aws-targets.ts # AWS deployment target types |
| 51 | +│ └── cdk/ # AWS CDK project for deployment |
| 52 | +└── ... (your application code) |
| 53 | +``` |
| 54 | + |
| 55 | +## Schema Reference |
| 56 | + |
| 57 | +The `agentcore/.llm-context/` directory contains TypeScript type definitions optimized for AI coding assistants. Each |
| 58 | +file maps to a JSON config file and includes validation constraints as comments. |
| 59 | + |
| 60 | +| JSON Config | Schema File | Root Type | |
| 61 | +| -------------------------- | --------------------------------------- | ------------------------ | |
| 62 | +| `agentcore/agentcore.json` | `agentcore/.llm-context/agentcore.ts` | `AgentCoreWorkspaceSpec` | |
| 63 | +| `agentcore/mcp.json` | `agentcore/.llm-context/mcp.ts` | `AgentCoreMcpSpec` | |
| 64 | +| `agentcore/mcp-defs.json` | `agentcore/.llm-context/mcp.ts` | `AgentCoreCliMcpDefs` | |
| 65 | +| (aws-targets) | `agentcore/.llm-context/aws-targets.ts` | `AWSDeploymentTarget[]` | |
| 66 | + |
| 67 | +### Key Types |
| 68 | + |
| 69 | +- **AgentEnvSpec**: Agent configuration (runtime, memory, identity, tools) |
| 70 | +- **Runtime**: Discriminated union of `CodeZipRuntime` | `ContainerImageRuntime` |
| 71 | +- **MemoryProvider**: `OwnedMemoryProvider` (creates memory) | `ReferencedMemoryProvider` (uses existing) |
| 72 | +- **AgentCoreGateway**: MCP gateway with tool targets |
| 73 | +- **ToolDefinition**: Tool name, description, input/output schemas |
| 74 | + |
| 75 | +### Common Enum Values |
| 76 | + |
| 77 | +- **ArtifactType**: `'CodeZip'` | `'ContainerImage'` |
| 78 | +- **NetworkMode**: `'PUBLIC'` | `'PRIVATE'` |
| 79 | +- **Relation**: `'own'` | `'use'` (for memory providers) |
| 80 | +- **ModelProvider**: `'Bedrock'` | `'Anthropic'` | `'OpenAI'` | `'Gemini'` |
| 81 | +- **ComputeHost**: `'Lambda'` | `'AgentCoreRuntime'` |
| 82 | + |
| 83 | +### Specific Context |
| 84 | + |
| 85 | +Directory pathing to local projects is required for runtimes and tools backed by a modeled compute. Only Python offers a |
| 86 | +zip based direct code deploy option. All other programming languages are required to be containerized and provide a path |
| 87 | +do a `Dockerfile` definition. |
| 88 | + |
| 89 | +MCP tools offer Lambda compute and AgentCore runtime compute. If something like a `FastMCP` server is desired, AgentCore |
| 90 | +runtime is a better fit. When using Lambda, the input schema needs to be modeled in `mcp-defs.json` and the lambda |
| 91 | +handler needs to be a traditional (context, event) style input shape. |
| 92 | + |
| 93 | +## Deployment |
| 94 | + |
| 95 | +The `agentcore/cdk/` subdirectory contains an AWS CDK node project. |
| 96 | + |
| 97 | +Deployments of this project are primarily intended to be orchestrated through the `agentcore deploy` command in the CLI. |
| 98 | + |
| 99 | +Alternatively, the project can be deployed directly as a traditional CDK project: |
| 100 | + |
| 101 | +```bash |
| 102 | +cd agentcore/cdk |
| 103 | +npm install |
| 104 | +npx cdk synth # Preview CloudFormation template |
| 105 | +npx cdk deploy # Deploy to AWS |
| 106 | +``` |
| 107 | + |
| 108 | +Both CLI and direct deployment have the same source of truth and are safe to be substituted interchangeably. |
| 109 | + |
| 110 | +## Editing Schemas |
| 111 | + |
| 112 | +When modifying JSON config files: |
| 113 | + |
| 114 | +1. Read the corresponding `agentcore/.llm-context/*.ts` file for type definitions |
| 115 | +2. Check validation constraint comments (`@regex`, `@min`, `@max`) |
| 116 | +3. Use exact enum values as string literals |
| 117 | +4. Use CloudFormation-safe names (alphanumeric, start with letter) |
| 118 | +5. Run `agentcore validate` command to verify changes. |
0 commit comments