Identity for AI demos Reference architecture
Reference architecturesAmazon Bedrock AgentCore

Securing AI agent tool calls on Amazon Bedrock AgentCore Gateway with Ping Identity

On this page

This reference architecture puts identity and fine-grained authorization around the tools an AI agent uses. The signed-in user's identity travels with every call, a central PingOne Authorize policy decides each MCP tool call at AgentCore Gateway, and sensitive calls wait for the user's approval on another device through CIBA.

It's distilled from a working demo: a user-admin agent on AgentCore Runtime that manages accounts in business systems through MCP servers. For step-by-step setup of the same deployment, see the setup guide. This page covers the design: the components, the trust between them, the decisions you'll make, and what we learned building it.

Who this is for

Architects and security engineers designing agentic applications on AWS with Ping Identity. It assumes working knowledge of OAuth 2.0, OpenID Connect and the Model Context Protocol (MCP).

When to use it

Use this pattern when:

Consider something else when the agent works with no user at all (a client credentials token has no user to carry forward, and the Gateway's targets list no tools for it), or when each MCP server must make its own authorization decisions.

Design principles

  1. The user's identity on every hop.Tokens are exchanged, never passed along. Each hop gets a new token that is valid only at the next hop, names the user in sub, and names who is acting for them in act (RFC 8693 token exchange).
  2. One decision point for every tool call.Authorization lives in PingOne Authorize, outside the agent and the MCP servers. The security team changes rules without redeploying either, and a tool nobody wrote a rule for is refused.
  3. The model never holds the approval.The policy asks for approvals and the Gateway's authorizer runs them. The agent, and anything that can inject a prompt into it, can't start, skip or fake one.
  4. Approvals are bound.An approval covers one user, one exact request, one use, for a limited time.
  5. Standard protocols and stock clients.OAuth 2.0 Token Exchange, OpenID CIBA, and MCP 2026-07-28 multi round-trip requests. Stock MCP clients complete approvals with no approval code in the agent.
  6. Refusals explain themselves.Every denial carries the policy's reason in plain words, and the agent shows it to the user.
  7. Fail closed.When the authorizer can't reach a decision, the call is refused.

Architecture

ArchitectureThe user signs in with PingOne SSO and chats through the chat app with the agent on AgentCore Runtime. The agent exchanges the user's token through AgentCore Identity and calls tools on AgentCore Gateway. The Gateway runs the Lambda authorizer, which asks PingOne Authorize, starts PingOne CIBA approvals that reach the user by email, and records approvals in DynamoDB. The Gateway then calls your MCP servers with a token minted for each server.PingOneAWS CloudYour MCP serversUserChat appYour frontendPingOne SSOSign-in, token exchangePingOne AuthorizeAPI Access ManagementPingOne CIBADaVinci approval flowUser's emailApprove or declineAgentCore IdentityCredential providersAmazon DynamoDBApproval recordsAWS LambdaAuthorizerAgentCore RuntimeAgentAgentCore GatewayMCP toolsMCP serverTarget 1MCP serverTarget 21Sign inPrompt + user token2Exchange2On-behalf-of token2tools/call + Gateway token3Interceptor3Sideband decision4CIBA request4Email56Server's own token
The reference deployment. Numbers follow one sensitive tool call; the steps are described under Architecture.
  1. The user signs in.The chat app signs the user in with PingOne (authorization code with PKCE). The token is valid only at the agent runtime.
  2. The agent gets a Gateway token and calls a tool.The agent exchanges the user's token through AgentCore Identity for one valid only at the Gateway, with act naming the agent, and sends tools/call to AgentCore Gateway.
  3. The authorizer asks PingOne Authorize.The Gateway runs the authorizer Lambda as its request interceptor. The Lambda sends the MCP request to PingOne Authorize API Access Management, which applies the policy: permit, deny with a reason, or ask for approval.
  4. A sensitive call waits for approval.The Lambda starts a CIBA request with PingOne, which reaches the user on another channel, and holds the call while it polls. The agent's MCP client retries the same call until the user answers.
  5. The approved call goes ahead once.The Lambda checks the approval belongs to this user and this request, asks PingOne Authorize again with a trusted approval header, and records the approval as used in DynamoDB.
  6. The MCP server gets its own token.The Gateway's target exchanges the Gateway token through AgentCore Identity for a token valid only at that MCP server, then forwards the call.
ComponentServiceRole
Chat appYour frontendSigns the user in and sends prompts to the agent with the user's token.
AgentAgentCore RuntimeValidates the user's token with its inbound JWT authorizer, gets a Gateway token through AgentCore Identity, and calls tools over MCP.
Token exchangeAgentCore IdentityOAuth credential providers run the on-behalf-of token exchanges with PingOne, one for the agent and one for the Gateway's targets, and keep their client secrets.
Tool gatewayAgentCore GatewayOne MCP endpoint for every tool. Validates the Gateway token, runs the authorizer on each request and response, and gets a new token for each target.
AuthorizerAWS LambdaSends each MCP request to PingOne Authorize, runs CIBA approvals when the policy asks, and enforces approval binding and single use.
Approval recordsAmazon DynamoDBBinds approvals to requests and records each use. Items expire on their own.
Identity providerPingOne SSOSigns users in, runs the token exchanges, and issues audience-restricted tokens that carry the user's application permissions.
Policy decision pointPingOne Authorize (API Access Management)Decides every MCP request from the token's permissions and the request body.
ApprovalsPingOne CIBA with a DaVinci flowAsks the user to approve or decline on another channel, such as email.
MCP serversYour servicesValidate their own tokens and run the tools.

Tokens on each hop

Three tokens carry the user through the system. Each is minted for one audience, so a token stolen from one hop is useless at the next.

Sign-in tokenGateway tokenMCP server token
IssuedTo the chat app at sign-inBy exchange, for the agentBy exchange, for the Gateway's target
AudienceThe agent runtimeAgentCore GatewayThat MCP server's URL
subThe userThe user, from the subject tokenThe user, from the subject token
actNoneThe agentThe Gateway acting for the agent, or the agent alone (see the Gateway hop)
Scopesagent:invokemcp:toolsThe scopes that server checks, for example crm:users.read
User's permissionsp1.permissionsp1.permissions, read by the policyNot needed
Validated byAgentCore Runtime's JWT authorizerThe Gateway's JWT authorizer, then PingOne AuthorizeThe MCP server itself

The user's permissions come from PingOne application roles (in the demo, help-desk with read and write, iam-admin adding delete). They reach tokens as p1.permissions, so the role check happens in PingOne and in the policy, never in the agent.

How each exchange works

Both exchanges use AgentCore Identity OAuth credential providers configured for on-behalf-of token exchange. Neither the agent nor the Gateway handles client secrets or talks to PingOne's token endpoint directly.

  1. Agent to Gateway. The agent calls GetWorkloadAccessTokenForJWT with the user's token, then GetResourceOauth2Token with oauth2Flow set to ON_BEHALF_OF_TOKEN_EXCHANGE and the Gateway's scopes.
  2. Gateway to MCP server. Each target's credential provider configuration has grantType TOKEN_EXCHANGE and the server's scopes. The Gateway runs the exchange for every call, with the Gateway token as the subject.

In both, the credential provider first gets an actor token: a client credentials token for its own PingOne application, for a dedicated actor scope. It then sends PingOne a token exchange request with the user's token as subject_token, the actor token as actor_token, the requested scopes, and its own client authentication. PingOne picks the audience from the scopes and builds the new token's claims with attribute mappings on that resource: sub from the subject token, act from the actor token.

Credential provider with on-behalf-of exchange
{
  "name": "agent-obo",
  "credentialProviderVendor": "CustomOauth2",
  "oauth2ProviderConfigInput": {
    "customOauth2ProviderConfig": {
      "oauthDiscovery": { "discoveryUrl": "<DISCOVERY_URL>" },
      "clientId": "<AGENT_APP_ID>",
      "clientSecret": "<AGENT_APP_SECRET>",
      "clientAuthenticationMethod": "CLIENT_SECRET_BASIC",
      "onBehalfOfTokenExchangeConfig": {
        "grantType": "TOKEN_EXCHANGE",
        "tokenExchangeGrantTypeConfig": {
          "actorTokenContent": "M2M",
          "actorTokenScopes": ["actor"]
        }
      }
    }
  }
}
Important

AgentCore Identity sends the generic JWT token type as subject_token_type by default, and PingOne rejects it. Send subject_token_type urn:ietf:params:oauth:token-type:access_token as a custom parameter on both exchanges: in the agent's GetResourceOauth2Token call and in each target's credential provider configuration.

Limiting who can exchange

PingOne details that shape the design

Delegation or impersonation at the Gateway

The first exchange is always delegation: the agent presents an actor token, and the Gateway token names the agent in act. At the second exchange you choose whether the Gateway presents its own actor token.

DelegationImpersonation
Actor token at the Gateway's exchangeYes: actorTokenContent M2MNo: actorTokenContent NONE
MCP server token's actThe Gateway, acting for the agent (nested, RFC 8693 section 4.1)The agent, carried over from the Gateway token
What the MCP server can seeUser, agent and GatewayUser and agent
What limits the exchangeThe exchange application's scope access, plus the act mappingThe exchange application's scope access
Actor resource used at this hopYesNo
Choose it whenDownstream services audit or authorize on the full chain, or must know a call came through the GatewayYou treat the Gateway as infrastructure rather than an actor, and want the simpler configuration

In this architecture the MCP servers don't authorize on act; the policy at the Gateway does. So the choice changes what the server's token records, not what is enforced. AgentCore Identity also accepts AWS_IAM_ID_TOKEN_JWT as actor token content, which this architecture hasn't evaluated.

Policy at the Gateway

AgentCore Gateway runs a Lambda interceptor on every MCP request and response. The authorizer Lambda sends each request to PingOne Authorize API Access Management through its sideband API, so the Gateway is protected the way any other API behind PingOne Authorize is. In API Access Management, the Gateway is one API service with one operation, POST /mcp, because every MCP request goes there. The policy reads the rest from the request.

The policy readsFromExample
The user's permissionsThe validated Gateway tokenusers:read, users:delete
JSON-RPC methodBody, $.methodtools/call
ToolBody, $.params.name, as <target>___<tool>crm___delete_user
Tool argumentsBody, $.params.argumentsuser_name, email
ApprovalHeader x-ciba-approval, which only the authorizer can setapproved

A policy shaped like this covers most tool sets. Order matters: rules are checked first to last.

#WhenEffect
1The request isn't a tool call (initialize, tools/list)Permit
2The tool's operation (read, write or delete) isn't in the user's permissionsDeny, with reason
3The arguments name something the user may not touch, such as an account outside the managed setDeny, with reason
4A sensitive tool, and x-ciba-approval isn't approvedAsk for approval
5A known tool that passed the checks abovePermit
6Anything else, including tools added laterDeny, with reason

What the agent receives

OutcomeResponse to the MCP client
PermitThe tool's result
Policy denialHTTP 200, JSON-RPC error -32081; message is the rule's reason
Approval pendingHTTP 200, result input_required with a sealed requestState
Authorizer refusalHTTP 200, JSON-RPC error -32080 with data.reason, such as approval_denied, approval_expired, approval_mismatch or approval_already_used
No decision possibleHTTP 5xx, -32603: the authorizer fails closed

Refusals travel in-band as HTTP 200 JSON-RPC errors on purpose. A transport-level 401 or 403 ends a stock MCP client's session, and most clients pass the model only the error's message, so the reason goes there in plain words.

Approvals with CIBA

If the agent started approvals, the model would be in the loop, and a prompt injection could skip the step or get something else approved. So the policy decides when an approval is needed, and the authorizer runs OpenID CIBA (Client-Initiated Backchannel Authentication) itself. The user answers on another channel, such as an email link or a push notification, and the call goes ahead only after that.

Approval sequenceThe agent calls a delete tool. The authorizer asks PingOne Authorize, which asks for approval. The authorizer starts a CIBA request, holds the call while polling, and returns input_required with a sealed requestState. The client retries the same call with requestState. After the user approves, the authorizer checks the approval, asks PingOne Authorize again with a trusted approval header, records the approval as spent in DynamoDB, and forwards the call to the MCP server with its own token.AgentMCP clientAgentCoreGatewayAuthorizerLambdaPingOneAuthorizePingOneCIBADynamoDBApproval recordsUser'sdeviceMCPserverFirst call: the policy asks for approvaltools/call with the Gateway tokenRequest interceptorSideband requestDeny, challenge ciba-approvalCIBA request, code APR-4821Approval requestBind approval to requestHold up to 20 s, polling: pendinginput_required + requestStateinput_required (HTTP 200)Retry: the client sends the same call with requestStateSame tools/call + requestStateRequest interceptorCheck seal, caller, request, expiryUser approvesPollApproved, approver's tokensApprover is the caller?Sideband request + x-ciba-approvalPermitRecord approval as spent (once)Forward, approval fields removedtools/call with the server's own tokenResultResult
One approval from first call to result. If the user approves during the first hold, the call goes ahead without the retry.

The authorizer returns the MCP 2026-07-28 input_required result, the protocol's multi round-trip request, with only an opaque requestState. It means "not yet, call again". This suits CIBA:

GuaranteeHow it's enforced
The same userThe approver's sub must equal the caller's. requestState names the caller and is refused for anyone else.
The same requestrequestState carries a SHA-256 fingerprint of the method and parameters. The approval is also bound to the request in DynamoDB before it's redeemed (with PingFederate, through authorization_details).
OnceA conditional write of a spent record in DynamoDB. A second use is refused with approval_already_used.
For a limited timeThe CIBA request's expiry, and an expiry inside requestState.
Only the authorizer marks a call approvedThe trusted x-ciba-approval and x-ciba-approver headers are stripped from every client request; the authorizer sets them only after checking the approval.
No tamperingrequestState is sealed with HMAC-SHA256 and a secret key. It's readable, so it never carries secrets.

The authorizer removes requestState, inputResponses and the trusted headers before it forwards the call, so MCP servers never see the approval machinery. The user sees the approval code (such as APR-4821) in the approval request. Stock clients don't expose it to the app; an agent that drives the rounds itself (allow_input_required=True in MCP SDK 2.x) can show it in the chat after the first round.

Approval records

The authorizer is stateless, and the identity provider records that an approval was given, not which request used it. A small DynamoDB table fills that gap.

RecordWrittenPurpose
request#…When the CIBA request starts (PingOne)Binds the approval to the exact request. Checked before the approval is redeemed, so a mismatched request can't use it up.
spent#…When an approved call is forwarded, as a conditional putMakes each approval usable once.

Protocol and clients

Approvals rely on MCP 2026-07-28 multi round-trip requests, so the Gateway offers only that version. Older clients can't connect, rather than connecting and failing at their first approval.

Gateway configuration (excerpt)
"protocolType": "MCP",
"protocolConfiguration": {
  "mcp": { "supportedVersions": ["2026-07-28"] }
},
"authorizerType": "CUSTOM_JWT",
"authorizerConfiguration": {
  "customJWTAuthorizer": {
    "discoveryUrl": "<DISCOVERY_URL>",
    "allowedAudience": ["<GATEWAY_AUD>"],
    "allowedScopes": ["mcp:tools"]
  }
}
Known issue

AgentCore Gateway currently passes the client's 2026-07-28 fields in params._meta on to MCP servers it talks to at an older version. A server that ignores them works. A server that checks them against the request's headers refuses every request. The authorizer can't remove them, because the Gateway requires them in its output. Test each MCP server behind the Gateway before you rely on it.

MCP server requirements

Variant: PingFederate

Organizations that run PingFederate can keep it as the authorization server and still use PingOne MFA for approvals and PingOne Authorize for decisions.

Architecture with PingFederateThe user signs in with PingFederate, which runs on Amazon EC2 in the AWS Cloud, and chats through the chat app with the agent on AgentCore Runtime. The agent exchanges the user's token with PingFederate through AgentCore Identity and calls tools on AgentCore Gateway. The Gateway runs the Lambda authorizer, which asks PingOne Authorize for a decision and sends CIBA requests to PingFederate. PingFederate's PingOne MFA CIBA Authenticator sends the approval prompt through PingOne MFA to the user's phone, and the Lambda records each used approval in DynamoDB. The Gateway then calls your MCP servers with a token minted for each server.AWS CloudAmazon EC2PingOneYour MCP serversUserChat appYour frontendPingFederateSign-in, token exchange, CIBAPingOne MFAApproval promptsPingOne AuthorizeAPI Access ManagementUser's phonePingOne MFA appAgentCore IdentityCredential providersAmazon DynamoDBUsed approvalsAWS LambdaAuthorizerAgentCore RuntimeAgentAgentCore GatewayMCP toolsMCP serverTarget 1MCP serverTarget 21Sign inPrompt +user token2Exchange2On-behalf-of token2tools/call + Gateway token3Interceptor3Sidebanddecision4CIBA request4Out-of-bandrequest4Push56Server'sown token
PingFederate signs users in, exchanges tokens and runs CIBA, with PingOne MFA pushing approvals to the user's phone. PingOne Authorize still decides every call.
Reference (PingOne)PingFederate variant
Sign-in and token exchangePingOne SSOPingFederate, self-managed, for example on Amazon EC2
Approval channelPingOne CIBA with a DaVinci flow (email in the demo)PingFederate CIBA with the PingOne MFA Integration Kit's CIBA authenticator, pushing to the PingOne MFA app
Authorizer settingCIBA_PROVIDER=pingoneCIBA_PROVIDER=pingfederate
Binding messageUp to 8 charactersUp to 20 characters
Binding the approval to the requestrequest record in DynamoDBauthorization_details (PingFederate 11.2 or later)
Single usespent record in DynamoDBspent record in DynamoDB
PolicyPingOne AuthorizePingOne Authorize

Points to design for in this variant:

Security checklist

Timing and limits

An approval has to fit inside the client's patience and the Lambda's timeout. These values work together; change them together.

SettingDemo valueConstraint
Hold per round (CIBA_HOLD_SECONDS)20 sWell under the Lambda timeout, and under the client's read timeout
Client retries10Fixed in MCP SDK 2.x and Strands Agents, almost no pause between rounds
Client's total waitAbout 220 sThe first call plus 10 retries, each held up to 20 s
Approval lifetime (CIBA_REQUESTED_EXPIRY)180 sBelow the client's total wait, so the user gets approval_expired instead of a generic error. PingOne allows up to 300 (default 120).
Lambda timeout60 sThe hold plus a sideband call, a provider poll and two DynamoDB calls
Binding messageAPR-4821PingOne: up to 8 characters. PingFederate: up to 20.
Approval records24 hNever shorter than the approval lifetime
Forwarded header size4 KBAn AgentCore limit. Response-phase authorization passes about 6 KB of state in a header, so the demo turns it off.

Other limits of the authorizer as built for the demo: streaming responses pass through without response-phase authorization, batched JSON-RPC requests can't be approved, and the header that carries a denial's reason from the request phase to the response phase isn't signed.

Lessons from the demo

  1. Don't echo the Authorization header. When an interceptor returns one, AgentCore sends it to the target instead of the token the target's exchange would mint. Every user saw an empty tool list until the authorizer stopped returning it.
  2. Pass unchanged responses through explicitly. If the response interceptor returns nothing, AgentCore sends the client an empty {}.
  3. Set the subject token type on every exchange. AgentCore's default generic JWT type is rejected by PingOne.
  4. Return refusals as HTTP 200 JSON-RPC errors. A 403 ends a stock client's session, and clients drop error data the model never sees.
  5. Give people time to find the approval, but less than the client waits. Email approvals need more than PingOne's 120-second default; 180 seconds still ends before the client gives up.
  6. Test with real users. Targets list their tools by exchanging the user's token, so a client credentials token sees no tools, and a smoke test with one proves little.
  7. Try every MCP server behind 2026-07-28 before you rely on it (see the known issue under Protocol and clients).
  8. Resend the full Gateway configuration on every update. A partial update-gateway silently drops the protocol version list and the interceptors.
  9. Mind the CA bundle. MCP SDK 2.x uses httpx2, which trusts the operating system's certificate store rather than certifi. Runtime images without one need verify=ssl.create_default_context(cafile=certifi.where()).

Verify a deployment

AsTryExpect
A user who may readA look-upThe tool runs. The MCP server receives a token with its own audience, the user as sub, and act.
A user who may not deleteA delete-32081 with the rule's reason. The MCP server is never called.
A user who may deleteA delete, then approveAn approval request with a code. The client retries on its own, and the delete runs once.
A user who may deleteA delete, then decline-32080 with approval_denied. The MCP server is never called.
Any userReplay an approved call's requestState, or change its arguments-32080. The MCP server is never called.
AnyConnect with an MCP SDK 1.x clientThe client can't connect: the Gateway offers only 2026-07-28.

Related resources

Based on the demo as deployed in November 2026, with MCP protocol version 2026-07-28: AgentCore Runtime, Identity and Gateway, PingOne SSO, PingOne Authorize API Access Management, and PingOne CIBA.