Some checks failed
check agents / check (push) Failing after 13s
The cp1-solution-architecture-agent and the sa-aws/azure/gcp-cloud MCP servers, a separate stream from the individual and sub-agent patterns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.6 KiB
Python
48 lines
2.6 KiB
Python
# sa-aws-cloud: the AWS counterpart of each source tool. Only list, describe and get operations are named here, and
|
|
# every call goes through the customer's read-only role, inside the connection's accounts and regions.
|
|
|
|
|
|
async def _aws_list(tool: str, arguments: Dict[str, Any], entry: tuple, wanted: Optional[List[str]] = None) -> Dict[str, Any]:
|
|
"""One page; `wanted` adds caller values to the fixed request, as (parameter, argument) pairs of a required value."""
|
|
service, operation, result_key, token_in, token_out, fixed = entry
|
|
fixed = dict(fixed)
|
|
for parameter, argument in wanted or []:
|
|
if not arguments.get(argument):
|
|
return _refuse("invalid_argument", f"{argument} is required")
|
|
fixed[parameter] = arguments[argument]
|
|
return await _aws_kind(tool, {**arguments, "kind": "one"}, {"one": (service, operation, result_key, token_in, token_out, fixed)}, "one")
|
|
|
|
|
|
async def _aws_get(tool: str, arguments: Dict[str, Any], service: str, operation: str, request: Dict[str, Any]) -> Dict[str, Any]:
|
|
account, region, refused = _aws_target(arguments)
|
|
if refused:
|
|
return refused
|
|
missing = [k for k, v in request.items() if v in (None, "", [], [None])]
|
|
if missing:
|
|
return _refuse("invalid_argument", "missing: " + ", ".join(missing))
|
|
try:
|
|
body = await _aws_call(arguments, service, operation, region, **request)
|
|
except Exception as error:
|
|
return _upstream_failed("aws", error)
|
|
body.pop("ResponseMetadata", None)
|
|
return _one_result("aws", tool, arguments, body)
|
|
|
|
|
|
async def _aws_metric_data(tool: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
queries, start, end = arguments.get("metric_queries"), arguments.get("start_time"), arguments.get("end_time")
|
|
if not isinstance(queries, list) or not queries or not start or not end:
|
|
return _refuse("invalid_argument", "metric_queries, start_time and end_time are required")
|
|
return await _aws_get(tool, arguments, "cloudwatch", "get_metric_data",
|
|
{"MetricDataQueries": queries, "StartTime": start, "EndTime": end})
|
|
|
|
|
|
def _aws_docs_connection() -> Dict[str, Any]:
|
|
connection = get_connection()
|
|
return {"aws_access_key_id": connection.get("docs_access_key_id") or connection.get("access_key_id"),
|
|
"aws_secret_access_key": connection.get("docs_secret_access_key") or connection.get("secret_access_key")}
|
|
|
|
|
|
def _aws_docs_request(url: Any) -> Dict[str, Any]:
|
|
"""The call shape AWS's documentation reader takes (agent-toolkit-for-aws)."""
|
|
return {"requests": [{"url": url, "max_length": 100000}]}
|