Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
25fdda6
fix: workshop fixes
akshseh Sep 29, 2025
47776ca
fix: lab3 workshop
akshseh Sep 29, 2025
529ea1b
chores: remove unused files
akshseh Sep 29, 2025
a027570
chore: update imports
akshseh Sep 29, 2025
d098a28
chore: remove unused utils
akshseh Sep 29, 2025
3ab9390
chore: fix import path
akshseh Sep 29, 2025
52092d5
chore: update lab3
akshseh Sep 29, 2025
cd8cc63
fix: add import
akshseh Sep 30, 2025
95fb745
fix: remove unnecessary token update
akshseh Oct 1, 2025
349bf80
fix: update gateway lab for new mcp format
akshseh Oct 1, 2025
13b60fc
fix: toolkit version
akshseh Oct 1, 2025
d4073a4
feat: update the runtime lab
akshseh Oct 1, 2025
3a7574f
Update lab-04-agentcore-runtime.ipynb
rohillasandeep Oct 5, 2025
bf7e111
Update utils.py - Added Gateway Invocation Permissions
rohillasandeep Oct 5, 2025
c9e35f1
Update requirements.txt - updated version numbers
rohillasandeep Oct 5, 2025
a95ccb9
Update lab-04-agentcore-runtime.ipynb
rohillasandeep Oct 5, 2025
d4d5414
Update lab-04-agentcore-runtime.ipynb
rohillasandeep Oct 5, 2025
d0d7d13
Update lab-04-agentcore-runtime.ipynb
rohillasandeep Oct 6, 2025
27f0af0
fix: agentcore sdk version fix (#432)
akshseh Oct 1, 2025
af44acd
AgentCore Observability - LlamaIndex Tutorial (#307)
seanslavichaws Oct 2, 2025
01ba6c5
Adding LangGraph notebooks for agentcore checkpointer and memory stor…
jgordley Oct 3, 2025
a8c3b2c
Changes to support latest version of browser-use (0.7.9) (#405)
chintanpatel-ai Oct 3, 2025
9268fa9
AgentCore Memory: Added Sample code for MemoryManager SDK changes (#435)
georgebe Oct 3, 2025
ce4e28f
Updated observability samples for Langfuse and Braintrust (#430)
rajeshkumarravi Oct 3, 2025
78de36d
feat: update workshop lab helpers
akshseh Oct 6, 2025
a4242b6
Integrations/amazon-sagemakerai/sagemaker-mlflow-agentcore-runtime (#…
ravees Oct 6, 2025
c9c8a2c
feat: iam auth with MCP Runtime (#438)
EashanKaushik Oct 6, 2025
a59ffea
fix: toolkit version
akshseh Oct 1, 2025
e2e2b36
fix: agentcore sdk version fix (#432)
akshseh Oct 1, 2025
e55f0dd
Merge branch 'awslabs:main' into workshop_e2e
akshseh Oct 6, 2025
0415cae
Update lab-04-agentcore-runtime.ipynb
rohillasandeep Oct 6, 2025
f5c267a
Update lab-03-agentcore-gateway.ipynb
rohillasandeep Oct 7, 2025
5319667
Update requirements.txt
rohillasandeep Oct 8, 2025
3de8fb8
Merge branch 'awslabs:main' into workshop_e2e
akshseh Oct 8, 2025
5d1dbcc
Merge branch 'awslabs:main' into workshop_e2e
akshseh Oct 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"import argparse\n",
"from boto3.session import Session\n",
"from opentelemetry import baggage, context\n",
"from scripts.utils import get_ssm_parameter\n",
"from lab_helpers.utils import get_ssm_parameter\n",
"\n",
"from strands import Agent\n",
"from strands.models import BedrockModel\n",
Expand Down
2 changes: 1 addition & 1 deletion 01-tutorials/07-AgentCore-E2E/Optional-lab-identity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@
"try:\n",
" print(\"📥 Fetching Cognito configuration from SSM...\")\n",
" \n",
" client_id = get_ssm_parameter(\"/app/customersupport/agentcore/machine_client_id\")\n",
" client_id = get_ssm_parameter(\"/app/customersupport/agentcore/client_id\")\n",
" print(f\"✅ Retrieved client ID: {client_id}\")\n",
"\n",
" client_secret = get_ssm_parameter(\"/app/customersupport/agentcore/cognito_secret\")\n",
Expand Down
130 changes: 44 additions & 86 deletions 01-tutorials/07-AgentCore-E2E/lab-03-agentcore-gateway.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,17 @@
"outputs": [],
"source": [
"# Import libraries\n",
"from strands import Agent\n",
"from strands.models import BedrockModel\n",
"from strands.tools.mcp import MCPClient\n",
"import os\n",
"import sys\n",
"import boto3\n",
"import json\n",
"from bedrock_agentcore.identity.auth import requires_access_token\n",
"\n",
"from strands import Agent\n",
"from strands.models import BedrockModel\n",
"from strands.tools.mcp import MCPClient\n",
"from mcp.client.streamable_http import streamablehttp_client\n",
"import requests\n",
"from lab_helpers.utils import get_or_create_cognito_pool, put_ssm_parameter, get_ssm_parameter, load_api_spec\n",
"\n",
"from scripts.utils import get_ssm_parameter, put_ssm_parameter, load_api_spec, get_cognito_client_secret\n",
"\n",
"sts_client = boto3.client('sts')\n",
"\n",
Expand Down Expand Up @@ -286,12 +285,11 @@
"source": [
"gateway_name = \"customersupport-gw\"\n",
"\n",
"cognito_config = get_or_create_cognito_pool(refresh_token=True)\n",
"auth_config = {\n",
" \"customJWTAuthorizer\": {\n",
" \"allowedClients\": [\n",
" get_ssm_parameter(\"/app/customersupport/agentcore/machine_client_id\")\n",
" ],\n",
" \"discoveryUrl\": get_ssm_parameter(\"/app/customersupport/agentcore/cognito_discovery_url\")\n",
" \"allowedClients\": [cognito_config[\"client_id\"]],\n",
" \"discoveryUrl\": cognito_config[\"discovery_url\"]\n",
" }\n",
"}\n",
"\n",
Expand All @@ -317,7 +315,13 @@
" \"gateway_arn\": create_response[\"gatewayArn\"],\n",
" }\n",
" put_ssm_parameter(\"/app/customersupport/agentcore/gateway_id\", gateway_id)\n",
"\n",
" put_ssm_parameter(\"/app/customersupport/agentcore/gateway_name\", gateway_name)\n",
" put_ssm_parameter(\n",
" \"/app/customersupport/agentcore/gateway_arn\", create_response[\"gatewayArn\"]\n",
" )\n",
" put_ssm_parameter(\n",
" \"/app/customersupport/agentcore/gateway_url\", create_response[\"gatewayUrl\"]\n",
" )\n",
" print(f\"✅ Gateway created successfully with ID: {gateway_id}\")\n",
"\n",
"except Exception as e:\n",
Expand Down Expand Up @@ -354,14 +358,6 @@
"metadata": {},
"outputs": [],
"source": [
"def load_api_spec(file_path: str) -> list:\n",
" with open(file_path, \"r\") as f:\n",
" data = json.load(f)\n",
" \n",
" if not isinstance(data, list):\n",
" raise ValueError(\"Expected a list in the JSON file\")\n",
" return data\n",
"\n",
"try:\n",
" api_spec_file = \"./prerequisite/lambda/api_spec.json\"\n",
"\n",
Expand Down Expand Up @@ -406,40 +402,8 @@
"metadata": {},
"source": [
"## Step 7: Add our new MCP-based tools to our support agent\n",
"Here we integrate our authentication token from Cognito into an MCPClient from Strands SDK to create an MCP Server object to integrate with our Strands Agent"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6fec14df-e398-4321-9903-21a5f5f76c3a",
"metadata": {},
"outputs": [],
"source": [
"def get_token(client_id: str, client_secret: str, scope_string: str, url: str) -> dict:\n",
" try:\n",
" headers = {\"Content-Type\": \"application/x-www-form-urlencoded\"}\n",
" data = {\n",
" \"grant_type\": \"client_credentials\",\n",
" \"client_id\": client_id,\n",
" \"client_secret\": client_secret,\n",
" \"scope\": scope_string,\n",
"\n",
" }\n",
" response = requests.post(url, headers=headers, data=data)\n",
" response.raise_for_status()\n",
" return response.json()\n",
"\n",
" except requests.exceptions.RequestException as err:\n",
" return {\"error\": str(err)}"
]
},
{
"cell_type": "markdown",
"id": "bff0a6b8-fdd3-4536-8012-6d0ab34f568f",
"metadata": {},
"source": [
"## Step 7.1. Set up a secure MCP client object"
"Here we integrate our authentication token from Cognito into an MCPClient from Strands SDK to create an MCP Server object to integrate with our Strands Agent\n",
"### Step 7.1. Set up a secure MCP client object"
]
},
{
Expand All @@ -449,19 +413,12 @@
"metadata": {},
"outputs": [],
"source": [
"gateway_access_token = get_token(\n",
" get_ssm_parameter(\"/app/customersupport/agentcore/machine_client_id\"),\n",
" get_cognito_client_secret(),\n",
" get_ssm_parameter(\"/app/customersupport/agentcore/cognito_auth_scope\"),\n",
" get_ssm_parameter(\"/app/customersupport/agentcore/cognito_token_url\"))\n",
"\n",
"print(f\"Gateway Endpoint - MCP URL: {gateway['gateway_url']}\")\n",
"\n",
"# Set up MCP client\n",
"mcp_client = MCPClient(\n",
" lambda: streamablehttp_client(\n",
" gateway['gateway_url'],\n",
" headers={\"Authorization\": f\"Bearer {gateway_access_token['access_token']}\"},\n",
" headers={\"Authorization\": f\"Bearer {cognito_config['bearer_token']}\"},\n",
" )\n",
")"
]
Expand Down Expand Up @@ -501,28 +458,29 @@
" temperature=0.3, # Balanced between creativity and consistency\n",
" region_name=REGION\n",
")\n",
"\n",
"try:\n",
" mcp_client.start()\n",
"except Exception as e:\n",
" print(f\"Error initializing agent: {str(e)}\")\n",
"\n",
"tools = (\n",
" [\n",
" get_product_info,\n",
" get_return_policy,\n",
" get_technical_support\n",
" ]\n",
" + mcp_client.list_tools_sync()\n",
" )\n",
"\n",
"# Create the customer support agent\n",
"agent = Agent(\n",
" model=model,\n",
" tools=tools,\n",
" hooks=[memory_hooks],\n",
" system_prompt=SYSTEM_PROMPT\n",
")\n",
"def create_agent(prompt):\n",
" try:\n",
" with mcp_client:\n",
" tools = (\n",
" [\n",
" get_product_info,\n",
" get_return_policy,\n",
" get_technical_support\n",
" ]\n",
" + mcp_client.list_tools_sync()\n",
" )\n",
" \n",
" # Create the customer support agent\n",
" agent = Agent(\n",
" model=model,\n",
" tools=tools,\n",
" hooks=[memory_hooks],\n",
" system_prompt=SYSTEM_PROMPT\n",
" )\n",
" response = agent(prompt)\n",
" return response\n",
" except Exception as e:\n",
" raise e\n",
"\n",
"print(\"✅ Customer support agent created successfully!\")"
]
Expand Down Expand Up @@ -557,18 +515,18 @@
"]\n",
"\n",
"# Function to test the agent\n",
"def test_agent_responses(agent, prompts):\n",
"def test_agent_responses(prompts):\n",
" for i, prompt in enumerate(prompts, 1):\n",
" print(f\"\\nTest Case {i}: {prompt}\")\n",
" print(\"-\" * 50)\n",
" try:\n",
" response = agent(prompt)\n",
" response = create_agent(prompt)\n",
" except Exception as e:\n",
" print(f\"Error: {str(e)}\")\n",
" print(\"-\" * 50)\n",
"\n",
"# Run the tests\n",
"test_agent_responses(agent, test_prompts)\n",
"test_agent_responses(test_prompts)\n",
"\n",
"print(\"\\\\n✅ Basic testing completed!\")\n"
]
Expand Down
Loading
Loading