Add Bedrock Mantle with native IAM credentials and GPT/Claude routing - #35
Add Bedrock Mantle with native IAM credentials and GPT/Claude routing#35edwardsb wants to merge 1 commit into
Conversation
|
hey @alexshapalov , I work mostly in AWS and I am in the progress of standing up pgbot mcp server in https://github.com/obot-platform/obot using their MCP Gateway. I needed a way for pgbot to use AWS Bedrock via IAM. This is working in my environment, so let me know what you think. Thanks. |
Code reviewFound 3 issues, plus one decision that is the maintainer's rather than a review finding.
Lines 84 to 91 in 606df5f
Lines 30 to 32 in 606df5f
Lines 77 to 81 in 606df5f Verified as correct: the bearer-token construction matches AWS's reference token generator field for field (and the golden-signature test proves it), the 15-minute TTL is clamped to credential expiry, redirects are refused, the host is re-checked on every request, credential retrieval is lazy so no AWS network call happens before the consent prompt, and nothing secret reaches error messages. For the maintainer. This PR adds 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Correction to item 1 above: the head commit already carries an |
|
The SDK-free rework is up as #37: your commit 2998a37 unchanged plus one commit replacing aws-sdk-go-v2 with a standard-library SigV4 presigner over environment credentials ( |
Adds
PGBOT_AI_PROVIDER=bedrock(aliasmantle) for AWS Bedrock Mantle, with bearer-token authentication or native IAM credentials from the AWS SDK credential chain, includingAWS_PROFILE.openai.*models through the existing Responses client andanthropic.*models through the Messages client.openai.gpt-5.6-terra. Region selection usesAWS_REGION, thenAWS_DEFAULT_REGION, then the SDK configuration for IAM authentication, thenus-east-1.PGBOT_AI_API_KEYorAWS_BEARER_TOKEN_BEDROCK; otherwise derives short-lived bearer tokens locally from AWS credentials. IAM authentication restricts requests to the configured regional Mantle HTTPS endpoint, and redirects are disabled.openai.model prefix for reasoning models, omits temperature for those models, and retains the upstream Responses token-budget floor andstore=falsebehavior.Validation:
go test ./...,go test -race ./...,go vet ./..., and a static CLI build. Tests cover Responses request shape, IAM profile credentials, token signing and expiry, endpoint restrictions, redirect handling, and GPT/Claude routing.The AWS SDK credential chain is intentional: native profile, SSO, and workload-role resolution and refresh support the AWS deployment use case without a separate credential-export step. Supplied bearer tokens bypass the chain. The SDK dependency tradeoff remains for maintainer approval.
Auth headers are selected from the model family, including when the base URL is overridden. Regression tests cover Anthropic without an
/anthropicpath and OpenAI with one. The provider list, privacy documentation (including credential-service calls), changelog, and unknown-provider error include Bedrock/Mantle.