@aws/agentcore 0.3.0-preview.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/LICENSE +175 -0
  2. package/README.md +147 -0
  3. package/dist/assets/README.md +79 -0
  4. package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +2862 -0
  5. package/dist/assets/__tests__/assets.snapshot.test.ts +139 -0
  6. package/dist/assets/agents/AGENTS.md +102 -0
  7. package/dist/assets/cdk/.prettierrc +8 -0
  8. package/dist/assets/cdk/README.md +14 -0
  9. package/dist/assets/cdk/bin/cdk.ts +50 -0
  10. package/dist/assets/cdk/cdk.json +88 -0
  11. package/dist/assets/cdk/gitignore.template +9 -0
  12. package/dist/assets/cdk/jest.config.js +9 -0
  13. package/dist/assets/cdk/lib/cdk-stack.ts +38 -0
  14. package/dist/assets/cdk/npmignore.template +6 -0
  15. package/dist/assets/cdk/package.json +30 -0
  16. package/dist/assets/cdk/test/cdk.test.ts +16 -0
  17. package/dist/assets/cdk/tsconfig.json +28 -0
  18. package/dist/assets/mcp/python/README.md +27 -0
  19. package/dist/assets/mcp/python/pyproject.toml +22 -0
  20. package/dist/assets/mcp/python/server.py +117 -0
  21. package/dist/assets/mcp/python-lambda/README.md +22 -0
  22. package/dist/assets/mcp/python-lambda/handler.py +144 -0
  23. package/dist/assets/mcp/python-lambda/pyproject.toml +15 -0
  24. package/dist/assets/python/autogen/base/README.md +41 -0
  25. package/dist/assets/python/autogen/base/gitignore.template +40 -0
  26. package/dist/assets/python/autogen/base/main.py +52 -0
  27. package/dist/assets/python/autogen/base/mcp_client/client.py +18 -0
  28. package/dist/assets/python/autogen/base/model/load.py +136 -0
  29. package/dist/assets/python/autogen/base/pyproject.toml +35 -0
  30. package/dist/assets/python/crewai/base/README.md +41 -0
  31. package/dist/assets/python/crewai/base/gitignore.template +40 -0
  32. package/dist/assets/python/crewai/base/main.py +55 -0
  33. package/dist/assets/python/crewai/base/model/load.py +133 -0
  34. package/dist/assets/python/crewai/base/pyproject.toml +32 -0
  35. package/dist/assets/python/googleadk/base/README.md +39 -0
  36. package/dist/assets/python/googleadk/base/gitignore.template +40 -0
  37. package/dist/assets/python/googleadk/base/main.py +84 -0
  38. package/dist/assets/python/googleadk/base/mcp_client/client.py +15 -0
  39. package/dist/assets/python/googleadk/base/model/load.py +41 -0
  40. package/dist/assets/python/googleadk/base/pyproject.toml +21 -0
  41. package/dist/assets/python/langchain_langgraph/base/README.md +41 -0
  42. package/dist/assets/python/langchain_langgraph/base/gitignore.template +40 -0
  43. package/dist/assets/python/langchain_langgraph/base/main.py +51 -0
  44. package/dist/assets/python/langchain_langgraph/base/mcp_client/client.py +19 -0
  45. package/dist/assets/python/langchain_langgraph/base/model/load.py +123 -0
  46. package/dist/assets/python/langchain_langgraph/base/pyproject.toml +37 -0
  47. package/dist/assets/python/openaiagents/base/README.md +39 -0
  48. package/dist/assets/python/openaiagents/base/gitignore.template +40 -0
  49. package/dist/assets/python/openaiagents/base/main.py +56 -0
  50. package/dist/assets/python/openaiagents/base/mcp_client/client.py +14 -0
  51. package/dist/assets/python/openaiagents/base/model/load.py +37 -0
  52. package/dist/assets/python/openaiagents/base/pyproject.toml +20 -0
  53. package/dist/assets/python/strands/base/README.md +41 -0
  54. package/dist/assets/python/strands/base/gitignore.template +41 -0
  55. package/dist/assets/python/strands/base/main.py +76 -0
  56. package/dist/assets/python/strands/base/mcp_client/client.py +12 -0
  57. package/dist/assets/python/strands/base/model/load.py +123 -0
  58. package/dist/assets/python/strands/base/pyproject.toml +23 -0
  59. package/dist/assets/python/strands/capabilities/memory/session.py +39 -0
  60. package/dist/assets/typescript/.gitkeep +0 -0
  61. package/dist/cli/index.mjs +985 -0
  62. package/dist/index.d.ts +9 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +27 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/lib/constants.d.ts +25 -0
  67. package/dist/lib/constants.d.ts.map +1 -0
  68. package/dist/lib/constants.js +49 -0
  69. package/dist/lib/constants.js.map +1 -0
  70. package/dist/lib/errors/config.d.ts +49 -0
  71. package/dist/lib/errors/config.d.ts.map +1 -0
  72. package/dist/lib/errors/config.js +167 -0
  73. package/dist/lib/errors/config.js.map +1 -0
  74. package/dist/lib/errors/index.d.ts +2 -0
  75. package/dist/lib/errors/index.d.ts.map +1 -0
  76. package/dist/lib/errors/index.js +18 -0
  77. package/dist/lib/errors/index.js.map +1 -0
  78. package/dist/lib/index.d.ts +7 -0
  79. package/dist/lib/index.d.ts.map +1 -0
  80. package/dist/lib/index.js +39 -0
  81. package/dist/lib/index.js.map +1 -0
  82. package/dist/lib/packaging/errors.d.ts +16 -0
  83. package/dist/lib/packaging/errors.d.ts.map +1 -0
  84. package/dist/lib/packaging/errors.js +36 -0
  85. package/dist/lib/packaging/errors.js.map +1 -0
  86. package/dist/lib/packaging/helpers.d.ts +54 -0
  87. package/dist/lib/packaging/helpers.d.ts.map +1 -0
  88. package/dist/lib/packaging/helpers.js +461 -0
  89. package/dist/lib/packaging/helpers.js.map +1 -0
  90. package/dist/lib/packaging/index.d.ts +36 -0
  91. package/dist/lib/packaging/index.d.ts.map +1 -0
  92. package/dist/lib/packaging/index.js +89 -0
  93. package/dist/lib/packaging/index.js.map +1 -0
  94. package/dist/lib/packaging/node.d.ts +17 -0
  95. package/dist/lib/packaging/node.d.ts.map +1 -0
  96. package/dist/lib/packaging/node.js +108 -0
  97. package/dist/lib/packaging/node.js.map +1 -0
  98. package/dist/lib/packaging/python.d.ts +17 -0
  99. package/dist/lib/packaging/python.d.ts.map +1 -0
  100. package/dist/lib/packaging/python.js +162 -0
  101. package/dist/lib/packaging/python.js.map +1 -0
  102. package/dist/lib/packaging/types/index.d.ts +2 -0
  103. package/dist/lib/packaging/types/index.d.ts.map +1 -0
  104. package/dist/lib/packaging/types/index.js +3 -0
  105. package/dist/lib/packaging/types/index.js.map +1 -0
  106. package/dist/lib/packaging/types/packaging.d.ts +57 -0
  107. package/dist/lib/packaging/types/packaging.d.ts.map +1 -0
  108. package/dist/lib/packaging/types/packaging.js +3 -0
  109. package/dist/lib/packaging/types/packaging.js.map +1 -0
  110. package/dist/lib/packaging/uv.d.ts +7 -0
  111. package/dist/lib/packaging/uv.d.ts.map +1 -0
  112. package/dist/lib/packaging/uv.js +40 -0
  113. package/dist/lib/packaging/uv.js.map +1 -0
  114. package/dist/lib/schemas/io/config-io.d.ts +106 -0
  115. package/dist/lib/schemas/io/config-io.d.ts.map +1 -0
  116. package/dist/lib/schemas/io/config-io.js +293 -0
  117. package/dist/lib/schemas/io/config-io.js.map +1 -0
  118. package/dist/lib/schemas/io/index.d.ts +3 -0
  119. package/dist/lib/schemas/io/index.d.ts.map +1 -0
  120. package/dist/lib/schemas/io/index.js +17 -0
  121. package/dist/lib/schemas/io/index.js.map +1 -0
  122. package/dist/lib/schemas/io/path-resolver.d.ts +112 -0
  123. package/dist/lib/schemas/io/path-resolver.d.ts.map +1 -0
  124. package/dist/lib/schemas/io/path-resolver.js +195 -0
  125. package/dist/lib/schemas/io/path-resolver.js.map +1 -0
  126. package/dist/lib/utils/aws-account.d.ts +7 -0
  127. package/dist/lib/utils/aws-account.d.ts.map +1 -0
  128. package/dist/lib/utils/aws-account.js +24 -0
  129. package/dist/lib/utils/aws-account.js.map +1 -0
  130. package/dist/lib/utils/credentials.d.ts +86 -0
  131. package/dist/lib/utils/credentials.d.ts.map +1 -0
  132. package/dist/lib/utils/credentials.js +153 -0
  133. package/dist/lib/utils/credentials.js.map +1 -0
  134. package/dist/lib/utils/env.d.ts +22 -0
  135. package/dist/lib/utils/env.d.ts.map +1 -0
  136. package/dist/lib/utils/env.js +65 -0
  137. package/dist/lib/utils/env.js.map +1 -0
  138. package/dist/lib/utils/index.d.ts +7 -0
  139. package/dist/lib/utils/index.d.ts.map +1 -0
  140. package/dist/lib/utils/index.js +23 -0
  141. package/dist/lib/utils/index.js.map +1 -0
  142. package/dist/lib/utils/platform.d.ts +63 -0
  143. package/dist/lib/utils/platform.d.ts.map +1 -0
  144. package/dist/lib/utils/platform.js +88 -0
  145. package/dist/lib/utils/platform.js.map +1 -0
  146. package/dist/lib/utils/subprocess.d.ts +29 -0
  147. package/dist/lib/utils/subprocess.d.ts.map +1 -0
  148. package/dist/lib/utils/subprocess.js +94 -0
  149. package/dist/lib/utils/subprocess.js.map +1 -0
  150. package/dist/lib/utils/zod.d.ts +14 -0
  151. package/dist/lib/utils/zod.d.ts.map +1 -0
  152. package/dist/lib/utils/zod.js +32 -0
  153. package/dist/lib/utils/zod.js.map +1 -0
  154. package/dist/schema/constants.d.ts +82 -0
  155. package/dist/schema/constants.d.ts.map +1 -0
  156. package/dist/schema/constants.js +117 -0
  157. package/dist/schema/constants.js.map +1 -0
  158. package/dist/schema/index.d.ts +4 -0
  159. package/dist/schema/index.d.ts.map +1 -0
  160. package/dist/schema/index.js +21 -0
  161. package/dist/schema/index.js.map +1 -0
  162. package/dist/schema/schemas/agent-env.d.ts +75 -0
  163. package/dist/schema/schemas/agent-env.d.ts.map +1 -0
  164. package/dist/schema/schemas/agent-env.js +84 -0
  165. package/dist/schema/schemas/agent-env.js.map +1 -0
  166. package/dist/schema/schemas/agentcore-project.d.ts +88 -0
  167. package/dist/schema/schemas/agentcore-project.d.ts.map +1 -0
  168. package/dist/schema/schemas/agentcore-project.js +83 -0
  169. package/dist/schema/schemas/agentcore-project.js.map +1 -0
  170. package/dist/schema/schemas/aws-targets.d.ts +50 -0
  171. package/dist/schema/schemas/aws-targets.d.ts.map +1 -0
  172. package/dist/schema/schemas/aws-targets.js +49 -0
  173. package/dist/schema/schemas/aws-targets.js.map +1 -0
  174. package/dist/schema/schemas/deployed-state.d.ts +260 -0
  175. package/dist/schema/schemas/deployed-state.d.ts.map +1 -0
  176. package/dist/schema/schemas/deployed-state.js +100 -0
  177. package/dist/schema/schemas/deployed-state.js.map +1 -0
  178. package/dist/schema/schemas/index.d.ts +8 -0
  179. package/dist/schema/schemas/index.d.ts.map +1 -0
  180. package/dist/schema/schemas/index.js +25 -0
  181. package/dist/schema/schemas/index.js.map +1 -0
  182. package/dist/schema/schemas/mcp-defs.d.ts +52 -0
  183. package/dist/schema/schemas/mcp-defs.d.ts.map +1 -0
  184. package/dist/schema/schemas/mcp-defs.js +50 -0
  185. package/dist/schema/schemas/mcp-defs.js.map +1 -0
  186. package/dist/schema/schemas/mcp.d.ts +659 -0
  187. package/dist/schema/schemas/mcp.d.ts.map +1 -0
  188. package/dist/schema/schemas/mcp.js +283 -0
  189. package/dist/schema/schemas/mcp.js.map +1 -0
  190. package/dist/schema/schemas/primitives/index.d.ts +3 -0
  191. package/dist/schema/schemas/primitives/index.d.ts.map +1 -0
  192. package/dist/schema/schemas/primitives/index.js +9 -0
  193. package/dist/schema/schemas/primitives/index.js.map +1 -0
  194. package/dist/schema/schemas/primitives/memory.d.ts +42 -0
  195. package/dist/schema/schemas/primitives/memory.d.ts.map +1 -0
  196. package/dist/schema/schemas/primitives/memory.js +50 -0
  197. package/dist/schema/schemas/primitives/memory.js.map +1 -0
  198. package/dist/schema/schemas/zod-util.d.ts +10 -0
  199. package/dist/schema/schemas/zod-util.d.ts.map +1 -0
  200. package/dist/schema/schemas/zod-util.js +23 -0
  201. package/dist/schema/schemas/zod-util.js.map +1 -0
  202. package/dist/schema/types/index.d.ts +2 -0
  203. package/dist/schema/types/index.d.ts.map +1 -0
  204. package/dist/schema/types/index.js +18 -0
  205. package/dist/schema/types/index.js.map +1 -0
  206. package/dist/schema/types/path.d.ts +27 -0
  207. package/dist/schema/types/path.d.ts.map +1 -0
  208. package/dist/schema/types/path.js +13 -0
  209. package/dist/schema/types/path.js.map +1 -0
  210. package/package.json +111 -0
  211. package/scripts/bump-version.ts +442 -0
  212. package/scripts/check-old-cli.mjs +26 -0
  213. package/scripts/copy-assets.mjs +50 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Snapshot tests for the assets directory.
3
+ *
4
+ * These tests ensure that template files vended to users don't change unexpectedly.
5
+ * If you intentionally change an asset file, update snapshots with:
6
+ *
7
+ * npm run test:snapshots:update
8
+ *
9
+ * See docs/TESTING.md for more information.
10
+ */
11
+ import * as fs from 'fs';
12
+ import * as path from 'path';
13
+ import { describe, expect, it } from 'vitest';
14
+
15
+ const ASSETS_DIR = path.resolve(__dirname, '..');
16
+
17
+ /**
18
+ * Recursively get all files in a directory
19
+ */
20
+ function getAllFiles(dir: string, baseDir: string = dir): string[] {
21
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
22
+ const files: string[] = [];
23
+
24
+ for (const entry of entries) {
25
+ const fullPath = path.join(dir, entry.name);
26
+ if (entry.isDirectory()) {
27
+ // Skip __tests__ directory to avoid circular snapshots
28
+ if (entry.name === '__tests__' || entry.name === '__snapshots__') {
29
+ continue;
30
+ }
31
+ files.push(...getAllFiles(fullPath, baseDir));
32
+ } else {
33
+ // Get relative path from assets dir for cleaner snapshot names
34
+ const relativePath = path.relative(baseDir, fullPath);
35
+ files.push(relativePath);
36
+ }
37
+ }
38
+
39
+ return files.sort();
40
+ }
41
+
42
+ /**
43
+ * Read file content, handling binary files gracefully
44
+ */
45
+ function readFileContent(filePath: string): string {
46
+ const content = fs.readFileSync(filePath, 'utf-8');
47
+ return content;
48
+ }
49
+
50
+ describe('Assets Directory Snapshots', () => {
51
+ const assetFiles = getAllFiles(ASSETS_DIR);
52
+
53
+ it('should have asset files to test', () => {
54
+ expect(assetFiles.length).toBeGreaterThan(0);
55
+ });
56
+
57
+ describe('File listing', () => {
58
+ it('should match the expected file structure', () => {
59
+ expect(assetFiles).toMatchSnapshot('asset-file-listing');
60
+ });
61
+ });
62
+
63
+ describe('CDK assets', () => {
64
+ const cdkFiles = assetFiles.filter(f => f.startsWith('cdk/'));
65
+
66
+ it.each(cdkFiles)('cdk/%s should match snapshot', file => {
67
+ const content = readFileContent(path.join(ASSETS_DIR, file));
68
+ expect(content).toMatchSnapshot();
69
+ });
70
+ });
71
+
72
+ describe('Python framework assets', () => {
73
+ const pythonFiles = assetFiles.filter(f => f.startsWith('python/'));
74
+
75
+ it.each(pythonFiles)('python/%s should match snapshot', file => {
76
+ const content = readFileContent(path.join(ASSETS_DIR, file));
77
+ expect(content).toMatchSnapshot();
78
+ });
79
+ });
80
+
81
+ describe('MCP assets', () => {
82
+ const mcpFiles = assetFiles.filter(f => f.startsWith('mcp/'));
83
+
84
+ it.each(mcpFiles)('mcp/%s should match snapshot', file => {
85
+ const content = readFileContent(path.join(ASSETS_DIR, file));
86
+ expect(content).toMatchSnapshot();
87
+ });
88
+ });
89
+
90
+ describe('Static assets', () => {
91
+ const staticFiles = assetFiles.filter(f => f.startsWith('static/'));
92
+
93
+ if (staticFiles.length > 0) {
94
+ it.each(staticFiles)('static/%s should match snapshot', file => {
95
+ const content = readFileContent(path.join(ASSETS_DIR, file));
96
+ expect(content).toMatchSnapshot();
97
+ });
98
+ } else {
99
+ it('static directory is empty or does not exist', () => {
100
+ // Static assets may not exist
101
+ expect(true).toBe(true);
102
+ });
103
+ }
104
+ });
105
+
106
+ describe('TypeScript assets', () => {
107
+ const tsFiles = assetFiles.filter(f => f.startsWith('typescript/'));
108
+
109
+ if (tsFiles.length > 0) {
110
+ it.each(tsFiles)('typescript/%s should match snapshot', file => {
111
+ const content = readFileContent(path.join(ASSETS_DIR, file));
112
+ expect(content).toMatchSnapshot();
113
+ });
114
+ } else {
115
+ it('typescript directory is empty or contains only placeholder files', () => {
116
+ // TypeScript assets may not exist yet
117
+ expect(true).toBe(true);
118
+ });
119
+ }
120
+ });
121
+
122
+ describe('Root-level assets', () => {
123
+ const rootFiles = assetFiles.filter(
124
+ f =>
125
+ !f.includes('/') ||
126
+ (f.startsWith('agents/') &&
127
+ !f.startsWith('cdk/') &&
128
+ !f.startsWith('python/') &&
129
+ !f.startsWith('mcp/') &&
130
+ !f.startsWith('static/') &&
131
+ !f.startsWith('typescript/'))
132
+ );
133
+
134
+ it.each(rootFiles)('%s should match snapshot', file => {
135
+ const content = readFileContent(path.join(ASSETS_DIR, file));
136
+ expect(content).toMatchSnapshot();
137
+ });
138
+ });
139
+ });
@@ -0,0 +1,102 @@
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 uses a **flat resource
7
+ model** where agents, memories, and credentials are top-level arrays.
8
+
9
+ ## Mental Model
10
+
11
+ The project uses a **flat resource model**. Agents, memories, and credentials are independent top-level arrays in
12
+ `agentcore.json`. There is no binding or attachment between resources in the schema — each resource is provisioned
13
+ independently. To use a memory or credential from an agent, the application code discovers the resource at runtime
14
+ (e.g., via environment variables or SDK calls).
15
+
16
+ ## Critical Invariants
17
+
18
+ 1. **Schema-First Authority:** The `.json` files are the absolute source of truth. Do not attempt to modify agent
19
+ behavior by editing the generated CDK code in `cdk/`.
20
+ 2. **Resource Identity:** The `name` field in the schema determines the CloudFormation Logical ID.
21
+ - **Renaming** an agent or target will **destroy and recreate** that resource.
22
+ - **Modifying** other fields (descriptions, config) will update the resource **in-place**.
23
+ 3. **1:1 Validation:** The schema maps directly to valid CloudFormation. If your JSON conforms to the types in
24
+ `.llm-context/`, it will deploy successfully.
25
+ 4. **Resource Removal:** To remove all resources, use `agentcore remove all`. To tear down deployed infrastructure, run
26
+ `agentcore deploy` after removal — it will detect the empty state and offer a teardown flow.
27
+
28
+ ## Directory Structure
29
+
30
+ ```
31
+ myNewProject/
32
+ ├── AGENTS.md # This file - AI coding assistant context
33
+ ├── agentcore/ # AgentCore configuration directory
34
+ │ ├── agentcore.json # Main project config (AgentCoreProjectSpec)
35
+ │ ├── aws-targets.json # Deployment targets
36
+ │ ├── .llm-context/ # TypeScript type definitions for AI coding assistants
37
+ │ │ ├── README.md # Guide to using the schema files
38
+ │ │ ├── agentcore.ts # AgentCoreProjectSpec types
39
+ │ │ └── aws-targets.ts # AWS deployment target types
40
+ │ └── cdk/ # AWS CDK project for deployment
41
+ └── app/ # Application code (if agents were created)
42
+ ```
43
+
44
+ ## Schema Reference
45
+
46
+ The `agentcore/.llm-context/` directory contains TypeScript type definitions optimized for AI coding assistants. Each
47
+ file maps to a JSON config file and includes validation constraints as comments.
48
+
49
+ | JSON Config | Schema File | Root Type |
50
+ | ---------------------------- | --------------------------------------- | ----------------------- |
51
+ | `agentcore/agentcore.json` | `agentcore/.llm-context/agentcore.ts` | `AgentCoreProjectSpec` |
52
+ | `agentcore/aws-targets.json` | `agentcore/.llm-context/aws-targets.ts` | `AWSDeploymentTarget[]` |
53
+
54
+ ### Key Types
55
+
56
+ - **AgentCoreProjectSpec**: Root project configuration with `agents`, `memories`, `credentials` arrays
57
+ - **AgentEnvSpec**: Agent configuration (runtime, entrypoint, code location)
58
+ - **Memory**: Memory resource with strategies and expiry
59
+ - **Credential**: API key credential provider
60
+
61
+ ### Common Enum Values
62
+
63
+ - **BuildType**: `'CodeZip'`
64
+ - **NetworkMode**: `'PUBLIC'`
65
+ - **RuntimeVersion**: `'PYTHON_3_10'` | `'PYTHON_3_11'` | `'PYTHON_3_12'` | `'PYTHON_3_13'`
66
+ - **MemoryStrategyType**: `'SEMANTIC'` | `'SUMMARIZATION'` | `'USER_PREFERENCE'`
67
+
68
+ ### Supported Frameworks (for template agents)
69
+
70
+ - **Strands** - Works with Bedrock, Anthropic, OpenAI, Gemini
71
+ - **LangChain_LangGraph** - Works with Bedrock, Anthropic, OpenAI, Gemini
72
+ - **GoogleADK** - Gemini only
73
+ - **OpenAIAgents** - OpenAI only
74
+
75
+ ### Specific Context
76
+
77
+ Directory pathing to local projects is required for runtimes. Only Python offers a zip based direct code deploy option.
78
+
79
+ ## Deployment
80
+
81
+ The `agentcore/cdk/` subdirectory contains an AWS CDK node project.
82
+
83
+ Deployments of this project are primarily intended to be orchestrated through the `agentcore deploy` command in the CLI.
84
+
85
+ Alternatively, the project can be deployed directly as a traditional CDK project:
86
+
87
+ ```bash
88
+ cd agentcore/cdk
89
+ npm install
90
+ npx cdk synth # Preview CloudFormation template
91
+ npx cdk deploy # Deploy to AWS
92
+ ```
93
+
94
+ ## Editing Schemas
95
+
96
+ When modifying JSON config files:
97
+
98
+ 1. Read the corresponding `agentcore/.llm-context/*.ts` file for type definitions
99
+ 2. Check validation constraint comments (`@regex`, `@min`, `@max`)
100
+ 3. Use exact enum values as string literals
101
+ 4. Use CloudFormation-safe names (alphanumeric, start with letter)
102
+ 5. Run `agentcore validate` command to verify changes.
@@ -0,0 +1,8 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "printWidth": 120,
4
+ "tabWidth": 2,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "arrowParens": "avoid"
8
+ }
@@ -0,0 +1,14 @@
1
+ # Welcome to your CDK TypeScript project
2
+
3
+ This is a blank project for CDK development with TypeScript.
4
+
5
+ The `cdk.json` file tells the CDK Toolkit how to execute your app.
6
+
7
+ ## Useful commands
8
+
9
+ - `npm run build` compile typescript to js
10
+ - `npm run watch` watch for changes and compile
11
+ - `npm run test` perform the jest unit tests
12
+ - `npx cdk deploy` deploy this stack to your default AWS account/region
13
+ - `npx cdk diff` compare deployed stack with current state
14
+ - `npx cdk synth` emits the synthesized CloudFormation template
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import { AgentCoreStack } from '../lib/cdk-stack';
3
+ import { ConfigIO, type AwsDeploymentTarget } from '@aws/agentcore-cdk';
4
+ import { App, type Environment } from 'aws-cdk-lib';
5
+ import * as path from 'path';
6
+
7
+ function toEnvironment(target: AwsDeploymentTarget): Environment {
8
+ return {
9
+ account: target.account,
10
+ region: target.region,
11
+ };
12
+ }
13
+
14
+ function toStackName(projectName: string, targetName: string): string {
15
+ return `AgentCore-${projectName}-${targetName}`;
16
+ }
17
+
18
+ async function main() {
19
+ // Config root is parent of cdk/ directory. The CLI sets process.cwd() to agentcore/cdk/.
20
+ const configRoot = path.resolve(process.cwd(), '..');
21
+ const configIO = new ConfigIO({ baseDir: configRoot });
22
+
23
+ const spec = await configIO.readProjectSpec();
24
+ const targets = await configIO.readAWSDeploymentTargets();
25
+
26
+ if (targets.length === 0) {
27
+ throw new Error('No deployment targets configured. Please define targets in agentcore/aws-targets.json');
28
+ }
29
+
30
+ const app = new App();
31
+
32
+ for (const target of targets) {
33
+ const env = toEnvironment(target);
34
+ const stackName = toStackName(spec.name, target.name);
35
+
36
+ new AgentCoreStack(app, stackName, {
37
+ spec,
38
+ env,
39
+ description: `AgentCore stack for ${spec.name} deployed to ${target.name} (${target.region})`,
40
+ tags: {
41
+ 'agentcore:project-name': spec.name,
42
+ 'agentcore:target-name': target.name,
43
+ },
44
+ });
45
+ }
46
+
47
+ app.synth();
48
+ }
49
+
50
+ main();
@@ -0,0 +1,88 @@
1
+ {
2
+ "app": "node dist/bin/cdk.js",
3
+ "watch": {
4
+ "include": ["**"],
5
+ "exclude": ["README.md", "cdk*.json", "tsconfig.json", "package*.json", "yarn.lock", "node_modules", "dist", "test"]
6
+ },
7
+ "context": {
8
+ "@aws-cdk/aws-signer:signingProfileNamePassedToCfn": true,
9
+ "@aws-cdk/aws-ecs-patterns:secGroupsDisablesImplicitOpenListener": true,
10
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
11
+ "@aws-cdk/core:checkSecretUsage": true,
12
+ "@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
13
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
14
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
15
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
16
+ "@aws-cdk/aws-iam:minimizePolicies": true,
17
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
18
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
19
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
20
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
21
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
22
+ "@aws-cdk/core:enablePartitionLiterals": true,
23
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
24
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
25
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
26
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
27
+ "@aws-cdk/aws-route53-patters:useCertificate": true,
28
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
29
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
30
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
31
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
32
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
33
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
34
+ "@aws-cdk/aws-redshift:columnId": true,
35
+ "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
36
+ "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
37
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
38
+ "@aws-cdk/aws-kms:aliasNameRef": true,
39
+ "@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal": true,
40
+ "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
41
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
42
+ "@aws-cdk/aws-efs:denyAnonymousAccess": true,
43
+ "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
44
+ "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
45
+ "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
46
+ "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
47
+ "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
48
+ "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
49
+ "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
50
+ "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
51
+ "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
52
+ "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
53
+ "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
54
+ "@aws-cdk/aws-eks:nodegroupNameAttribute": true,
55
+ "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
56
+ "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
57
+ "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
58
+ "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
59
+ "@aws-cdk/core:explicitStackTags": true,
60
+ "@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature": false,
61
+ "@aws-cdk/aws-ecs:disableEcsImdsBlocking": true,
62
+ "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
63
+ "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
64
+ "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
65
+ "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
66
+ "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
67
+ "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
68
+ "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
69
+ "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true,
70
+ "@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true,
71
+ "@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true,
72
+ "@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
73
+ "@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
74
+ "@aws-cdk/core:enableAdditionalMetadataCollection": true,
75
+ "@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
76
+ "@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
77
+ "@aws-cdk/aws-events:requireEventBusPolicySid": true,
78
+ "@aws-cdk/core:aspectPrioritiesMutating": true,
79
+ "@aws-cdk/aws-dynamodb:retainTableReplica": true,
80
+ "@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
81
+ "@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true,
82
+ "@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
83
+ "@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
84
+ "@aws-cdk/aws-lambda:useCdkManagedLogGroup": true,
85
+ "@aws-cdk/aws-elasticloadbalancingv2:networkLoadBalancerWithSecurityGroupByDefault": true,
86
+ "@aws-cdk/aws-ecs-patterns:uniqueTargetGroupId": true
87
+ }
88
+ }
@@ -0,0 +1,9 @@
1
+ # Build output
2
+ dist/
3
+
4
+ # Dependencies
5
+ node_modules/
6
+
7
+ # CDK asset staging directory
8
+ .cdk.staging
9
+ cdk.out
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ roots: ['<rootDir>/test'],
4
+ testMatch: ['**/*.test.ts'],
5
+ transform: {
6
+ '^.+\\.tsx?$': 'ts-jest',
7
+ },
8
+ setupFilesAfterEnv: ['aws-cdk-lib/testhelpers/jest-autoclean'],
9
+ };
@@ -0,0 +1,38 @@
1
+ import { AgentCoreApplication, type AgentCoreProjectSpec } from '@aws/agentcore-cdk';
2
+ import { CfnOutput, Stack, type StackProps } from 'aws-cdk-lib';
3
+ import { Construct } from 'constructs';
4
+
5
+ export interface AgentCoreStackProps extends StackProps {
6
+ /**
7
+ * The AgentCore project specification containing agents, memories, and credentials.
8
+ */
9
+ spec: AgentCoreProjectSpec;
10
+ }
11
+
12
+ /**
13
+ * CDK Stack that deploys AgentCore infrastructure.
14
+ *
15
+ * This is a thin wrapper that instantiates L3 constructs.
16
+ * All resource logic and outputs are contained within the L3 constructs.
17
+ */
18
+ export class AgentCoreStack extends Stack {
19
+ /** The AgentCore application containing all agent environments */
20
+ public readonly application: AgentCoreApplication;
21
+
22
+ constructor(scope: Construct, id: string, props: AgentCoreStackProps) {
23
+ super(scope, id, props);
24
+
25
+ const { spec } = props;
26
+
27
+ // Create AgentCoreApplication with all agents
28
+ this.application = new AgentCoreApplication(this, 'Application', {
29
+ spec,
30
+ });
31
+
32
+ // Stack-level output
33
+ new CfnOutput(this, 'StackNameOutput', {
34
+ description: 'Name of the CloudFormation Stack',
35
+ value: this.stackName,
36
+ });
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ *.ts
2
+ !*.d.ts
3
+
4
+ # CDK asset staging directory
5
+ .cdk.staging
6
+ cdk.out
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "agentcore-cdk-app",
3
+ "version": "0.1.0",
4
+ "bin": {
5
+ "cdk": "dist/bin/cdk.js"
6
+ },
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc -w",
10
+ "test": "jest",
11
+ "cdk": "npm run build && cdk",
12
+ "clean": "rm -rf dist",
13
+ "format": "prettier --write .",
14
+ "format:check": "prettier --check ."
15
+ },
16
+ "devDependencies": {
17
+ "@types/jest": "^29.5.14",
18
+ "@types/node": "^24.10.1",
19
+ "jest": "^29.7.0",
20
+ "ts-jest": "^29.2.5",
21
+ "aws-cdk": "2.1100.1",
22
+ "prettier": "^3.4.2",
23
+ "typescript": "~5.9.3"
24
+ },
25
+ "dependencies": {
26
+ "@aws/agentcore-cdk": "^0.1.0-alpha.1",
27
+ "aws-cdk-lib": "2.234.1",
28
+ "constructs": "^10.0.0"
29
+ }
30
+ }
@@ -0,0 +1,16 @@
1
+ // import * as cdk from 'aws-cdk-lib/core';
2
+ // import { Template } from 'aws-cdk-lib/assertions';
3
+ // import * as Cdk from '../lib/cdk-stack';
4
+
5
+ // example test. To run these tests, uncomment this file along with the
6
+ // example resource in lib/cdk-stack.ts
7
+ test('SQS Queue Created', () => {
8
+ // const app = new cdk.App();
9
+ // // WHEN
10
+ // const stack = new Cdk.CdkStack(app, 'MyTestStack');
11
+ // // THEN
12
+ // const template = Template.fromStack(stack);
13
+ // template.hasResourceProperties('AWS::SQS::Queue', {
14
+ // VisibilityTimeout: 300
15
+ // });
16
+ });
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "Node",
6
+ "lib": ["es2022"],
7
+ "declaration": true,
8
+ "strict": true,
9
+ "noImplicitAny": true,
10
+ "strictNullChecks": true,
11
+ "noImplicitThis": true,
12
+ "alwaysStrict": true,
13
+ "noUnusedLocals": false,
14
+ "noUnusedParameters": false,
15
+ "noImplicitReturns": true,
16
+ "noFallthroughCasesInSwitch": false,
17
+ "inlineSourceMap": true,
18
+ "inlineSources": true,
19
+ "experimentalDecorators": true,
20
+ "strictPropertyInitialization": false,
21
+ "skipLibCheck": true,
22
+ "typeRoots": ["./node_modules/@types"],
23
+ "rootDir": ".",
24
+ "outDir": "dist"
25
+ },
26
+ "include": ["bin/**/*", "lib/**/*", "test/**/*"],
27
+ "exclude": ["node_modules", "cdk.out", "dist"]
28
+ }
@@ -0,0 +1,27 @@
1
+ # {{ name }}
2
+
3
+ This is a template MCP server generated by the AgentCore CLI.
4
+
5
+ Demonstrates HTTP tool patterns with proper error handling and retry logic.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ # Create and activate virtual environment
11
+ uv venv
12
+ source .venv/bin/activate # or .venv\Scripts\activate on Windows
13
+
14
+ # Install dependencies
15
+ uv sync
16
+
17
+ # Run the server
18
+ uv run server.py
19
+ ```
20
+
21
+ ## Available Tools
22
+
23
+ | Tool | Description |
24
+ | ----------------- | ------------------------------------------------------ |
25
+ | `lookup_ip` | Look up geolocation and network info for an IP address |
26
+ | `get_random_user` | Generate a random user profile for testing |
27
+ | `fetch_post` | Fetch a post by ID from JSONPlaceholder API |
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "{{ name }}"
7
+ version = "0.1.0"
8
+ description = "MCP Server demonstrating HTTP tool patterns"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "mcp[cli] >= 1.2.0",
13
+ "httpx >= 0.27.0",
14
+ "opentelemetry-distro",
15
+ "opentelemetry-exporter-otlp",
16
+ ]
17
+
18
+ [project.scripts]
19
+ server = "server:main"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["."]