awslabs / awslabs/agentcore-samples

[Help] AgentCore Gateway - Outbound Auth Code Grant using Strand Agents

Open
#802 0 comments 0 reactions 1 assignee Claimed by @EashanKaushik View on GitHub
help wanted
Dominant language
Python
Stars
3.4k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
30

Description

## Summary
I was following the [AgentCore-gateway/12-outbound-auth-code-grant](https://github.com/awslabs/amazon-bedrock-agentcore-samples/tree/main/01-tutorials/02-AgentCore-gateway/12-outbound-auth-code-grant) tutorial. Unfortunately, I wasn't able to perform the 3LO-Oauth of an AgentCore Gateway tool using Strands Agents.

## Details
Based on the above tutorial, I tried the following approach:
```python
from mcp.client.streamable_http import streamablehttp_client
from strands.tools.mcp.mcp_client import MCPClient
from strands import Agent

def create_streamable_http_transport():
return streamablehttp_client(gateway_url, headers={
"Authorization": f"Bearer {bearer_token}",
'MCP-Protocol-Version': '2025-11-25',
})
mcp_client = MCPClient(create_streamable_http_transport)

prompt = "Give me the LinkedIn user info"
with mcp_client:
tools = mcp_client.list_tools_sync()
print(f"Found tools: {[tool.tool_name for tool in tools]}")
agent = Agent(
name="tools-3l-oauth-agent",
description="3L-Oauth MCP Tools agent.",
model="global.anthropic.claude-haiku-4-5-20251001-v1:0",
tools=tools,
)
response = agent(prompt)
```

The tool call fails as expected (I need to authenticate). However, it only sends the error message to the agent (`This request requires more information.`), but not the elicitation data (callback URL) that is retrieved by the MCP call.
```bash
2025-12-22 21:28:23,532 | INFO | httpx | HTTP Request: POST https://gateway-authcode-20251222-XXXXXX-vw088gz3mp.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp "HTTP/1.1 200 OK"
2025-12-22 21:28:23,534 | INFO | mcp.client.streamable_http | Negotiated protocol version: 2025-11-25
2025-12-22 21:28:23,639 | INFO | httpx | HTTP Request: POST https://gateway-authcode-20251222-XXXXXX-vw088gz3mp.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp "HTTP/1.1 202 Accepted"
2025-12-22 21:28:23,767 | INFO | httpx | HTTP Request: POST https://gateway-authcode-20251222-XXXXXX-vw088gz3mp.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp "HTTP/1.1 200 OK"
Found tools: ['x_amz_bedrock_agentcore_search', 'LinkedInAuthCode___getUserInfo']

Tool #1: LinkedInAuthCode___getUserInfo
2025-12-22 21:28:25,331 | INFO | httpx | HTTP Request: POST https://gateway-authcode-20251222-XXXXXX-vw088gz3mp.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp "HTTP/1.1 200 OK"
2025-12-22 21:28:25,333 | ERROR | strands.tools.mcp.mcp_client | tool execution failed
Traceback (most recent call last):
File "/opt/conda/lib/python3.12/site-packages/strands/tools/mcp/mcp_client.py", line 523, in call_tool_async
call_tool_result: MCPCallToolResult = await asyncio.wrap_future(future)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/strands/tools/mcp/mcp_client.py", line 761, in run_async
return await invoke_event
^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/strands/tools/mcp/mcp_client.py", line 517, in _call_tool_async
return await cast(ClientSession, self._background_thread_session).call_tool(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/mcp/client/session.py", line 383, in call_tool
result = await self.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/mcp/shared/session.py", line 306, in send_request
raise McpError(response_or_error.error)
mcp.shared.exceptions.McpError: This request requires more information.
```

What is the proper way to perform the 3LO-Oauth of an AgentCore Gateway tool using Strands Agents? An additional tutorial addressing this case would be awesome!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.