项目文件夹

0
herosjourney 2cb0fa1c2e feat: add read-only Anthropic usage/cost discovery (gcp, azure, llm-to-bedrock) (#425)
* feat(gcp-to-aws): add Anthropic usage discovery (Admin API)

* Mention usage-API cost discovery (incl. Anthropic) in plugin.json

Surfaces the OpenAI/OpenRouter/Anthropic read-only usage-API discovery
capability in the plugin description and adds usage-api/cost-discovery
keywords, so the new Anthropic discovery fragment is discoverable from
the marketplace listing, not just from skill-internal docs.

* feat(azure-to-aws): add OpenAI/OpenRouter/Anthropic usage-API discovery

* feat(llm-to-bedrock): support azure-to-aws as Assess sibling + reuse usage profiles

* docs(aws-startup-advisor): README llm-to-bedrock accepts azure-to-aws too

* fix: resolve markdownlint failures (list style, emphasis, inline-HTML placeholder)

- discover-anthropic-api.md (gcp-to-aws + azure-to-aws): unordered list
  bullet style '+' -> '-' to match repo convention (MD004)
- llm-to-bedrock/SKILL.md: emphasis style '_underscore_' -> '*asterisk*'
  (MD049) and wrapped the <date> prose placeholder in a code span so
  markdownlint stops parsing it as inline HTML (MD033)

No behavior change; verified with 'npx markdownlint-cli2' (0 errors on the
3 touched files), llm-to-bedrock's own pytest suite (251/251), and
tests/test_model_id_lint.py (11/11).

* fix: stop dropping Anthropic cache tokens from usage/cost volume

Addresses the blocking review finding on this PR: the Admin usage report
has no `input_tokens` field. It returns `uncached_input_tokens`,
`cache_read_input_tokens`, and `cache_creation.ephemeral_5m_input_tokens`
+ `ephemeral_1h_input_tokens` as mutually exclusive pools —
Anthropic's own contract is `total prompt tokens = uncached_input_tokens +
cache_read_input_tokens + cache_creation_input_tokens`. This is the
opposite shape of OpenRouter's reasoning_tokens (already included inside
completion_tokens), which the prior wording wrongly used as the analogy.

- discover-anthropic-api.md (gcp-to-aws + azure-to-aws): Step 3 now reads
  uncached_input_tokens -> input_tokens, cache_read_input_tokens ->
  cache_read_tokens, and sums the two cache_creation sub-fields into
  cache_creation_tokens, instead of assuming input_tokens already exists
  on the response. Sort-by-volume instruction now includes both cache
  fields instead of just input_tokens + output_tokens.
- estimate-ai.md (gcp-to-aws + azure-to-aws): Prerequisites and Part 2 now
  instruct summing all four fields (input_tokens + cache_read_tokens +
  cache_creation_tokens + output_tokens) for total volume, instead of
  excluding the two cache fields as a supposed sub-accounting of input.
- clarify-ai.md / clarify-ai-only.md (both skills): Q18/Q19 auto-resolve
  and auto-detect logic updated to include cache tokens in the volume
  sum used for tier classification and top-model ranking.
- llm-to-bedrock/SKILL.md: Step 1.5's cross-skill profile-reuse sum
  updated to include cache tokens, with a pointer to the sibling skills'
  estimate-ai.md for the full field contract.

Net effect: a prompt-cached Claude workload (where cache reads are
typically the majority of input tokens) no longer has most of its real
token volume silently dropped from the Bedrock cost/sizing estimate.

Verified: Anthropic's own cookbook example (platform.claude.com/cookbook/
observability-usage-cost-api) confirms the real response field names
matching this fix. markdownlint-cli2: 0 errors on all 9 touched files.
llm-to-bedrock pytest: 251/251. test_model_id_lint.py: 11/11.
tools/validate.py: all validations passed.

* fix: trim llm-to-bedrock SKILL.md frontmatter description under 1024 chars

CI's lint:spec task failed: the description was 1072 chars, over the
repo's 1024-char limit. Trimmed redundant parenthetical examples and
restated the gcp/azure-preference clause more concisely with no
meaning lost. Verified: tools/validate_spec.py no longer reports the
length error (its remaining 3 errors are pre-existing .venv symlinks,
which are gitignored and not part of this diff). markdownlint-cli2: 0
errors. llm-to-bedrock pytest: 251/251 passed.

* fix(discover): correct usage-API request params and Azure capture ordering

- Azure discover-openai-api.md: usage endpoints (completions/embeddings/
  images/audio_speeches/audio_transcriptions) now request limit=31, not
  limit=180 (OpenAI's usage endpoints cap bucket_width=1d&limit at 31; the
  Costs endpoint's own max of 180 was copy-pasted onto usage rows).
- Both discover-anthropic-api.md copies: cost_report capture now loops once
  per selected workspace so costs_by_description[] carries workspace_id per
  row (previously only group_by=description, losing per-workspace
  attribution on multi-workspace selections). Consent block now discloses
  the Step 2b probe's org-wide per-workspace read.
- Azure discover.md: usage-API consent + capture steps now run after
  fragments/discover-assemble.md instead of as a pre-dispatch action, so
  their ai-workload-profile.json-based triggers see a profile that actually
  exists on a from-scratch run.
- Add tests/test_usage_api_request_params.py and
  tests/test_azure_discover_ordering.py as regression guards.

Addresses PR #425 Cursor review findings 1-3.

* fix: add cost_status/cost_provenance for cost-completeness tracking (PR425 findings 4,5)

* fix(discover): delete admin-key file on every terminal exit (PR425 finding 6)

Route Anthropic (both copies) and Azure OpenAI usage-discovery terminal
exits through key-file deletion, with an explicit KEY_INVALID_MID_RUN
retry_pending carve-out. Adds retry_pending to each manifest.json schema
and test_credential_lifecycle.py enforcing the contract.

* fix: Discover resume/schema consistency + GCP design guide selection

- Finding 7: gate Anthropic resume/postcondition checks on row status
  (captures[].status == ok), not bare manifest.json existence, in both
  gcp-to-aws and azure-to-aws discover.md, mirroring the OpenRouter sibling.
- Finding 8: drop the sdk_method qualifier from Anthropic's Step 4.4b
  sentinel-workload absence check (both copies), and add the equivalent
  workloads[] append to Azure's discover-openai-api.md Step 4. Widen
  detected_via to include usage_api in azure's schema-discover-ai.md.
- Finding 9: GCP design-ai.md's 'both' branch now selects guides by actual
  provider presence instead of hardcoding Gemini+OpenAI, mirroring Azure's
  existing conditional pattern.
- Add tests/test_resume_and_sentinel_consistency.py and
  tests/test_gcp_design_guide_selection.py.

* fix(llm-to-bedrock): defer usage-baseline write, fingerprint it, fix tiebreak (PR425 findings 10,11,15)

- Defer usage-baseline.json's write to A3, after $BEDROCK_RUN_DIR exists
- Pass a Usage baseline path line to C5/C6; report-generator reads it instead of assuming $BEDROCK_RUN_DIR
- Add usage_baseline_sha256 to current-context.json schema + MISMATCH table
- Replace unconditional lexicographic MMDD-HHMM tiebreak with last_updated-primary, year-aware logic; surface genuine ties to the user
- Add tests/test_llm_to_bedrock_run_state.py

* fix: report-generator cost-pricing + estimate/clarify volume resolution (PR425 findings 12-14)

Finding 12 (highest priority, numerically verified): cost_compare.py now
prices both source_cost and bedrock_cost for a baseline-covered model pair
from usage-baseline.json's real monthly token volume, never mixing it with
the golden-dataset sample volume on the other side of the same pair.
Uncovered pairs still fall back to the sample unchanged.

Finding 13: ported GCP's correct partial-provider-volume exception text
(unresolved + scenario rows) into Azure's estimate-ai.md Part 2.

Finding 14: Clarify's Q3 primary branch (azure-to-aws clarify-ai-only.md)
now checks partial_window/cost_status via current_costs provenance before
auto-resolving monthly AI spend; Discover's Step 4 merge in both Anthropic
copies and Azure's OpenAI copy now stamps those fields onto
current_costs/breakdown[] entries. GCP's own Clarify has no equivalent
auto-resolve shortcut today, so it has no equivalent bug (documented
skip-with-reason).

Verification: pytest tests/ -q -> 87 passed, zero regressions. New tests
exec the real embedded cost_compare.py script via subprocess against
constructed fixtures and assert on real numeric stdout.

* fix(aws-startup-advisor): scope OpenRouter workspace filtering and Azure AI-only phase gates

Fixes PR #425 findings 16/17: Design/Estimate phases now route-conditionally gate on
azure-resource-inventory.json vs ai-workload-profile.json (mirroring Clarify's existing
AI-only fork) instead of unconditionally requiring infra artifacts, and the assemblers
no longer fabricate empty infra files on AI-only runs. OpenRouter discovery (Azure +
GCP mirrors) now applies a real workspace_id filter at capture time instead of the
previously dead group_by=workspace parameter, with lifetime credits explicitly
relabeled account-wide when a workspace scope is set.

Also includes two small pre-existing markdownlint fixes unrelated to findings 16/17,
needed to get 'mise run build' green: a missing blank line before a list in
clarify-ai-only.md (MD032) and two headings in discover.md that skipped a level
(MD001, #### -> ###, matching the design doc's intended h3 nesting).

* fix: PR 425 review 5475407077 findings A, B, C

Finding A (blocking) - cost_report workspace filter: both
discover-anthropic-api.md copies (gcp-to-aws, azure-to-aws) replaced the
per-workspace cost_report loop with a single call using
group_by[]=workspace_id&group_by[]=description, since the endpoint has no
workspace_ids[] parameter at all. Rows are filtered client-side to the
selected workspace_ids after the one call returns. Updated the capture
table, Step 3 parsing prose, and the Error Handling row accordingly; the
Step 2b probe call is unchanged. Renamed
test_anthropic_cost_report_captures_once_per_workspace to
test_anthropic_cost_report_uses_single_call_with_compound_group_by in
test_usage_api_request_params.py to assert the new single-call contract and
that the cost_report table row no longer requests workspace_ids[].

Finding B (should-fix) - Priority Tier dollars excluded from cost_report:
both copies now add service_tier to Row 1's usage group_by so Priority rows
are observable, and Step 3 scans for service_tier in {priority,
priority_on_demand}. Decision: reused the existing cost_status enum's
partial_window value for this case rather than adding a 4th enum value,
since partial_window's downstream semantics ("real but incomplete total, not
a trustworthy monthly baseline") already match and no changes are needed in
estimate-ai.md or llm-to-bedrock/SKILL.md Step 1.5, which already treat
partial_window that way. monthly_cost_usd stays populated from the
standard/batch rows that did return (never nulled), and a capture_warnings
line is added. Added two new tests to test_cost_completeness.py covering
the service_tier detection and the complete-branch's new precondition.

Finding C (should-fix) - BYOK de-dupe for the only cost_provenance value this
flow writes: llm-to-bedrock/SKILL.md Step 1.5's unknown branch now matches
OpenRouter's provider/model-name usage_by_model[] rows against the direct
profile's bare model names (match = direct name equals the substring after
OpenRouter's last /) and excludes matching rows' dollars AND tokens from the
sum, keeping OpenRouter-only models. The byok_passthrough/mixed branch is
untouched.

Verification: uv run --with pytest python -m pytest tests/ -> 89 passed (87
baseline + 2 new for Finding B) from plugins/aws-startup-advisor. mise run
build: lint:manifests, lint:spec, lint:skill-parity, security scan all pass;
lint:md reports 70 pre-existing issues in 15 unrelated files (none touched
by this change). git diff --check: clean. git merge-tree --write-tree
upstream/main HEAD: no conflicts.

---------

Co-authored-by: Logan Kleier <lkleier@amazon.com>
Co-authored-by: Gen Li <i.ligen@gmail.com>
2026-10-09 22:46:37 +00:00
2026-04-23 12:44:11 +00:00
2026-04-23 12:44:11 +00:00

Agent Toolkit for AWS

License Build Status

Help AI coding agents build, deploy, and manage applications on AWS.

The Agent Toolkit for AWS gives AI coding agents the tools, knowledge, and guardrails they need to work with AWS services. It works with the coding agents developers already use — including Claude Code, Codex, Cursor, Kiro, and fx.

Quick start

AWS CLI

Use the Agent Toolkit directly from your terminal with the AWS CLI:

aws configure agent-toolkit

See the AWS CLI integration guide for setup, configuration, and usage instructions.

Claude Code

The plugins are available on the official Anthropic marketplace (claude-plugins-official) which is added to your Claude Code installation by default. Use the following commands to install supported plugins from the toolkit:

For aws-core that covers service selection, CDK/CloudFormation, serverless, containers, storage, observability, billing, SDK usage, and deployment:

/plugin install aws-core@claude-plugins-official

Tip: If you get Plugin not found, update your local marketplace index first:

/plugin marketplace update claude-plugins-official

For aws-agents that covers building AI agents on AWS with Amazon Bedrock and AgentCore:

/plugin install aws-agents@claude-plugins-official

For aws-data-analytics that covers data lake, analytics, and ETL workflows with S3 Tables, AWS Glue, and Athena:

/plugin install aws-data-analytics@claude-plugins-official

For aws-agents-for-devsecops used to investigate incidents, review code and execute UAT for release readiness, scan code for vulnerabilities, and run penetration tests with AWS DevOps Agent and AWS Security Agent.

/plugin marketplace add aws/agent-toolkit-for-aws
/plugin install aws-agents-for-devsecops
/reload-plugins

# Or from Claude's official marketplace:
/plugin install aws-agents-for-devsecops@claude-plugins-official
/reload-plugins

# Setup:
/aws-agents-for-devsecops:setup

For aws-startup-advisor that covers startup-focused architecture, cost, security, and AWS Activate guidance, plus migrations to AWS from Azure, GCP, Heroku, and AI stacks such as OpenAI and Gemini, install from this repository's marketplace:

/plugin marketplace add aws/agent-toolkit-for-aws
/plugin install aws-startup-advisor@agent-toolkit-for-aws
/reload-plugins

Codex

In your terminal:

codex plugin marketplace add aws/agent-toolkit-for-aws

Then launch Codex and run /plugins to browse and install the aws-core plugin.

Cursor

Add this repository as a team marketplace from Settings → Plugins → Team Marketplaces → Add Marketplace → Import from Repo, pointing it at aws/agent-toolkit-for-aws. Cursor indexes the plugins listed in .cursor-plugin/marketplace.json on import.

Then open the Plugins panel and install the aws-core plugin (start here), or aws-agents and aws-data-analytics as needed. Each plugin bundles the AWS MCP Server configuration and agent skills.

Kiro

Kiro setup has two independent parts: the AWS MCP Server (for runtime AWS API access and documentation search) and local skills (for task-specific agent guidance). They complement each other but work independently — skills don't require the MCP server, and the MCP server doesn't serve locally-installed skills.

1. Add the AWS MCP Server to your Kiro MCP configuration (.kiro/settings/mcp.json):

{
  "mcpServers": {
    "aws": {
      "command": "uvx",
      "args": [
        "mcp-proxy-for-aws-cli@latest",
        "https://aws-mcp.us-east-1.api.aws/mcp",
        "--metadata",
        "AWS_REGION=us-west-2"
      ]
    }
  }
}

The MCP server gives your agent access to AWS APIs, sandboxed script execution, and real-time documentation search.

2. Install skills from this repository:

npx skills add aws/agent-toolkit-for-aws/skills

This installs skill files to ~/.kiro/skills/ (global) or .kiro/skills/ (project-level). Each skill is a directory containing a SKILL.md file and optionally a references/ subdirectory with additional context the agent reads from the local filesystem when needed. Kiro discovers installed skills automatically and activates them on demand when a task matches.

Prerequisites: You need uv installed. An AWS account with credentials configured locally is required for API calls and script execution, but not for documentation search or skill discovery. See the user guide for detailed setup instructions.

fx

fx setup has the same two independent parts as Kiro: the AWS MCP Server (for runtime AWS API access and documentation search) and local skills (for task-specific agent guidance). Skills don't require the MCP server, and the MCP server doesn't serve locally-installed skills.

1. Add the AWS MCP Server from your terminal. fx stores MCP servers in ~/.fx/mcp.json, so the server is available in every project:

fx mcp add aws uvx mcp-proxy-for-aws-cli@latest https://aws-mcp.us-east-1.api.aws/mcp --metadata AWS_REGION=us-west-2

Or add it to ~/.fx/mcp.json by hand. fx uses the mcp key rather than mcpServers, type to select the transport, and a single command array holding the executable and its arguments:

{
  "mcp": {
    "aws": {
      "type": "local",
      "command": [
        "uvx",
        "mcp-proxy-for-aws-cli@latest",
        "https://aws-mcp.us-east-1.api.aws/mcp",
        "--metadata",
        "AWS_REGION=us-west-2"
      ]
    }
  }
}

If a session is already open when you edit the file, run /mcp reload to pick up the change. The MCP server gives your agent access to AWS APIs, sandboxed script execution, and real-time documentation search.

2. Install skills from this repository:

npx skills add aws/agent-toolkit-for-aws/skills -a fx

This installs skill files to .fx/skills/ (project-level); add -g to install to ~/.fx/skills/ (global). fx also discovers skills already installed for other agents in .agents/skills/, .claude/skills/, and .codex/skills/, so a project set up for Codex or Claude Code needs no second copy. Each skill is a directory containing a SKILL.md file and optionally a references/ subdirectory with additional context the agent reads from the local filesystem when needed. fx reads skill metadata at startup and loads a skill's instructions when you or the agent invokes it; type $ in the composer or run /skills to browse what's installed.

Prerequisites: You need uv installed. An AWS account with credentials configured locally is required for API calls and script execution, but not for documentation search or skill discovery. See the user guide for detailed setup instructions.

Other agents

See the AWS MCP Server getting started guide for instructions on configuring the AWS MCP Server with your agent.

Then install skills from this repository:

npx skills add aws/agent-toolkit-for-aws/skills

Prerequisites: You need uv installed. An AWS account with credentials configured locally is required for API calls and script execution, but not for documentation search or skill discovery. See the user guide for detailed setup instructions.

What's included

Plugins

Plugins bundle the AWS MCP Server configuration and agent skills into a single install for your coding agent.

Plugin Description
aws-core Core AWS skills and MCP Server configuration. Covers service selection, CDK/CloudFormation, serverless, containers, storage, observability, billing, SDK usage, and deployment. Start here.
aws-agents Skills for building AI agents on AWS with Amazon Bedrock and AgentCore.
aws-data-analytics Skills for data lake, analytics, and ETL workflows with S3 Tables, AWS Glue, and Athena.
aws-agents-for-devsecops Investigate incidents, review code and execute UAT for release readiness, scan code for vulnerabilities, and run penetration tests with AWS DevOps Agent and AWS Security Agent.
aws-startup-advisor Personalized AWS guidance for startups, built on patterns from 350,000+ startups. Covers architecture, cost, security, day-one account setup, AWS Activate credits eligibility and startup offers, and migration to AWS from Azure, GCP, Heroku, and AI stacks (Azure OpenAI/OpenAI/Gemini SDK rewrites to Amazon Bedrock, agentic systems to AWS-native runtimes).

Plugins are currently available for Claude Code, Codex, and Cursor. For other agents, configure the AWS MCP Server directly and install skills from this repository.

Skills

Agent skills are curated packages of instructions and reference materials that help agents complete specific AWS tasks. Skills are loaded on demand — agents discover and retrieve only what's relevant to the current task.

npx skills add aws/agent-toolkit-for-aws/skills

Browse the skills/ directory to see all available skills.

Rules files

Recommended project-level configuration files that tell agents how to use AWS most effectively — for example, by using the AWS MCP Server, discovering available skills, or searching documentation before acting.

See rules/ for details.

AWS MCP Server

The AWS MCP Server is a managed server that gives agents access to AWS through the Model Context Protocol. It provides:

  • Full AWS API coverage — Interact with any of the 300+ AWS services through a single authenticated endpoint.
  • Sandboxed script execution — Agents can run Python scripts in an isolated environment for complex multi-step operations.
  • Real-time documentation access — Search and retrieve current AWS documentation, API references, and service capabilities without authentication.
  • Enterprise controls — Amazon CloudWatch metrics, IAM context keys for agent-specific policies, and AWS CloudTrail audit logging.

For details on operation, available tools, authentication, and supported Regions, see the AWS MCP Server documentation.

Documentation

How the Agent Toolkit relates to the MCP servers, skills, and plugins in AWS Labs

In 2025, AWS began releasing MCP servers, skills, and plugins as part of AWS Labs. The Agent Toolkit for AWS is the successor to those tools. We recommend using the Agent Toolkit for AWS, because it offers key features including:

  • IAM condition keys that distinguish between agent actions and human actions, so you can write policies that apply only to agents. For example, you can write policies that only allow read-only actions through the MCP server, even if the user’s underlying IAM role can take write actions).
  • CloudWatch metrics and CloudTrail audit logging for every request, so you can monitor and audit coding agent activity.
  • Agent skills that have undergone thorough end-to-end evaluations, so you can be confident that workflows will complete successfully.

AWS Labs MCP servers, skills, and plugins will continue to work and accept contributions, and over time the best of AWS Labs will be transitioned to the Agent Toolkit for AWS to ensure that customers can access the broadest array of tooling and guidance for their agents.

License

This project is licensed under the Apache-2.0 License. See LICENSE for details.