@aws/agentcore 0.3.0-preview.2.1 → 0.3.0-preview.3.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.
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +415 -58
- package/dist/assets/cdk/README.md +19 -7
- package/dist/assets/cdk/bin/cdk.ts +37 -2
- package/dist/assets/cdk/lib/cdk-stack.ts +25 -2
- package/dist/assets/cdk/package.json +1 -1
- package/dist/assets/cdk/test/cdk.test.ts +18 -14
- package/dist/assets/cdk/tsconfig.json +4 -4
- package/dist/assets/container/python/Dockerfile +7 -1
- package/dist/assets/python/googleadk/base/main.py +10 -1
- package/dist/assets/python/googleadk/base/mcp_client/client.py +54 -3
- package/dist/assets/python/googleadk/base/pyproject.toml +2 -0
- package/dist/assets/python/langchain_langgraph/base/main.py +11 -1
- package/dist/assets/python/langchain_langgraph/base/mcp_client/client.py +52 -3
- package/dist/assets/python/langchain_langgraph/base/pyproject.toml +2 -1
- package/dist/assets/python/openaiagents/base/main.py +43 -3
- package/dist/assets/python/openaiagents/base/mcp_client/client.py +54 -3
- package/dist/assets/python/openaiagents/base/pyproject.toml +2 -0
- package/dist/assets/python/strands/base/README.md +1 -1
- package/dist/assets/python/strands/base/main.py +16 -3
- package/dist/assets/python/strands/base/mcp_client/client.py +56 -4
- package/dist/assets/python/strands/base/pyproject.toml +2 -0
- package/dist/cli/index.mjs +290 -286
- package/dist/lib/packaging/build-args.d.ts +6 -0
- package/dist/lib/packaging/build-args.d.ts.map +1 -0
- package/dist/lib/packaging/build-args.js +18 -0
- package/dist/lib/packaging/build-args.js.map +1 -0
- package/dist/lib/packaging/container.d.ts.map +1 -1
- package/dist/lib/packaging/container.js +2 -1
- package/dist/lib/packaging/container.js.map +1 -1
- package/dist/lib/schemas/io/cli-config.d.ts +10 -0
- package/dist/lib/schemas/io/cli-config.d.ts.map +1 -0
- package/dist/lib/schemas/io/cli-config.js +27 -0
- package/dist/lib/schemas/io/cli-config.js.map +1 -0
- package/dist/lib/schemas/io/index.d.ts +1 -0
- package/dist/lib/schemas/io/index.d.ts.map +1 -1
- package/dist/lib/schemas/io/index.js +3 -1
- package/dist/lib/schemas/io/index.js.map +1 -1
- package/dist/lib/utils/subprocess.d.ts.map +1 -1
- package/dist/lib/utils/subprocess.js +32 -10
- package/dist/lib/utils/subprocess.js.map +1 -1
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +0 -1
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +48 -5
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +19 -4
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/aws-targets.js +1 -1
- package/dist/schema/schemas/aws-targets.js.map +1 -1
- package/dist/schema/schemas/deployed-state.d.ts +32 -0
- package/dist/schema/schemas/deployed-state.d.ts.map +1 -1
- package/dist/schema/schemas/deployed-state.js +11 -1
- package/dist/schema/schemas/deployed-state.js.map +1 -1
- package/dist/schema/schemas/mcp-defs.d.ts +1 -1
- package/dist/schema/schemas/mcp-defs.js +1 -1
- package/dist/schema/schemas/mcp.d.ts +146 -6
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +49 -4
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/package.json +12 -6
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
from strands import Agent, tool
|
|
2
2
|
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
|
3
3
|
from model.load import load_model
|
|
4
|
+
{{#if hasGateway}}
|
|
5
|
+
from mcp_client.client import get_all_gateway_mcp_clients
|
|
6
|
+
{{else}}
|
|
4
7
|
from mcp_client.client import get_streamable_http_mcp_client
|
|
8
|
+
{{/if}}
|
|
5
9
|
{{#if hasMemory}}
|
|
6
10
|
from memory.session import get_memory_session_manager
|
|
7
11
|
{{/if}}
|
|
@@ -10,7 +14,11 @@ app = BedrockAgentCoreApp()
|
|
|
10
14
|
log = app.logger
|
|
11
15
|
|
|
12
16
|
# Define a Streamable HTTP MCP Client
|
|
13
|
-
|
|
17
|
+
{{#if hasGateway}}
|
|
18
|
+
mcp_clients = get_all_gateway_mcp_clients()
|
|
19
|
+
{{else}}
|
|
20
|
+
mcp_clients = [get_streamable_http_mcp_client()]
|
|
21
|
+
{{/if}}
|
|
14
22
|
|
|
15
23
|
# Define a collection of tools used by the model
|
|
16
24
|
tools = []
|
|
@@ -22,6 +30,11 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
22
30
|
return a+b
|
|
23
31
|
tools.append(add_numbers)
|
|
24
32
|
|
|
33
|
+
# Add MCP client to tools if available
|
|
34
|
+
for mcp_client in mcp_clients:
|
|
35
|
+
if mcp_client:
|
|
36
|
+
tools.append(mcp_client)
|
|
37
|
+
|
|
25
38
|
|
|
26
39
|
{{#if hasMemory}}
|
|
27
40
|
def agent_factory():
|
|
@@ -36,7 +49,7 @@ def agent_factory():
|
|
|
36
49
|
system_prompt="""
|
|
37
50
|
You are a helpful assistant. Use tools when appropriate.
|
|
38
51
|
""",
|
|
39
|
-
tools=tools
|
|
52
|
+
tools=tools
|
|
40
53
|
)
|
|
41
54
|
return cache[key]
|
|
42
55
|
return get_or_create_agent
|
|
@@ -52,7 +65,7 @@ def get_or_create_agent():
|
|
|
52
65
|
system_prompt="""
|
|
53
66
|
You are a helpful assistant. Use tools when appropriate.
|
|
54
67
|
""",
|
|
55
|
-
tools=tools
|
|
68
|
+
tools=tools
|
|
56
69
|
)
|
|
57
70
|
return _agent
|
|
58
71
|
{{/if}}
|
|
@@ -1,12 +1,64 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
1
3
|
from mcp.client.streamable_http import streamablehttp_client
|
|
2
4
|
from strands.tools.mcp.mcp_client import MCPClient
|
|
3
5
|
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
{{#if hasGateway}}
|
|
9
|
+
{{#if (includes gatewayAuthTypes "AWS_IAM")}}
|
|
10
|
+
from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if (includes gatewayAuthTypes "CUSTOM_JWT")}}
|
|
13
|
+
from bedrock_agentcore.identity import requires_access_token
|
|
14
|
+
{{/if}}
|
|
15
|
+
|
|
16
|
+
{{#each gatewayProviders}}
|
|
17
|
+
{{#if (eq authType "CUSTOM_JWT")}}
|
|
18
|
+
@requires_access_token(
|
|
19
|
+
provider_name="{{credentialProviderName}}",
|
|
20
|
+
scopes=[{{#if scopes}}"{{scopes}}"{{/if}}],
|
|
21
|
+
auth_flow="M2M",
|
|
22
|
+
)
|
|
23
|
+
def _get_bearer_token_{{snakeCase name}}(*, access_token: str):
|
|
24
|
+
"""Obtain OAuth access token via AgentCore Identity for {{name}}."""
|
|
25
|
+
return access_token
|
|
26
|
+
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{/each}}
|
|
29
|
+
{{#each gatewayProviders}}
|
|
30
|
+
def get_{{snakeCase name}}_mcp_client() -> MCPClient | None:
|
|
31
|
+
"""Returns an MCP Client connected to the {{name}} gateway."""
|
|
32
|
+
url = os.environ.get("{{envVarName}}")
|
|
33
|
+
if not url:
|
|
34
|
+
logger.warning("{{envVarName}} not set — {{name}} gateway tools unavailable")
|
|
35
|
+
return None
|
|
36
|
+
{{#if (eq authType "AWS_IAM")}}
|
|
37
|
+
return MCPClient(lambda: aws_iam_streamablehttp_client(url, aws_service="bedrock-agentcore", aws_region=os.environ.get("AWS_REGION", os.environ.get("AWS_DEFAULT_REGION"))))
|
|
38
|
+
{{else if (eq authType "CUSTOM_JWT")}}
|
|
39
|
+
token = _get_bearer_token_{{snakeCase name}}()
|
|
40
|
+
headers = {"Authorization": f"Bearer {token}"} if token else {}
|
|
41
|
+
return MCPClient(lambda: streamablehttp_client(url, headers=headers))
|
|
42
|
+
{{else}}
|
|
43
|
+
return MCPClient(lambda: streamablehttp_client(url))
|
|
44
|
+
{{/if}}
|
|
45
|
+
|
|
46
|
+
{{/each}}
|
|
47
|
+
def get_all_gateway_mcp_clients() -> list[MCPClient]:
|
|
48
|
+
"""Returns MCP clients for all configured gateways."""
|
|
49
|
+
clients = []
|
|
50
|
+
{{#each gatewayProviders}}
|
|
51
|
+
client = get_{{snakeCase name}}_mcp_client()
|
|
52
|
+
if client:
|
|
53
|
+
clients.append(client)
|
|
54
|
+
{{/each}}
|
|
55
|
+
return clients
|
|
56
|
+
{{else}}
|
|
4
57
|
# ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
|
|
5
58
|
EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
|
|
6
59
|
|
|
7
60
|
def get_streamable_http_mcp_client() -> MCPClient:
|
|
8
|
-
"""
|
|
9
|
-
Returns an MCP Client compatible with Strands
|
|
10
|
-
"""
|
|
61
|
+
"""Returns an MCP Client compatible with Strands"""
|
|
11
62
|
# to use an MCP server that supports bearer authentication, add headers={"Authorization": f"Bearer {access_token}"}
|
|
12
|
-
return MCPClient(lambda: streamablehttp_client(EXAMPLE_MCP_ENDPOINT))
|
|
63
|
+
return MCPClient(lambda: streamablehttp_client(EXAMPLE_MCP_ENDPOINT))
|
|
64
|
+
{{/if}}
|
|
@@ -17,6 +17,8 @@ dependencies = [
|
|
|
17
17
|
{{/if}}"mcp >= 1.19.0",
|
|
18
18
|
{{#if (eq modelProvider "OpenAI")}}"openai >= 1.0.0",
|
|
19
19
|
{{/if}}"strands-agents >= 1.13.0",
|
|
20
|
+
{{#if hasGateway}}{{#if (includes gatewayAuthTypes "AWS_IAM")}}"mcp-proxy-for-aws >= 1.1.0",
|
|
21
|
+
{{/if}}{{/if}}
|
|
20
22
|
]
|
|
21
23
|
|
|
22
24
|
[tool.hatch.build.targets.wheel]
|