bedrock-agentcore-starter-toolkit 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of bedrock-agentcore-starter-toolkit might be problematic. Click here for more details.

Files changed (44) hide show
  1. bedrock_agentcore_starter_toolkit/__init__.py +5 -0
  2. bedrock_agentcore_starter_toolkit/cli/cli.py +39 -0
  3. bedrock_agentcore_starter_toolkit/cli/common.py +44 -0
  4. bedrock_agentcore_starter_toolkit/cli/gateway/__init__.py +1 -0
  5. bedrock_agentcore_starter_toolkit/cli/gateway/commands.py +88 -0
  6. bedrock_agentcore_starter_toolkit/cli/runtime/__init__.py +1 -0
  7. bedrock_agentcore_starter_toolkit/cli/runtime/commands.py +603 -0
  8. bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py +124 -0
  9. bedrock_agentcore_starter_toolkit/notebook/__init__.py +5 -0
  10. bedrock_agentcore_starter_toolkit/notebook/runtime/__init__.py +1 -0
  11. bedrock_agentcore_starter_toolkit/notebook/runtime/bedrock_agentcore.py +196 -0
  12. bedrock_agentcore_starter_toolkit/operations/__init__.py +1 -0
  13. bedrock_agentcore_starter_toolkit/operations/gateway/README.md +277 -0
  14. bedrock_agentcore_starter_toolkit/operations/gateway/__init__.py +6 -0
  15. bedrock_agentcore_starter_toolkit/operations/gateway/client.py +456 -0
  16. bedrock_agentcore_starter_toolkit/operations/gateway/constants.py +152 -0
  17. bedrock_agentcore_starter_toolkit/operations/gateway/create_lambda.py +85 -0
  18. bedrock_agentcore_starter_toolkit/operations/gateway/create_role.py +89 -0
  19. bedrock_agentcore_starter_toolkit/operations/gateway/exceptions.py +13 -0
  20. bedrock_agentcore_starter_toolkit/operations/runtime/__init__.py +26 -0
  21. bedrock_agentcore_starter_toolkit/operations/runtime/configure.py +227 -0
  22. bedrock_agentcore_starter_toolkit/operations/runtime/invoke.py +129 -0
  23. bedrock_agentcore_starter_toolkit/operations/runtime/launch.py +163 -0
  24. bedrock_agentcore_starter_toolkit/operations/runtime/models.py +76 -0
  25. bedrock_agentcore_starter_toolkit/operations/runtime/status.py +66 -0
  26. bedrock_agentcore_starter_toolkit/services/ecr.py +55 -0
  27. bedrock_agentcore_starter_toolkit/services/runtime.py +383 -0
  28. bedrock_agentcore_starter_toolkit/utils/endpoints.py +32 -0
  29. bedrock_agentcore_starter_toolkit/utils/runtime/config.py +129 -0
  30. bedrock_agentcore_starter_toolkit/utils/runtime/container.py +310 -0
  31. bedrock_agentcore_starter_toolkit/utils/runtime/entrypoint.py +197 -0
  32. bedrock_agentcore_starter_toolkit/utils/runtime/logs.py +33 -0
  33. bedrock_agentcore_starter_toolkit/utils/runtime/schema.py +141 -0
  34. bedrock_agentcore_starter_toolkit/utils/runtime/templates/Dockerfile.j2 +59 -0
  35. bedrock_agentcore_starter_toolkit/utils/runtime/templates/dockerignore.template +69 -0
  36. bedrock_agentcore_starter_toolkit-0.1.0.dist-info/METADATA +137 -0
  37. bedrock_agentcore_starter_toolkit-0.1.0.dist-info/RECORD +41 -0
  38. bedrock_agentcore_starter_toolkit-0.1.0.dist-info/entry_points.txt +2 -0
  39. bedrock_agentcore_starter_toolkit-0.1.0.dist-info/licenses/NOTICE.txt +190 -0
  40. bedrock_agentcore_starter_toolkit/init.py +0 -3
  41. bedrock_agentcore_starter_toolkit-0.0.1.dist-info/METADATA +0 -26
  42. bedrock_agentcore_starter_toolkit-0.0.1.dist-info/RECORD +0 -5
  43. {bedrock_agentcore_starter_toolkit-0.0.1.dist-info → bedrock_agentcore_starter_toolkit-0.1.0.dist-info}/WHEEL +0 -0
  44. /bedrock_agentcore_starter_toolkit-0.0.1.dist-info/licenses/LICENSE → /bedrock_agentcore_starter_toolkit-0.1.0.dist-info/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,124 @@
1
+ """Configuration management for BedrockAgentCore runtime."""
2
+
3
+ import os
4
+ from pathlib import Path
5
+ from typing import Dict, Optional
6
+
7
+ from ..common import _handle_error, _print_success, _prompt_with_default, console
8
+
9
+
10
+ class ConfigurationManager:
11
+ """Manages interactive configuration prompts with existing configuration defaults."""
12
+
13
+ def __init__(self, config_path: Path):
14
+ """Initialize the ConfigPrompt with a configuration path.
15
+
16
+ Args:
17
+ config_path: Path to the configuration file
18
+ """
19
+ from ...utils.runtime.config import load_config_if_exists
20
+
21
+ project_config = load_config_if_exists(config_path)
22
+ self.existing_config = project_config.get_agent_config() if project_config else None
23
+
24
+ def prompt_execution_role(self) -> str:
25
+ """Prompt for execution role with existing config as default."""
26
+ console.print("\n🔐 [cyan]Execution Role[/cyan]")
27
+ console.print("[dim]Execution role is required for deployment[/dim]")
28
+
29
+ default = self.existing_config.aws.execution_role if self.existing_config else ""
30
+ role = _prompt_with_default("Enter execution role ARN or name", default)
31
+
32
+ if not role:
33
+ _handle_error("Execution role is required")
34
+
35
+ _print_success(f"Using execution role: [dim]{role}[/dim]")
36
+ return role
37
+
38
+ def prompt_ecr_repository(self) -> tuple[Optional[str], bool]:
39
+ """Prompt for ECR repository. Returns (repository, auto_create_flag)."""
40
+ console.print("\n🏗️ [cyan]ECR Repository[/cyan]")
41
+ console.print(
42
+ "[dim]Press Enter to auto-create ECR repository, or provide ECR Repository URI to use existing[/dim]"
43
+ )
44
+
45
+ default = self.existing_config.aws.ecr_repository if self.existing_config else ""
46
+ response = _prompt_with_default("ECR Repository URI (or skip to auto-create)", default)
47
+
48
+ if response:
49
+ _print_success(f"Using existing ECR repository: [dim]{response}[/dim]")
50
+ return response, False
51
+ else:
52
+ _print_success("Will auto-create ECR repository")
53
+ return None, True
54
+
55
+ def prompt_oauth_config(self) -> Optional[dict]:
56
+ """Prompt for OAuth configuration. Returns OAuth config dict or None."""
57
+ console.print("\n🔐 [cyan]Authorization Configuration[/cyan]")
58
+ console.print("[dim]By default, Bedrock AgentCore uses IAM authorization.[/dim]")
59
+
60
+ existing_oauth = self.existing_config and self.existing_config.authorizer_configuration
61
+ oauth_default = "yes" if existing_oauth else "no"
62
+
63
+ response = _prompt_with_default("Configure OAuth authorizer instead? (yes/no)", oauth_default)
64
+
65
+ if response.lower() in ["yes", "y"]:
66
+ return self._configure_oauth()
67
+ else:
68
+ _print_success("Using default IAM authorization")
69
+ return None
70
+
71
+ def _configure_oauth(self) -> dict:
72
+ """Configure OAuth settings and return config dict."""
73
+ console.print("\n📋 [cyan]OAuth Configuration[/cyan]")
74
+
75
+ # Get existing OAuth values
76
+ existing_discovery_url = ""
77
+ existing_client_ids = ""
78
+ existing_audience = ""
79
+
80
+ if (
81
+ self.existing_config
82
+ and self.existing_config.authorizer_configuration
83
+ and "customJWTAuthorizer" in self.existing_config.authorizer_configuration
84
+ ):
85
+ jwt_config = self.existing_config.authorizer_configuration["customJWTAuthorizer"]
86
+ existing_discovery_url = jwt_config.get("discoveryUrl", "")
87
+ existing_client_ids = ",".join(jwt_config.get("allowedClients", []))
88
+ existing_audience = ",".join(jwt_config.get("allowedAudience", []))
89
+
90
+ # Prompt for discovery URL
91
+ default_discovery_url = existing_discovery_url or os.getenv("BEDROCK_AGENTCORE_DISCOVERY_URL", "")
92
+ discovery_url = _prompt_with_default("Enter OAuth discovery URL", default_discovery_url)
93
+
94
+ if not discovery_url:
95
+ _handle_error("OAuth discovery URL is required")
96
+
97
+ # Prompt for client IDs
98
+ default_client_id = existing_client_ids or os.getenv("BEDROCK_AGENTCORE_CLIENT_ID", "")
99
+ client_ids_input = _prompt_with_default("Enter allowed OAuth client IDs (comma-separated)", default_client_id)
100
+ # Prompt for audience
101
+ default_audience = existing_audience or os.getenv("BEDROCK_AGENTCORE_AUDIENCE", "")
102
+ audience_input = _prompt_with_default("Enter allowed OAuth audience (comma-separated)", default_audience)
103
+
104
+ if not client_ids_input and not audience_input:
105
+ _handle_error("At least one client ID or one audience is required for OAuth configuration")
106
+
107
+ # Parse and return config
108
+ client_ids = [cid.strip() for cid in client_ids_input.split(",") if cid.strip()]
109
+ audience = [aud.strip() for aud in audience_input.split(", ") if aud.strip()]
110
+
111
+ config: Dict = {
112
+ "customJWTAuthorizer": {
113
+ "discoveryUrl": discovery_url,
114
+ }
115
+ }
116
+
117
+ if client_ids:
118
+ config["customJWTAuthorizer"]["allowedClients"] = client_ids
119
+
120
+ if audience:
121
+ config["customJWTAuthorizer"]["allowedAudience"] = audience
122
+
123
+ _print_success("OAuth authorizer configuration created")
124
+ return config
@@ -0,0 +1,5 @@
1
+ """Bedrock AgentCore Starter Toolkit notebook package."""
2
+
3
+ from .runtime.bedrock_agentcore import Runtime
4
+
5
+ __all__ = ["Runtime"]
@@ -0,0 +1 @@
1
+ """Bedrock AgentCore Starter Toolkit notebook runtime package."""
@@ -0,0 +1,196 @@
1
+ """Bedrock AgentCore Notebook - Jupyter notebook interface for Bedrock AgentCore."""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+ from typing import Any, Dict, List, Literal, Optional
6
+
7
+ from ...operations.runtime import (
8
+ configure_bedrock_agentcore,
9
+ get_status,
10
+ invoke_bedrock_agentcore,
11
+ launch_bedrock_agentcore,
12
+ validate_agent_name,
13
+ )
14
+ from ...operations.runtime.models import ConfigureResult, LaunchResult, StatusResult
15
+ from ...utils.runtime.entrypoint import parse_entrypoint
16
+
17
+ # Configure logger for notebook use
18
+ log = logging.getLogger(__name__)
19
+ if not log.handlers:
20
+ handler = logging.StreamHandler()
21
+ handler.setFormatter(logging.Formatter("%(message)s"))
22
+ log.addHandler(handler)
23
+ log.setLevel(logging.INFO)
24
+
25
+
26
+ class Runtime:
27
+ """Bedrock AgentCore for Jupyter notebooks - simplified interface for file-based configuration."""
28
+
29
+ def __init__(self):
30
+ """Initialize Bedrock AgentCore notebook interface."""
31
+ self._config_path: Optional[Path] = None
32
+ self.name = None
33
+
34
+ def configure(
35
+ self,
36
+ entrypoint: str,
37
+ execution_role: str,
38
+ agent_name: Optional[str] = None,
39
+ requirements: Optional[List[str]] = None,
40
+ requirements_file: Optional[str] = None,
41
+ ecr_repository: Optional[str] = None,
42
+ container_runtime: Optional[str] = None,
43
+ auto_create_ecr: bool = True,
44
+ authorizer_configuration: Optional[Dict[str, Any]] = None,
45
+ region: Optional[str] = None,
46
+ protocol: Optional[Literal["HTTP", "MCP"]] = None,
47
+ ) -> ConfigureResult:
48
+ """Configure Bedrock AgentCore from notebook using an entrypoint file.
49
+
50
+ Args:
51
+ entrypoint: Path to Python file with optional Bedrock AgentCore name
52
+ (e.g., "handler.py" or "handler.py:bedrock_agentcore")
53
+ execution_role: AWS IAM execution role ARN or name
54
+ agent_name: name of the agent
55
+ requirements: Optional list of requirements to generate requirements.txt
56
+ requirements_file: Optional path to existing requirements file
57
+ ecr_repository: Optional ECR repository URI
58
+ container_runtime: Optional container runtime (docker/podman)
59
+ auto_create_ecr: Whether to auto-create ECR repository
60
+ authorizer_configuration: JWT authorizer configuration dictionary
61
+ region: AWS region for deployment
62
+ protocol: agent server protocol, must be either HTTP or MCP
63
+
64
+ Returns:
65
+ ConfigureResult with configuration details
66
+ """
67
+ if protocol and protocol.upper() not in ["HTTP", "MCP"]:
68
+ raise ValueError("protocol must be either HTTP or MCP")
69
+
70
+ # Parse entrypoint to get agent name
71
+ file_path, file_name = parse_entrypoint(entrypoint)
72
+ agent_name = agent_name or file_name
73
+
74
+ valid, error = validate_agent_name(agent_name)
75
+ if not valid:
76
+ raise ValueError(error)
77
+
78
+ # Update our name if not already set
79
+ if not self.name:
80
+ self.name = agent_name
81
+
82
+ # Handle requirements
83
+ final_requirements_file = requirements_file
84
+
85
+ if requirements and not requirements_file:
86
+ # Create requirements.txt in the same directory as the handler
87
+ handler_dir = Path(file_path).parent
88
+ req_file_path = handler_dir / "requirements.txt"
89
+
90
+ all_requirements = [] # "bedrock_agentcore" # Always include bedrock_agentcore
91
+ all_requirements.extend(requirements)
92
+
93
+ req_file_path.write_text("\n".join(all_requirements))
94
+ log.info("Generated requirements.txt: %s", req_file_path)
95
+
96
+ final_requirements_file = str(req_file_path)
97
+
98
+ # Configure using the operations module
99
+ result = configure_bedrock_agentcore(
100
+ agent_name=agent_name,
101
+ entrypoint_path=Path(file_path),
102
+ execution_role=execution_role,
103
+ ecr_repository=ecr_repository,
104
+ container_runtime=container_runtime,
105
+ auto_create_ecr=auto_create_ecr,
106
+ requirements_file=final_requirements_file,
107
+ authorizer_configuration=authorizer_configuration,
108
+ region=region,
109
+ protocol=protocol.upper() if protocol else None,
110
+ )
111
+
112
+ self._config_path = result.config_path
113
+ log.info("Bedrock AgentCore configured: %s", self._config_path)
114
+ return result
115
+
116
+ def launch(self, local: bool = False, push_ecr: bool = False, env_vars: Optional[Dict] = None) -> LaunchResult:
117
+ """Launch Bedrock AgentCore from notebook.
118
+
119
+ Args:
120
+ local: Whether to build for local execution only
121
+ push_ecr: Whether to push to ECR only (no deployment)
122
+ env_vars: environment variables for agent container
123
+
124
+ Returns:
125
+ LaunchResult with deployment details
126
+ """
127
+ if not self._config_path:
128
+ raise ValueError("Must configure before launching. Call .configure() first.")
129
+
130
+ result = launch_bedrock_agentcore(self._config_path, local=local, push_ecr_only=push_ecr, env_vars=env_vars)
131
+
132
+ if result.mode == "cloud":
133
+ log.info("Deployed to cloud: %s", result.agent_arn)
134
+ # Show log information for cloud deployments
135
+ if result.agent_id:
136
+ from ...utils.runtime.logs import get_agent_log_paths, get_aws_tail_commands
137
+
138
+ runtime_logs, otel_logs = get_agent_log_paths(result.agent_id)
139
+ follow_cmd, since_cmd = get_aws_tail_commands(runtime_logs)
140
+ log.info("🔍 Agent logs available at:")
141
+ log.info(" %s", runtime_logs)
142
+ log.info(" %s", otel_logs)
143
+ log.info("💡 Tail logs with: %s", follow_cmd)
144
+ log.info("💡 Or view recent logs: %s", since_cmd)
145
+ elif result.mode == "push-ecr":
146
+ log.info("Pushed to ECR: %s", result.ecr_uri)
147
+ else:
148
+ log.info("Built for local: %s", result.tag)
149
+
150
+ return result
151
+
152
+ def invoke(
153
+ self,
154
+ payload: Dict[str, Any],
155
+ session_id: Optional[str] = None,
156
+ bearer_token: Optional[str] = None,
157
+ local: Optional[bool] = False,
158
+ user_id: Optional[str] = None,
159
+ ) -> Dict[str, Any]:
160
+ """Invoke deployed Bedrock AgentCore endpoint.
161
+
162
+ Args:
163
+ payload: Dictionary payload to send
164
+ session_id: Optional session ID for conversation continuity
165
+ bearer_token: Optional bearer token for HTTP authentication
166
+ local: Send request to a running local container
167
+ user_id: User id for authorization flows
168
+
169
+ Returns:
170
+ Response from the Bedrock AgentCore endpoint
171
+ """
172
+ if not self._config_path:
173
+ raise ValueError("Must configure and launch first.")
174
+
175
+ result = invoke_bedrock_agentcore(
176
+ config_path=self._config_path,
177
+ payload=payload,
178
+ session_id=session_id,
179
+ bearer_token=bearer_token,
180
+ local_mode=local,
181
+ user_id=user_id,
182
+ )
183
+ return result.response
184
+
185
+ def status(self) -> StatusResult:
186
+ """Get Bedrock AgentCore status including config and runtime details.
187
+
188
+ Returns:
189
+ StatusResult with configuration, agent, and endpoint status
190
+ """
191
+ if not self._config_path:
192
+ raise ValueError("Must configure first. Call .configure() first.")
193
+
194
+ result = get_status(self._config_path)
195
+ log.info("Retrieved Bedrock AgentCore status for: %s", self.name or "Bedrock AgentCore")
196
+ return result
@@ -0,0 +1 @@
1
+ """BedrockAgentCore Starter Toolkit operations."""
@@ -0,0 +1,277 @@
1
+ # Bedrock AgentCore Gateway
2
+
3
+ Bedrock AgentCore Gateway is a primitive within the Bedrock AgentCore SDK that enables you to:
4
+ - Convert REST APIs (OpenAPI) into MCP tools
5
+ - Expose Lambda functions as MCP tools
6
+ - Handle authentication automatically with EZ Auth
7
+ - Enable semantic search across your tools
8
+
9
+ ## Quick Start
10
+
11
+ ### Using the CLI (Recommended)
12
+
13
+ ```bash
14
+ # Create a Gateway to use with targets defined in OpenAPI or Smithy
15
+ agentcore create_mcp_gateway \
16
+ --region us-west-2 \
17
+ --name gateway-name
18
+
19
+ # Create a Gateway Target with predefined smithy model
20
+ agentcore create_mcp_gateway_target \
21
+ --region us-east-1 \
22
+ --gateway-arn arn:aws:bedrock-agentcore:us-east-1:123:gateway/gateway-id \
23
+ --gateway-url https://gateway-id.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp \
24
+ --role-arn arn:aws:iam::123:role/BedrockAgentCoreGatewayRole \
25
+ --target-type smithyModel
26
+
27
+ # Create a Gateway Target with OpenAPI target (OAuth with API Key)
28
+ agentcore create_mcp_gateway_target \
29
+ --region us-east-1 \
30
+ --gateway-arn arn:aws:bedrock-agentcore:us-east-1:123:gateway/gateway-id \
31
+ --gateway-url https://gateway-id.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp \
32
+ --role-arn arn:aws:iam::123:role/BedrockAgentCoreGatewayRole \
33
+ --target-type openApiSchema \
34
+ --credentials "{\"api_key\": \"Bearer 123234bc\", \"credential_location\": \"HEADER\", \"credential_parameter_name\": \"Authorization\"}" \
35
+ --target-payload "{\"s3\": { \"uri\": \"s3://openapischemas/sample-openapi-schema.json\", \"bucketOwnerAccountId\": \"012345678912\"}}"
36
+
37
+ # Create a Gateway Target with OpenAPI target (OAuth with credential provider)
38
+ agentcore create_mcp_gateway_target \
39
+ --region us-east-1 \
40
+ --gateway-arn arn:aws:bedrock-agentcore:us-east-1:123:gateway/gateway-id \
41
+ --gateway-url https://gateway-id.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp \
42
+ --role-arn arn:aws:iam::123:role/BedrockAgentCoreGatewayRole \
43
+ --target-type openApiSchema \
44
+ --credentials "{\"oauth2_provider_config\": { \"customOauth2ProviderConfig\": {\"oauthDiscovery\" : {\"authorizationServerMetadata\" : {\"issuer\" : \"<issuer>\",\"authorizationEndpoint\" : \"<authorizationEndpoint>\",\"tokenEndpoint\" : \"<tokenEndpoint>\"}},\"clientId\" : \"<clientId>\",\"clientSecret\" : \"<clientSecret>\" }}}" \
45
+ --target-payload "{\"s3\": { \"uri\": \"s3://openapischemas/sample-openapi-schema.json\", \"bucketOwnerAccountId\": \"012345678912\"}}"
46
+ ```
47
+
48
+ The CLI automatically:
49
+ - Detects target type from ARN patterns or file extensions
50
+ - Sets up Cognito OAuth (EZ Auth)
51
+ - Detects your AWS region and account
52
+ - Builds full role ARN from role name
53
+
54
+
55
+ ### Using the SDK
56
+
57
+ For programmatic access in scripts, notebooks, or CI/CD:
58
+
59
+ ```python
60
+ from bedrock_agentcore_starter_toolkit.operations.gateway.client import GatewayClient
61
+ import json
62
+
63
+ # Initialize client
64
+ client = GatewayClient(region_name='us-west-2')
65
+
66
+ # EZ Auth - automatically sets up Cognito OAuth
67
+ cognito_result = client.create_oauth_authorizer_with_cognito("my-gateway")
68
+
69
+ # Create Gateway with OpenAPI schema target
70
+ gateway = client.create_mcp_gateway(
71
+ name="my-gateway",
72
+ role_arn="arn:aws:iam::123:role/BedrockAgentCoreGatewayExecutionRole",
73
+ authorizer_config=cognito_result['authorizer_config']
74
+ )
75
+
76
+ target = client.create_mcp_gateway_target(
77
+ gateway=gateway,
78
+ name="sample_target",
79
+ target_type='openApiSchema',
80
+ target_payload= {
81
+ "s3": {
82
+ "uri": "s3://openapischemas/sample-openapi-schema.json",
83
+ "bucketOwnerAccountId": "012345678912"
84
+ }
85
+ },
86
+ credentials={
87
+ "api_key": "abc123",
88
+ "credential_location": "HEADER",
89
+ "credential_parameter_name": "Authorization"
90
+ }
91
+ )
92
+ print(f"MCP Endpoint: {gateway['gatewayUrl']}")
93
+ print(f"OAuth Credentials:")
94
+ print(f" Client ID: {cognito_result['client_info']['client_id']}")
95
+ print(f" Client Secret: {cognito_result['client_info']['client_secret']}")
96
+ print(f" Scope: {cognito_result['client_info']['scope']}")
97
+ ```
98
+
99
+ ## Key Features
100
+
101
+ ### EZ Auth
102
+ Eliminates the complexity of OAuth setup:
103
+ ```python
104
+ # Without EZ Auth: 8+ manual steps
105
+ # With EZ Auth: 1 line
106
+ cognito_result = client.create_oauth_authorizer_with_cognito("my-gateway")
107
+ ```
108
+
109
+ ### Semantic Search
110
+ Enable intelligent tool discovery:
111
+ ```python
112
+ gateway = client.create_mcp_gateway(
113
+ name="my-gateway",
114
+ role_arn="arn:aws:iam::123:role/BedrockAgentCoreGatewayExecutionRole",
115
+ authorizer_config=cognito_result['authorizer_config'],
116
+ enable_semantic_search=True # Enable semantic search.
117
+ )
118
+ ```
119
+
120
+ ### Multiple Target Types
121
+
122
+ #### Lambda Functions
123
+ ```python
124
+ # Auto-generated schema (default)
125
+ gateway = client.create_mcp_gateway(
126
+ name="my-gateway",
127
+ role_arn="arn:aws:iam::123:role/BedrockAgentCoreGatewayExecutionRole",
128
+ authorizer_config=cognito_result['authorizer_config']
129
+ )
130
+
131
+ # Create a lambda target
132
+ lambda_target = client.create_mcp_gateway_target(
133
+ name="lambda-target",
134
+ gateway=gateway,
135
+ target_type='lambda'
136
+ )
137
+ ```
138
+
139
+ #### OpenAPI (REST APIs)
140
+ ```python
141
+ # Inline OpenAPI
142
+ openapi_spec = {
143
+ "openapi": "3.0.0",
144
+ "info": {"title": "My API", "version": "1.0.0"},
145
+ "servers": [{"url": "https://api.example.com"}],
146
+ "paths": {
147
+ "/users": {
148
+ "get": {
149
+ "operationId": "listUsers",
150
+ "responses": {"200": {"description": "Success"}}
151
+ }
152
+ }
153
+ }
154
+ }
155
+ openAPI_inline_target = client.create_mcp_gateway_target(
156
+ name="inlineTarget",
157
+ gateway=gateway,
158
+ credentials={
159
+ "api_key": "abc123",
160
+ "credential_location": "HEADER",
161
+ "credential_parameter_name": "Authorization"
162
+ },
163
+ target_type='openApiSchema',
164
+ target_payload= {
165
+ "inlinePayload": openapi_spec
166
+ }
167
+ )
168
+
169
+ # From S3
170
+ openAPI_target = client.create_mcp_gateway_target(
171
+ name="s3target",
172
+ gateway=gateway,
173
+ credentials={
174
+ "api_key": "abc123",
175
+ "credential_location": "HEADER",
176
+ "credential_parameter_name": "Authorization"
177
+ },
178
+ target_type='openApiSchema',
179
+ target_payload= {
180
+ "s3": {
181
+ "uri": "s3://openapischemas/sample-openapi-schema.json",
182
+ "bucketOwnerAccountId": "012345678912"
183
+ }
184
+ }
185
+ )
186
+ ```
187
+
188
+ ## MCP Integration
189
+
190
+ Once created, use any MCP client to interact with your Gateway:
191
+
192
+ ```python
193
+ import httpx
194
+
195
+ # Get token
196
+ token = client.get_access_token_for_cognito(cognito_result['client_info'])
197
+
198
+ # List tools
199
+ async with httpx.AsyncClient() as http:
200
+ response = await http.post(
201
+ gateway['gatewayUrl'],
202
+ headers={"Authorization": f"Bearer {token}"},
203
+ json={
204
+ "jsonrpc": "2.0",
205
+ "id": 1,
206
+ "method": "tools/list",
207
+ "params": {}
208
+ }
209
+ )
210
+ tools = response.json()
211
+
212
+ # Invoke a tool
213
+ response = await http.post(
214
+ gateway['gatewayUrl'],
215
+ headers={"Authorization": f"Bearer {token}"},
216
+ json={
217
+ "jsonrpc": "2.0",
218
+ "id": 2,
219
+ "method": "tools/call",
220
+ "params": {
221
+ "name": "listUsers",
222
+ "arguments": {}
223
+ }
224
+ }
225
+ )
226
+ ```
227
+
228
+ ## Prerequisites
229
+
230
+ **AWS Account**: Must be allowlisted for Bedrock AgentCore beta
231
+ **IAM Execution Role**: With trust relationship to BedrockAgentCore service
232
+ **Permissions**: Role needs access to your backends (Lambda invoke, S3 read, etc.)
233
+ **Custom Boto3 SDK**: Download from Bedrock AgentCore documentation
234
+
235
+ ## Testing
236
+
237
+ See `tests/bedrock_agentcore/gateway/` for integration tests covering all target types.
238
+
239
+ ## API Reference
240
+
241
+ ### GatewayClient
242
+
243
+ - `create_oauth_authorizer_with_cognito(gateway_name)` - Set up Cognito OAuth automatically
244
+ - `create_mcp_gateway(...)` - Create a gateway
245
+ - `create_mcp_gateway_target(...)` - Create a gateway target
246
+ - `get_test_token_for_cognito(client_info)` - Get OAuth token for testing
247
+
248
+ ### List of all builtin schemas
249
+ ```doc
250
+ 1. confluence
251
+ 2. onedrive
252
+ 3. dynamodb
253
+ 4. cloudwatch
254
+ 5. slack
255
+ 6. smartsheet
256
+ 7. sap-business-partner
257
+ 8. tavily
258
+ 9. jira
259
+ 10. sap-product-master-data
260
+ 11. genericHTTP
261
+ 12. sap-material-stock
262
+ 13. sap-physical-inventory
263
+ 14. salesforce
264
+ 15. servicenow
265
+ 16. bambooHR
266
+ 17. brave-search
267
+ 18. msExchange
268
+ 19. sap-bill-of-material
269
+ 20. sharepoint
270
+ 21. asana
271
+ 22. zendesk
272
+ 23. msTeams
273
+ 24. pagerduty
274
+ 25. zoom
275
+ 26. bedrock-runtime
276
+ 27. bedrock-agent-runtime
277
+ ```
@@ -0,0 +1,6 @@
1
+ """BedrockAgentCore Starter Toolkit cli gateway package."""
2
+
3
+ from .client import GatewayClient
4
+ from .exceptions import GatewayException, GatewaySetupException
5
+
6
+ __all__ = ["GatewayClient", "GatewayException", "GatewaySetupException"]