@aws/agentcore 0.3.0-preview.5.0 → 0.3.0-preview.6.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 (119) hide show
  1. package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +1124 -97
  2. package/dist/assets/cdk/package.json +1 -1
  3. package/dist/assets/cdk/test/cdk.test.ts +2 -0
  4. package/dist/assets/python/a2a/googleadk/base/README.md +22 -0
  5. package/dist/assets/python/a2a/googleadk/base/main.py +48 -0
  6. package/dist/assets/python/a2a/googleadk/base/pyproject.toml +20 -0
  7. package/dist/assets/python/a2a/langchain_langgraph/base/README.md +22 -0
  8. package/dist/assets/python/a2a/langchain_langgraph/base/main.py +64 -0
  9. package/dist/assets/python/a2a/langchain_langgraph/base/pyproject.toml +24 -0
  10. package/dist/assets/python/a2a/strands/base/README.md +22 -0
  11. package/dist/assets/python/a2a/strands/base/main.py +44 -0
  12. package/dist/assets/python/a2a/strands/base/pyproject.toml +23 -0
  13. package/dist/assets/python/a2a/strands/capabilities/memory/session.py +38 -0
  14. package/dist/assets/python/{autogen → http/autogen}/base/mcp_client/client.py +10 -0
  15. package/dist/assets/python/http/googleadk/base/gitignore.template +41 -0
  16. package/dist/assets/python/{googleadk → http/googleadk}/base/mcp_client/client.py +9 -0
  17. package/dist/assets/python/http/googleadk/base/model/load.py +41 -0
  18. package/dist/assets/python/http/langchain_langgraph/base/gitignore.template +41 -0
  19. package/dist/assets/python/{langchain_langgraph → http/langchain_langgraph}/base/mcp_client/client.py +9 -0
  20. package/dist/assets/python/http/langchain_langgraph/base/model/load.py +123 -0
  21. package/dist/assets/python/http/openaiagents/base/gitignore.template +41 -0
  22. package/dist/assets/python/{openaiagents → http/openaiagents}/base/mcp_client/client.py +9 -0
  23. package/dist/assets/python/http/openaiagents/base/model/__init__.py +1 -0
  24. package/dist/assets/python/http/strands/base/mcp_client/__init__.py +1 -0
  25. package/dist/assets/python/{strands → http/strands}/base/mcp_client/client.py +9 -0
  26. package/dist/assets/python/http/strands/base/model/__init__.py +1 -0
  27. package/dist/assets/python/http/strands/base/model/load.py +123 -0
  28. package/dist/assets/python/http/strands/capabilities/memory/__init__.py +1 -0
  29. package/dist/assets/python/mcp/standalone/base/README.md +36 -0
  30. package/dist/assets/python/mcp/standalone/base/gitignore.template +41 -0
  31. package/dist/assets/python/mcp/standalone/base/main.py +25 -0
  32. package/dist/assets/python/mcp/standalone/base/pyproject.toml +16 -0
  33. package/dist/cli/index.mjs +359 -321
  34. package/dist/lib/packaging/helpers.js +2 -2
  35. package/dist/lib/packaging/helpers.js.map +1 -1
  36. package/dist/lib/utils/index.d.ts +1 -0
  37. package/dist/lib/utils/index.d.ts.map +1 -1
  38. package/dist/lib/utils/index.js +3 -1
  39. package/dist/lib/utils/index.js.map +1 -1
  40. package/dist/lib/utils/json-rpc.d.ts +3 -0
  41. package/dist/lib/utils/json-rpc.d.ts.map +1 -0
  42. package/dist/lib/utils/json-rpc.js +27 -0
  43. package/dist/lib/utils/json-rpc.js.map +1 -0
  44. package/dist/schema/constants.d.ts +20 -1
  45. package/dist/schema/constants.d.ts.map +1 -1
  46. package/dist/schema/constants.js +29 -2
  47. package/dist/schema/constants.js.map +1 -1
  48. package/dist/schema/schemas/agent-env.d.ts +20 -2
  49. package/dist/schema/schemas/agent-env.d.ts.map +1 -1
  50. package/dist/schema/schemas/agent-env.js +37 -2
  51. package/dist/schema/schemas/agent-env.js.map +1 -1
  52. package/dist/schema/schemas/agentcore-project.d.ts +82 -1
  53. package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
  54. package/dist/schema/schemas/agentcore-project.js +59 -2
  55. package/dist/schema/schemas/agentcore-project.js.map +1 -1
  56. package/dist/schema/schemas/deployed-state.d.ts +62 -0
  57. package/dist/schema/schemas/deployed-state.d.ts.map +1 -1
  58. package/dist/schema/schemas/deployed-state.js +18 -1
  59. package/dist/schema/schemas/deployed-state.js.map +1 -1
  60. package/dist/schema/schemas/mcp.d.ts +25 -10
  61. package/dist/schema/schemas/mcp.d.ts.map +1 -1
  62. package/dist/schema/schemas/mcp.js +9 -1
  63. package/dist/schema/schemas/mcp.js.map +1 -1
  64. package/dist/schema/schemas/primitives/evaluator.d.ts +68 -0
  65. package/dist/schema/schemas/primitives/evaluator.d.ts.map +1 -0
  66. package/dist/schema/schemas/primitives/evaluator.js +58 -0
  67. package/dist/schema/schemas/primitives/evaluator.js.map +1 -0
  68. package/dist/schema/schemas/primitives/index.d.ts +4 -0
  69. package/dist/schema/schemas/primitives/index.d.ts.map +1 -1
  70. package/dist/schema/schemas/primitives/index.js +14 -1
  71. package/dist/schema/schemas/primitives/index.js.map +1 -1
  72. package/dist/schema/schemas/primitives/online-eval-config.d.ts +13 -0
  73. package/dist/schema/schemas/primitives/online-eval-config.d.ts.map +1 -0
  74. package/dist/schema/schemas/primitives/online-eval-config.js +27 -0
  75. package/dist/schema/schemas/primitives/online-eval-config.js.map +1 -0
  76. package/package.json +11 -5
  77. /package/dist/assets/python/{autogen → a2a/googleadk}/base/gitignore.template +0 -0
  78. /package/dist/assets/python/{autogen/base/mcp_client → a2a/googleadk/base/model}/__init__.py +0 -0
  79. /package/dist/assets/python/{googleadk → a2a/googleadk}/base/model/load.py +0 -0
  80. /package/dist/assets/python/{crewai → a2a/langchain_langgraph}/base/gitignore.template +0 -0
  81. /package/dist/assets/python/{autogen → a2a/langchain_langgraph}/base/model/__init__.py +0 -0
  82. /package/dist/assets/python/{langchain_langgraph → a2a/langchain_langgraph}/base/model/load.py +0 -0
  83. /package/dist/assets/python/{googleadk → a2a/strands}/base/gitignore.template +0 -0
  84. /package/dist/assets/python/{crewai → a2a/strands}/base/model/__init__.py +0 -0
  85. /package/dist/assets/python/{strands → a2a/strands}/base/model/load.py +0 -0
  86. /package/dist/assets/python/{googleadk/base/mcp_client → a2a/strands/capabilities/memory}/__init__.py +0 -0
  87. /package/dist/assets/python/{autogen → http/autogen}/base/README.md +0 -0
  88. /package/dist/assets/python/{langchain_langgraph → http/autogen}/base/gitignore.template +0 -0
  89. /package/dist/assets/python/{autogen → http/autogen}/base/main.py +0 -0
  90. /package/dist/assets/python/{googleadk/base/model → http/autogen/base/mcp_client}/__init__.py +0 -0
  91. /package/dist/assets/python/{langchain_langgraph/base/mcp_client → http/autogen/base/model}/__init__.py +0 -0
  92. /package/dist/assets/python/{autogen → http/autogen}/base/model/load.py +0 -0
  93. /package/dist/assets/python/{autogen → http/autogen}/base/pyproject.toml +0 -0
  94. /package/dist/assets/python/{crewai → http/crewai}/base/README.md +0 -0
  95. /package/dist/assets/python/{openaiagents → http/crewai}/base/gitignore.template +0 -0
  96. /package/dist/assets/python/{crewai → http/crewai}/base/main.py +0 -0
  97. /package/dist/assets/python/{langchain_langgraph → http/crewai}/base/model/__init__.py +0 -0
  98. /package/dist/assets/python/{crewai → http/crewai}/base/model/load.py +0 -0
  99. /package/dist/assets/python/{crewai → http/crewai}/base/pyproject.toml +0 -0
  100. /package/dist/assets/python/{googleadk → http/googleadk}/base/README.md +0 -0
  101. /package/dist/assets/python/{googleadk → http/googleadk}/base/main.py +0 -0
  102. /package/dist/assets/python/{openaiagents → http/googleadk}/base/mcp_client/__init__.py +0 -0
  103. /package/dist/assets/python/{openaiagents → http/googleadk}/base/model/__init__.py +0 -0
  104. /package/dist/assets/python/{googleadk → http/googleadk}/base/pyproject.toml +0 -0
  105. /package/dist/assets/python/{langchain_langgraph → http/langchain_langgraph}/base/README.md +0 -0
  106. /package/dist/assets/python/{langchain_langgraph → http/langchain_langgraph}/base/main.py +0 -0
  107. /package/dist/assets/python/{strands → http/langchain_langgraph}/base/mcp_client/__init__.py +0 -0
  108. /package/dist/assets/python/{strands → http/langchain_langgraph}/base/model/__init__.py +0 -0
  109. /package/dist/assets/python/{langchain_langgraph → http/langchain_langgraph}/base/pyproject.toml +0 -0
  110. /package/dist/assets/python/{openaiagents → http/openaiagents}/base/README.md +0 -0
  111. /package/dist/assets/python/{openaiagents → http/openaiagents}/base/main.py +0 -0
  112. /package/dist/assets/python/{strands/capabilities/memory → http/openaiagents/base/mcp_client}/__init__.py +0 -0
  113. /package/dist/assets/python/{openaiagents → http/openaiagents}/base/model/load.py +0 -0
  114. /package/dist/assets/python/{openaiagents → http/openaiagents}/base/pyproject.toml +0 -0
  115. /package/dist/assets/python/{strands → http/strands}/base/README.md +0 -0
  116. /package/dist/assets/python/{strands → http/strands}/base/gitignore.template +0 -0
  117. /package/dist/assets/python/{strands → http/strands}/base/main.py +0 -0
  118. /package/dist/assets/python/{strands → http/strands}/base/pyproject.toml +0 -0
  119. /package/dist/assets/python/{strands → http/strands}/capabilities/memory/session.py +0 -0
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@aws/agentcore-cdk": "^0.1.0-alpha.1",
27
- "aws-cdk-lib": "2.239.0",
27
+ "aws-cdk-lib": "2.243.0",
28
28
  "constructs": "^10.0.0"
29
29
  }
30
30
  }
@@ -11,6 +11,8 @@ test('AgentCoreStack synthesizes with empty spec', () => {
11
11
  agents: [],
12
12
  memories: [],
13
13
  credentials: [],
14
+ evaluators: [],
15
+ onlineEvalConfigs: [],
14
16
  },
15
17
  });
16
18
  const template = Template.fromStack(stack);
@@ -0,0 +1,22 @@
1
+ # {{ name }}
2
+
3
+ An A2A (Agent-to-Agent) agent deployed on Amazon Bedrock AgentCore using Google ADK.
4
+
5
+ ## Overview
6
+
7
+ This agent implements the A2A protocol using Google's Agent Development Kit, enabling agent-to-agent communication.
8
+
9
+ ## Local Development
10
+
11
+ ```bash
12
+ uv sync
13
+ uv run python main.py
14
+ ```
15
+
16
+ The agent starts on port 9000.
17
+
18
+ ## Deploy
19
+
20
+ ```bash
21
+ agentcore deploy
22
+ ```
@@ -0,0 +1,48 @@
1
+ from google.adk.agents import Agent
2
+ from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
3
+ from google.adk.runners import Runner
4
+ from google.adk.sessions import InMemorySessionService
5
+ from a2a.types import AgentCapabilities, AgentCard, AgentSkill
6
+ from bedrock_agentcore.runtime import serve_a2a
7
+ from model.load import load_model
8
+
9
+
10
+ def add_numbers(a: int, b: int) -> int:
11
+ """Return the sum of two numbers."""
12
+ return a + b
13
+
14
+
15
+ agent = Agent(
16
+ model=load_model(),
17
+ name="{{ name }}",
18
+ description="A helpful assistant that can use tools.",
19
+ instruction="You are a helpful assistant. Use tools when appropriate.",
20
+ tools=[add_numbers],
21
+ )
22
+
23
+ runner = Runner(
24
+ app_name=agent.name,
25
+ agent=agent,
26
+ session_service=InMemorySessionService(),
27
+ )
28
+
29
+ card = AgentCard(
30
+ name=agent.name,
31
+ description=agent.description,
32
+ url="http://localhost:9000/",
33
+ version="0.1.0",
34
+ capabilities=AgentCapabilities(streaming=True),
35
+ skills=[
36
+ AgentSkill(
37
+ id="tools",
38
+ name="tools",
39
+ description="Use tools to help answer questions",
40
+ tags=["tools"],
41
+ )
42
+ ],
43
+ default_input_modes=["text"],
44
+ default_output_modes=["text"],
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ serve_a2a(A2aAgentExecutor(runner=runner), card)
@@ -0,0 +1,20 @@
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 A2A Agent using Google ADK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "a2a-sdk >= 0.2.0",
13
+ "aws-opentelemetry-distro",
14
+ "bedrock-agentcore[a2a] >= 1.0.3",
15
+ "google-adk >= 1.0.0",
16
+ "google-genai >= 1.0.0",
17
+ ]
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ packages = ["."]
@@ -0,0 +1,22 @@
1
+ # {{ name }}
2
+
3
+ An A2A (Agent-to-Agent) agent deployed on Amazon Bedrock AgentCore using LangChain + LangGraph.
4
+
5
+ ## Overview
6
+
7
+ This agent implements the A2A protocol using LangGraph, enabling agent-to-agent communication.
8
+
9
+ ## Local Development
10
+
11
+ ```bash
12
+ uv sync
13
+ uv run python main.py
14
+ ```
15
+
16
+ The agent starts on port 9000.
17
+
18
+ ## Deploy
19
+
20
+ ```bash
21
+ agentcore deploy
22
+ ```
@@ -0,0 +1,64 @@
1
+ from langchain_core.tools import tool
2
+ from langgraph.prebuilt import create_react_agent
3
+ from a2a.server.agent_execution import AgentExecutor, RequestContext
4
+ from a2a.server.events import EventQueue
5
+ from a2a.server.tasks import TaskUpdater
6
+ from a2a.types import AgentCapabilities, AgentCard, AgentSkill, Part, TextPart
7
+ from a2a.utils import new_task
8
+ from bedrock_agentcore.runtime import serve_a2a
9
+ from model.load import load_model
10
+
11
+
12
+ @tool
13
+ def add_numbers(a: int, b: int) -> int:
14
+ """Return the sum of two numbers."""
15
+ return a + b
16
+
17
+
18
+ model = load_model()
19
+ graph = create_react_agent(model, tools=[add_numbers])
20
+
21
+
22
+ class LangGraphA2AExecutor(AgentExecutor):
23
+ """Wraps a LangGraph CompiledGraph as an a2a-sdk AgentExecutor."""
24
+
25
+ def __init__(self, graph):
26
+ self.graph = graph
27
+
28
+ async def execute(self, context: RequestContext, event_queue: EventQueue) -> None:
29
+ task = context.current_task or new_task(context.message)
30
+ if not context.current_task:
31
+ await event_queue.enqueue_event(task)
32
+ updater = TaskUpdater(event_queue, task.id, task.context_id)
33
+
34
+ user_text = context.get_user_input()
35
+ result = await self.graph.ainvoke({"messages": [("user", user_text)]})
36
+ response = result["messages"][-1].content
37
+
38
+ await updater.add_artifact([Part(root=TextPart(text=response))])
39
+ await updater.complete()
40
+
41
+ async def cancel(self, context: RequestContext, event_queue: EventQueue) -> None:
42
+ pass
43
+
44
+
45
+ card = AgentCard(
46
+ name="{{ name }}",
47
+ description="A LangGraph agent on Bedrock AgentCore",
48
+ url="http://localhost:9000/",
49
+ version="0.1.0",
50
+ capabilities=AgentCapabilities(streaming=True),
51
+ skills=[
52
+ AgentSkill(
53
+ id="tools",
54
+ name="tools",
55
+ description="Use tools to help answer questions",
56
+ tags=["tools"],
57
+ )
58
+ ],
59
+ default_input_modes=["text"],
60
+ default_output_modes=["text"],
61
+ )
62
+
63
+ if __name__ == "__main__":
64
+ serve_a2a(LangGraphA2AExecutor(graph), card)
@@ -0,0 +1,24 @@
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 A2A Agent using LangChain + LangGraph"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "a2a-sdk >= 0.2.0",
13
+ {{#if (eq modelProvider "Anthropic")}}"langchain-anthropic >= 0.3.0",
14
+ {{/if}}{{#if (eq modelProvider "Bedrock")}}"langchain-aws >= 0.2.0",
15
+ {{/if}}{{#if (eq modelProvider "Gemini")}}"langchain-google-genai >= 2.0.0",
16
+ {{/if}}{{#if (eq modelProvider "OpenAI")}}"langchain-openai >= 0.2.0",
17
+ {{/if}}"aws-opentelemetry-distro",
18
+ "bedrock-agentcore[a2a] >= 1.0.3",
19
+ "botocore[crt] >= 1.35.0",
20
+ "langgraph >= 0.2.0",
21
+ ]
22
+
23
+ [tool.hatch.build.targets.wheel]
24
+ packages = ["."]
@@ -0,0 +1,22 @@
1
+ # {{ name }}
2
+
3
+ An A2A (Agent-to-Agent) agent deployed on Amazon Bedrock AgentCore using Strands SDK.
4
+
5
+ ## Overview
6
+
7
+ This agent implements the A2A protocol, enabling agent-to-agent communication. Other agents can discover and interact with this agent via the `/.well-known/agent-card.json` endpoint.
8
+
9
+ ## Local Development
10
+
11
+ ```bash
12
+ uv sync
13
+ uv run python main.py
14
+ ```
15
+
16
+ The agent starts on port 9000.
17
+
18
+ ## Deploy
19
+
20
+ ```bash
21
+ agentcore deploy
22
+ ```
@@ -0,0 +1,44 @@
1
+ from strands import Agent, tool
2
+ from strands.multiagent.a2a.executor import StrandsA2AExecutor
3
+ from bedrock_agentcore.runtime import serve_a2a
4
+ from model.load import load_model
5
+ {{#if hasMemory}}
6
+ from memory.session import get_memory_session_manager
7
+ {{/if}}
8
+
9
+
10
+ @tool
11
+ def add_numbers(a: int, b: int) -> int:
12
+ """Return the sum of two numbers."""
13
+ return a + b
14
+
15
+
16
+ tools = [add_numbers]
17
+
18
+ {{#if hasMemory}}
19
+ def agent_factory():
20
+ cache = {}
21
+ def get_or_create_agent(session_id, user_id):
22
+ key = f"{session_id}/{user_id}"
23
+ if key not in cache:
24
+ cache[key] = Agent(
25
+ model=load_model(),
26
+ session_manager=get_memory_session_manager(session_id, user_id),
27
+ system_prompt="You are a helpful assistant. Use tools when appropriate.",
28
+ tools=tools,
29
+ )
30
+ return cache[key]
31
+ return get_or_create_agent
32
+
33
+ get_or_create_agent = agent_factory()
34
+ agent = get_or_create_agent("default-session", "default-user")
35
+ {{else}}
36
+ agent = Agent(
37
+ model=load_model(),
38
+ system_prompt="You are a helpful assistant. Use tools when appropriate.",
39
+ tools=tools,
40
+ )
41
+ {{/if}}
42
+
43
+ if __name__ == "__main__":
44
+ serve_a2a(StrandsA2AExecutor(agent))
@@ -0,0 +1,23 @@
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 A2A Agent using Strands SDK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ {{#if (eq modelProvider "Anthropic")}}"anthropic >= 0.30.0",
13
+ {{/if}}"a2a-sdk[all] >= 0.2.0",
14
+ "aws-opentelemetry-distro",
15
+ "bedrock-agentcore[a2a] >= 1.0.3",
16
+ "botocore[crt] >= 1.35.0",
17
+ {{#if (eq modelProvider "Gemini")}}"google-genai >= 1.0.0",
18
+ {{/if}}{{#if (eq modelProvider "OpenAI")}}"openai >= 1.0.0",
19
+ {{/if}}"strands-agents >= 1.13.0",
20
+ ]
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["."]
@@ -0,0 +1,38 @@
1
+ import os
2
+ from typing import Optional
3
+
4
+ from bedrock_agentcore.memory.integrations.strands.config import AgentCoreMemoryConfig{{#if memoryProviders.[0].strategies.length}}, RetrievalConfig{{/if}}
5
+ from bedrock_agentcore.memory.integrations.strands.session_manager import AgentCoreMemorySessionManager
6
+
7
+ MEMORY_ID = os.getenv("{{memoryProviders.[0].envVarName}}")
8
+ REGION = os.getenv("AWS_REGION")
9
+
10
+ def get_memory_session_manager(session_id: str, actor_id: str) -> Optional[AgentCoreMemorySessionManager]:
11
+ if not MEMORY_ID:
12
+ return None
13
+
14
+ {{#if memoryProviders.[0].strategies.length}}
15
+ retrieval_config = {
16
+ {{#if (includes memoryProviders.[0].strategies "SEMANTIC")}}
17
+ f"/users/{actor_id}/facts": RetrievalConfig(top_k=3, relevance_score=0.5),
18
+ {{/if}}
19
+ {{#if (includes memoryProviders.[0].strategies "USER_PREFERENCE")}}
20
+ f"/users/{actor_id}/preferences": RetrievalConfig(top_k=3, relevance_score=0.5),
21
+ {{/if}}
22
+ {{#if (includes memoryProviders.[0].strategies "SUMMARIZATION")}}
23
+ f"/summaries/{actor_id}/{session_id}": RetrievalConfig(top_k=3, relevance_score=0.5),
24
+ {{/if}}
25
+ }
26
+ {{/if}}
27
+
28
+ return AgentCoreMemorySessionManager(
29
+ AgentCoreMemoryConfig(
30
+ memory_id=MEMORY_ID,
31
+ session_id=session_id,
32
+ actor_id=actor_id,
33
+ {{#if memoryProviders.[0].strategies.length}}
34
+ retrieval_config=retrieval_config,
35
+ {{/if}}
36
+ ),
37
+ REGION
38
+ )
@@ -1,4 +1,13 @@
1
1
  from typing import List
2
+ {{#if isVpc}}
3
+ # VPC mode: external MCP endpoints are not reachable without a NAT gateway.
4
+ # Add an AgentCore Gateway with `agentcore add gateway`, or configure your own endpoint below.
5
+
6
+
7
+ async def get_streamable_http_mcp_tools() -> List:
8
+ """No MCP server configured. Add a gateway with `agentcore add gateway`."""
9
+ return []
10
+ {{else}}
2
11
  from autogen_ext.tools.mcp import (
3
12
  StreamableHttpMcpToolAdapter,
4
13
  StreamableHttpServerParams,
@@ -16,3 +25,4 @@ async def get_streamable_http_mcp_tools() -> List[StreamableHttpMcpToolAdapter]:
16
25
  # to use an MCP server that supports bearer authentication, add headers={"Authorization": f"Bearer {access_token}"}
17
26
  server_params = StreamableHttpServerParams(url=EXAMPLE_MCP_ENDPOINT)
18
27
  return await mcp_server_tools(server_params)
28
+ {{/if}}
@@ -0,0 +1,41 @@
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
+ venv/
29
+ ENV/
30
+ env/
31
+
32
+ # IDE
33
+ .vscode/
34
+ .idea/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
@@ -53,6 +53,14 @@ def get_all_gateway_mcp_toolsets() -> list[MCPToolset]:
53
53
  {{/each}}
54
54
  return toolsets
55
55
  {{else}}
56
+ {{#if isVpc}}
57
+ # VPC mode: external MCP endpoints are not reachable without a NAT gateway.
58
+ # Add an AgentCore Gateway with `agentcore add gateway`, or configure your own endpoint below.
59
+
60
+ def get_streamable_http_mcp_client() -> MCPToolset | None:
61
+ """No MCP server configured. Add a gateway with `agentcore add gateway`."""
62
+ return None
63
+ {{else}}
56
64
  # ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
57
65
  EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
58
66
 
@@ -64,3 +72,4 @@ def get_streamable_http_mcp_client() -> MCPToolset:
64
72
  connection_params=StreamableHTTPConnectionParams(url=EXAMPLE_MCP_ENDPOINT)
65
73
  )
66
74
  {{/if}}
75
+ {{/if}}
@@ -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,41 @@
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
+ venv/
29
+ ENV/
30
+ env/
31
+
32
+ # IDE
33
+ .vscode/
34
+ .idea/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
@@ -50,6 +50,14 @@ def get_all_gateway_mcp_client() -> MultiServerMCPClient | None:
50
50
  return None
51
51
  return MultiServerMCPClient(servers)
52
52
  {{else}}
53
+ {{#if isVpc}}
54
+ # VPC mode: external MCP endpoints are not reachable without a NAT gateway.
55
+ # Add an AgentCore Gateway with `agentcore add gateway`, or configure your own endpoint below.
56
+
57
+ def get_streamable_http_mcp_client() -> MultiServerMCPClient | None:
58
+ """No MCP server configured. Add a gateway with `agentcore add gateway`."""
59
+ return None
60
+ {{else}}
53
61
  # ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
54
62
  EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
55
63
 
@@ -66,3 +74,4 @@ def get_streamable_http_mcp_client() -> MultiServerMCPClient:
66
74
  }
67
75
  )
68
76
  {{/if}}
77
+ {{/if}}
@@ -0,0 +1,123 @@
1
+ {{#if (eq modelProvider "Bedrock")}}
2
+ from langchain_aws import ChatBedrock
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 = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
7
+
8
+
9
+ def load_model() -> ChatBedrock:
10
+ """Get Bedrock model client using IAM credentials."""
11
+ return ChatBedrock(model_id=MODEL_ID)
12
+ {{/if}}
13
+ {{#if (eq modelProvider "Anthropic")}}
14
+ import os
15
+ from langchain_anthropic import ChatAnthropic
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() -> ChatAnthropic:
44
+ """Get authenticated Anthropic model client."""
45
+ return ChatAnthropic(
46
+ model="claude-sonnet-4-5-20250929",
47
+ api_key=_get_api_key()
48
+ )
49
+ {{/if}}
50
+ {{#if (eq modelProvider "OpenAI")}}
51
+ import os
52
+ from langchain_openai import ChatOpenAI
53
+ from bedrock_agentcore.identity.auth import requires_api_key
54
+
55
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
56
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
57
+
58
+
59
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
60
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
61
+ """Fetch API key from AgentCore Identity."""
62
+ return api_key
63
+
64
+
65
+ def _get_api_key() -> str:
66
+ """
67
+ Uses AgentCore Identity for API key management in deployed environments.
68
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
69
+ """
70
+ if os.getenv("LOCAL_DEV") == "1":
71
+ api_key = os.getenv(IDENTITY_ENV_VAR)
72
+ if not api_key:
73
+ raise RuntimeError(
74
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
75
+ )
76
+ return api_key
77
+ return _agentcore_identity_api_key_provider()
78
+
79
+
80
+ def load_model() -> ChatOpenAI:
81
+ """Get authenticated OpenAI model client."""
82
+ return ChatOpenAI(
83
+ model="gpt-4.1",
84
+ api_key=_get_api_key()
85
+ )
86
+ {{/if}}
87
+ {{#if (eq modelProvider "Gemini")}}
88
+ import os
89
+ from langchain_google_genai import ChatGoogleGenerativeAI
90
+ from bedrock_agentcore.identity.auth import requires_api_key
91
+
92
+ IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
93
+ IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
94
+
95
+
96
+ @requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
97
+ def _agentcore_identity_api_key_provider(api_key: str) -> str:
98
+ """Fetch API key from AgentCore Identity."""
99
+ return api_key
100
+
101
+
102
+ def _get_api_key() -> str:
103
+ """
104
+ Uses AgentCore Identity for API key management in deployed environments.
105
+ For local development, run via 'agentcore dev' which loads agentcore/.env.
106
+ """
107
+ if os.getenv("LOCAL_DEV") == "1":
108
+ api_key = os.getenv(IDENTITY_ENV_VAR)
109
+ if not api_key:
110
+ raise RuntimeError(
111
+ f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
112
+ )
113
+ return api_key
114
+ return _agentcore_identity_api_key_provider()
115
+
116
+
117
+ def load_model() -> ChatGoogleGenerativeAI:
118
+ """Get authenticated Gemini model client."""
119
+ return ChatGoogleGenerativeAI(
120
+ model="gemini-2.5-flash",
121
+ api_key=_get_api_key()
122
+ )
123
+ {{/if}}