awslabs / awslabs/agentcore-samples
Amazon Bedrock AgentCore Samples - [Bug] MCP example doesn't surface correct exception
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 1.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 30
Description
**Describe the bug**
Customer was seeing the issue:
```
bash> python my_mcp_client_remote.py
Using AWS region: us-west-2
Retrieved Agent ARN: arn:aws:bedrock-agentcore:us-west-2::runtime/mcp_server-zzzzzzz
✓ Retrieved bearer token from Secrets Manager
Connecting to: https://bedrock-agentcore.us-west-2.amazonaws.com/runtimes/arn%3Aaws%3Abedrock-agentcore%3Aus-west-2%3A256215987095%3Aruntime%2Fmcp_server-kOjvNZ4q0I/invocations?qualifier=DEFAULT
Headers configured ✓
🔄 Initializing MCP session...
❌ Error connecting to MCP server: unhandled errors in a TaskGroup (1 sub-exception)
```
Underlying issue was:
```
com.amazon.awsrequestauth.exception.UnauthorizedInboundTokenException: Token has expired
at com.amazon.awsrequestauth.validator.BearerTokenValidator.validateTokenTimeboundPayload(BearerTokenValidator.java:156)
```
**Expected behavior**
Can we transparently surface exceptions, atleast enable debug log in our samples
Contributor guide
Research direction
Start with the my_mcp_client_remote.py sample and reproduce the shown connection flow, including the expired-token case. Trace how the MCP initialization error is reported; done means the underlying token exception is surfaced or debug logging is enabled clearly enough to identify it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100