@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,40 @@
1
+ # Environment variables
2
+ .env
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+ *.so
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Virtual environments
27
+ venv/
28
+ ENV/
29
+ env/
30
+
31
+ # IDE
32
+ .vscode/
33
+ .idea/
34
+ *.swp
35
+ *.swo
36
+ *~
37
+
38
+ # OS
39
+ .DS_Store
40
+ Thumbs.db
@@ -0,0 +1,55 @@
1
+ from crewai import Agent, Crew, Task, Process
2
+ from crewai.tools import tool
3
+ from bedrock_agentcore.runtime import BedrockAgentCoreApp
4
+ from model.load import load_model
5
+
6
+ app = BedrockAgentCoreApp()
7
+ log = app.logger
8
+
9
+
10
+ # Define a simple function tool
11
+ @tool
12
+ def add_numbers(a: int, b: int) -> int:
13
+ """Return the sum of two numbers"""
14
+ return a + b
15
+
16
+
17
+ # Define a collection of tools used by the model
18
+ tools = [add_numbers]
19
+
20
+
21
+ @app.entrypoint
22
+ def invoke(payload, context):
23
+ log.info("Invoking Agent.....")
24
+
25
+ # Define the Agent with Tools
26
+ agent = Agent(
27
+ role="Question Answering Assistant",
28
+ goal="Answer the users questions",
29
+ backstory="Always eager to answer any questions",
30
+ llm=load_model(),
31
+ tools=tools,
32
+ )
33
+
34
+ # Define the Task
35
+ task = Task(
36
+ agent=agent,
37
+ description="Answer the users question: {prompt}",
38
+ expected_output="An answer to the users question",
39
+ )
40
+
41
+ # Create the Crew
42
+ crew = Crew(agents=[agent], tasks=[task], process=Process.sequential)
43
+
44
+ # Process the user prompt
45
+ prompt = payload.get("prompt", "What can you help me with?")
46
+
47
+ # Run the crew
48
+ result = crew.kickoff(inputs={"prompt": prompt})
49
+
50
+ # Return result
51
+ return {"result": result.raw}
52
+
53
+
54
+ if __name__ == "__main__":
55
+ app.run()
@@ -0,0 +1,133 @@
1
+ {{#if (eq modelProvider "Bedrock")}}
2
+ from crewai import LLM
3
+
4
+ # Uses global inference profile for Claude Sonnet 4.5
5
+ # https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
6
+ MODEL_ID = "bedrock/global.anthropic.claude-sonnet-4-5-20250929-v1:0"
7
+
8
+
9
+ def load_model() -> LLM:
10
+ """Get Bedrock model client using IAM credentials."""
11
+ return LLM(model=MODEL_ID)
12
+ {{/if}}
13
+ {{#if (eq modelProvider "Anthropic")}}
14
+ import os
15
+ from crewai import LLM
16
+ from bedrock_agentcore.identity.auth import requires_api_key
17
+
18
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
19
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
20
+
21
+
22
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
23
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
24
+ """Fetch API key from AgentCore Identity."""
25
+ return api_key
26
+
27
+
28
+ def _get_api_key() -> str:
29
+ """
30
+ Uses AgentCore Identity for API key management in deployed environments.
31
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
32
+ """
33
+ if os.getenv("LOCAL_DEV") == "1":
34
+ api_key = os.getenv(IDENTITY_ENV_VAR)
35
+ if not api_key:
36
+ raise RuntimeError(
37
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
38
+ )
39
+ return api_key
40
+ return _agentcore_identity_api_key_provider()
41
+
42
+
43
+ def load_model() -> LLM:
44
+ """Get authenticated Anthropic model client."""
45
+ api_key = _get_api_key()
46
+ # CrewAI requires ANTHROPIC_API_KEY env var (ignores api_key parameter)
47
+ os.environ["ANTHROPIC_API_KEY"] = api_key
48
+ return LLM(
49
+ model="anthropic/claude-sonnet-4-5-20250929",
50
+ api_key=api_key,
51
+ max_tokens=4096
52
+ )
53
+ {{/if}}
54
+ {{#if (eq modelProvider "OpenAI")}}
55
+ import os
56
+ from crewai import LLM
57
+ from bedrock_agentcore.identity.auth import requires_api_key
58
+
59
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
60
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
61
+
62
+
63
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
64
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
65
+ """Fetch API key from AgentCore Identity."""
66
+ return api_key
67
+
68
+
69
+ def _get_api_key() -> str:
70
+ """
71
+ Uses AgentCore Identity for API key management in deployed environments.
72
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
73
+ """
74
+ if os.getenv("LOCAL_DEV") == "1":
75
+ api_key = os.getenv(IDENTITY_ENV_VAR)
76
+ if not api_key:
77
+ raise RuntimeError(
78
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
79
+ )
80
+ return api_key
81
+ return _agentcore_identity_api_key_provider()
82
+
83
+
84
+ def load_model() -> LLM:
85
+ """Get authenticated OpenAI model client."""
86
+ api_key = _get_api_key()
87
+ # CrewAI requires OPENAI_API_KEY env var (ignores api_key parameter)
88
+ os.environ["OPENAI_API_KEY"] = api_key
89
+ return LLM(
90
+ model="openai/gpt-4o",
91
+ api_key=api_key
92
+ )
93
+ {{/if}}
94
+ {{#if (eq modelProvider "Gemini")}}
95
+ import os
96
+ from crewai import LLM
97
+ from bedrock_agentcore.identity.auth import requires_api_key
98
+
99
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
100
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
101
+
102
+
103
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
104
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
105
+ """Fetch API key from AgentCore Identity."""
106
+ return api_key
107
+
108
+
109
+ def _get_api_key() -> str:
110
+ """
111
+ Uses AgentCore Identity for API key management in deployed environments.
112
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
113
+ """
114
+ if os.getenv("LOCAL_DEV") == "1":
115
+ api_key = os.getenv(IDENTITY_ENV_VAR)
116
+ if not api_key:
117
+ raise RuntimeError(
118
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
119
+ )
120
+ return api_key
121
+ return _agentcore_identity_api_key_provider()
122
+
123
+
124
+ def load_model() -> LLM:
125
+ """Get authenticated Gemini model client."""
126
+ api_key = _get_api_key()
127
+ # CrewAI requires GEMINI_API_KEY env var (ignores api_key parameter)
128
+ os.environ["GEMINI_API_KEY"] = api_key
129
+ return LLM(
130
+ model="gemini/gemini-2.0-flash",
131
+ api_key=api_key
132
+ )
133
+ {{/if}}
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "{{ name }}"
7
+ version = "0.1.0"
8
+ description = "AgentCore Runtime Application using CrewAI SDK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ dependencies = [
12
+ "opentelemetry-distro",
13
+ "opentelemetry-exporter-otlp",
14
+ "bedrock-agentcore >= 1.0.3",
15
+ "botocore[crt] >= 1.35.0",
16
+ "python-dotenv >= 1.0.1",
17
+ {{#if (eq modelProvider "Bedrock")}}
18
+ "crewai[tools,bedrock] >= 1.3.0",
19
+ {{/if}}
20
+ {{#if (eq modelProvider "Anthropic")}}
21
+ "crewai[tools,anthropic] >= 1.3.0",
22
+ {{/if}}
23
+ {{#if (eq modelProvider "OpenAI")}}
24
+ "crewai[tools,openai] >= 1.3.0",
25
+ {{/if}}
26
+ {{#if (eq modelProvider "Gemini")}}
27
+ "crewai[tools,google-genai] >= 1.3.0",
28
+ {{/if}}
29
+ ]
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ packages = ["."]
@@ -0,0 +1,39 @@
1
+ This is a project generated by the agentcore create CLI tool!
2
+
3
+ # Layout
4
+
5
+ There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
+ `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
7
+ commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
8
+
9
+ ## src/
10
+
11
+ The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
12
+ file defines a Starlette ASGI app with the Google ADK framework running within.
13
+
14
+ `src/model/load.py` instantiates your chosen model provider (Gemini).
15
+
16
+ ## Environment Variables
17
+
18
+ | Variable | Required | Description |
19
+ | --------------------------- | -------- | ---------------------------------------------------------------- |
20
+ | `AGENTCORE_IDENTITY_GEMINI` | Yes | Gemini API key (local) or Identity provider name (deployed) |
21
+ | `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
22
+
23
+ # Developing locally
24
+
25
+ If installation was successful, a virtual environment is already created with dependencies installed.
26
+
27
+ Run `source .venv/bin/activate` before developing.
28
+
29
+ `agentcore dev` will start a local server on 0.0.0.0:8080.
30
+
31
+ In a new terminal, you can invoke that server with:
32
+
33
+ `agentcore invoke --dev "What can you do"`
34
+
35
+ # Deployment
36
+
37
+ After providing credentials, `agentcore deploy` will deploy your project into Amazon Bedrock AgentCore.
38
+
39
+ Use `agentcore invoke` to invoke your deployed agent.
@@ -0,0 +1,40 @@
1
+ # Environment variables
2
+ .env
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+ *.so
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Virtual environments
27
+ venv/
28
+ ENV/
29
+ env/
30
+
31
+ # IDE
32
+ .vscode/
33
+ .idea/
34
+ *.swp
35
+ *.swo
36
+ *~
37
+
38
+ # OS
39
+ .DS_Store
40
+ Thumbs.db
@@ -0,0 +1,84 @@
1
+ import os
2
+ from google.adk.agents import Agent
3
+ from google.adk.runners import Runner
4
+ from google.adk.sessions import InMemorySessionService
5
+ from google.genai import types
6
+ from bedrock_agentcore.runtime import BedrockAgentCoreApp
7
+ from model.load import load_model
8
+ from mcp_client.client import get_streamable_http_mcp_client
9
+
10
+ app = BedrockAgentCoreApp()
11
+ log = app.logger
12
+
13
+ APP_NAME = "{{ name }}"
14
+
15
+ # https://google.github.io/adk-docs/agents/models/
16
+ MODEL_ID = "gemini-2.5-flash"
17
+
18
+
19
+ # Define a simple function tool
20
+ def add_numbers(a: int, b: int) -> int:
21
+ """Return the sum of two numbers"""
22
+ return a + b
23
+
24
+
25
+ # Set environment variables for model authentication
26
+ load_model()
27
+
28
+ # Get MCP Toolset
29
+ mcp_toolset = [get_streamable_http_mcp_client()]
30
+
31
+ # Agent Definition
32
+ agent = Agent(
33
+ model=MODEL_ID,
34
+ name="{{ name }}",
35
+ description="Agent to answer questions",
36
+ instruction="I can answer your questions using the knowledge I have!",
37
+ tools=mcp_toolset + [add_numbers],
38
+ )
39
+
40
+
41
+ # Session and Runner
42
+ async def setup_session_and_runner(user_id, session_id):
43
+ session_service = InMemorySessionService()
44
+ session = await session_service.create_session(
45
+ app_name=APP_NAME, user_id=user_id, session_id=session_id
46
+ )
47
+ runner = Runner(agent=agent, app_name=APP_NAME, session_service=session_service)
48
+ return session, runner
49
+
50
+
51
+ # Agent Interaction
52
+ async def call_agent_async(query, user_id, session_id):
53
+ content = types.Content(role="user", parts=[types.Part(text=query)])
54
+ session, runner = await setup_session_and_runner(user_id, session_id)
55
+ events = runner.run_async(
56
+ user_id=user_id, session_id=session.id, new_message=content
57
+ )
58
+
59
+ final_response = None
60
+ async for event in events:
61
+ if event.is_final_response():
62
+ final_response = event.content.parts[0].text
63
+
64
+ return final_response
65
+
66
+
67
+ @app.entrypoint
68
+ async def invoke(payload, context):
69
+ log.info("Invoking Agent.....")
70
+
71
+ # Process the user prompt
72
+ prompt = payload.get("prompt", "What can you help me with?")
73
+ session_id = getattr(context, "session_id", "default_session")
74
+ user_id = payload.get("user_id", "default_user")
75
+
76
+ # Run the agent
77
+ result = await call_agent_async(prompt, user_id, session_id)
78
+
79
+ # Return result
80
+ return {"result": result}
81
+
82
+
83
+ if __name__ == "__main__":
84
+ app.run()
@@ -0,0 +1,15 @@
1
+ from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
2
+ from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
3
+
4
+ # ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
5
+ EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
6
+
7
+
8
+ def get_streamable_http_mcp_client() -> MCPToolset:
9
+ """
10
+ Returns an MCP Toolset compatible with Google ADK.
11
+ """
12
+ # to use an MCP server that supports bearer authentication, add headers={"Authorization": f"Bearer {access_token}"}
13
+ return MCPToolset(
14
+ connection_params=StreamableHTTPConnectionParams(url=EXAMPLE_MCP_ENDPOINT)
15
+ )
@@ -0,0 +1,41 @@
1
+ import os
2
+ from bedrock_agentcore.identity.auth import requires_api_key
3
+
4
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
5
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
6
+
7
+
8
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
9
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
10
+ """Fetch API key from AgentCore Identity."""
11
+ return api_key
12
+
13
+
14
+ def _get_api_key() -> str:
15
+ """
16
+ Uses AgentCore Identity for API key management in deployed environments.
17
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
18
+ """
19
+ if os.getenv("LOCAL_DEV") == "1":
20
+ api_key = os.getenv(IDENTITY_ENV_VAR)
21
+ if not api_key:
22
+ raise RuntimeError(
23
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
24
+ )
25
+ return api_key
26
+ return _agentcore_identity_api_key_provider()
27
+
28
+
29
+ def load_model() -> None:
30
+ """
31
+ Set up Gemini API key authentication.
32
+ Uses AgentCore Identity for API key management in deployed environments,
33
+ and falls back to .env file for local development.
34
+ Sets the GOOGLE_API_KEY environment variable for the Google ADK.
35
+ """
36
+ api_key = _get_api_key()
37
+ # Use Google AI Studios API Key Authentication.
38
+ # https://google.github.io/adk-docs/agents/models/#google-ai-studio
39
+ os.environ["GOOGLE_API_KEY"] = api_key
40
+ # Set to TRUE is using Google Vertex AI, Set to FALSE for Google AI Studio
41
+ os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "FALSE"
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "{{ name }}"
7
+ version = "0.1.0"
8
+ description = "AgentCore Runtime Application using Google ADK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "opentelemetry-distro",
13
+ "opentelemetry-exporter-otlp",
14
+ "google-adk >= 1.17.0",
15
+ "bedrock-agentcore >= 1.0.3",
16
+ "botocore[crt] >= 1.35.0",
17
+ "python-dotenv >= 1.0.1",
18
+ ]
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["."]
@@ -0,0 +1,41 @@
1
+ This is a project generated by the agentcore create CLI tool!
2
+
3
+ # Layout
4
+
5
+ There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
+ `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
7
+ commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
8
+
9
+ ## src/
10
+
11
+ The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
12
+ file defines a Starlette ASGI app with the LangChain/LangGraph framework running within.
13
+
14
+ `src/model/load.py` instantiates your chosen model provider.
15
+
16
+ ## Environment Variables
17
+
18
+ | Variable | Required | Description |
19
+ | ------------------------------ | --------------- | ---------------------------------------------------------------- |
20
+ | `AGENTCORE_IDENTITY_OPENAI` | Yes (OpenAI) | OpenAI API key (local) or Identity provider name (deployed) |
21
+ | `AGENTCORE_IDENTITY_ANTHROPIC` | Yes (Anthropic) | Anthropic API key (local) or Identity provider name (deployed) |
22
+ | `AGENTCORE_IDENTITY_GEMINI` | Yes (Gemini) | Gemini API key (local) or Identity provider name (deployed) |
23
+ | `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
24
+
25
+ # Developing locally
26
+
27
+ If installation was successful, a virtual environment is already created with dependencies installed.
28
+
29
+ Run `source .venv/bin/activate` before developing.
30
+
31
+ `agentcore dev` will start a local server on 0.0.0.0:8080.
32
+
33
+ In a new terminal, you can invoke that server with:
34
+
35
+ `agentcore invoke --dev "What can you do"`
36
+
37
+ # Deployment
38
+
39
+ After providing credentials, `agentcore deploy` will deploy your project into Amazon Bedrock AgentCore.
40
+
41
+ Use `agentcore invoke` to invoke your deployed agent.
@@ -0,0 +1,40 @@
1
+ # Environment variables
2
+ .env
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+ *.so
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Virtual environments
27
+ venv/
28
+ ENV/
29
+ env/
30
+
31
+ # IDE
32
+ .vscode/
33
+ .idea/
34
+ *.swp
35
+ *.swo
36
+ *~
37
+
38
+ # OS
39
+ .DS_Store
40
+ Thumbs.db
@@ -0,0 +1,51 @@
1
+ import os
2
+ from langchain_core.messages import HumanMessage
3
+ from langgraph.prebuilt import create_react_agent
4
+ from langchain.tools import tool
5
+ from bedrock_agentcore.runtime import BedrockAgentCoreApp
6
+ from model.load import load_model
7
+ from mcp_client.client import get_streamable_http_mcp_client
8
+
9
+ app = BedrockAgentCoreApp()
10
+ log = app.logger
11
+
12
+ # Instantiate model
13
+ llm = load_model()
14
+
15
+
16
+ # Define a simple function tool
17
+ @tool
18
+ def add_numbers(a: int, b: int) -> int:
19
+ """Return the sum of two numbers"""
20
+ return a + b
21
+
22
+
23
+ # Define a collection of tools used by the model
24
+ tools = [add_numbers]
25
+
26
+
27
+ @app.entrypoint
28
+ async def invoke(payload, context):
29
+ log.info("Invoking Agent.....")
30
+
31
+ # Get MCP Client
32
+ mcp_client = get_streamable_http_mcp_client()
33
+
34
+ # Load MCP Tools
35
+ mcp_tools = await mcp_client.get_tools()
36
+
37
+ # Define the agent using create_react_agent
38
+ graph = create_react_agent(llm, tools=mcp_tools + tools)
39
+
40
+ # Process the user prompt
41
+ prompt = payload.get("prompt", "What can you help me with?")
42
+
43
+ # Run the agent
44
+ result = await graph.ainvoke({"messages": [HumanMessage(content=prompt)]})
45
+
46
+ # Return result
47
+ return {"result": result["messages"][-1].content}
48
+
49
+
50
+ if __name__ == "__main__":
51
+ app.run()
@@ -0,0 +1,19 @@
1
+ from langchain_mcp_adapters.client import MultiServerMCPClient
2
+
3
+ # ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
4
+ EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
5
+
6
+
7
+ def get_streamable_http_mcp_client() -> MultiServerMCPClient:
8
+ """
9
+ Returns an MCP Client compatible with LangChain/LangGraph.
10
+ """
11
+ # to use an MCP server that supports bearer authentication, add headers={"Authorization": f"Bearer {access_token}"}
12
+ return MultiServerMCPClient(
13
+ {
14
+ "agentcore_gateway": {
15
+ "transport": "streamable_http",
16
+ "url": EXAMPLE_MCP_ENDPOINT,
17
+ }
18
+ }
19
+ )