Skip to content

weather_service: forward inbound Authorization header to MCP tool calls#203

Merged
huang195 merged 1 commit intokagenti:mainfrom
huang195:forward-token-weather-service
Mar 26, 2026
Merged

weather_service: forward inbound Authorization header to MCP tool calls#203
huang195 merged 1 commit intokagenti:mainfrom
huang195:forward-token-weather-service

Conversation

@huang195
Copy link
Copy Markdown
Contributor

Summary

  • Forward the inbound Authorization header from A2A requests to outbound MCP tool calls in the weather_service agent
  • Add optional headers parameter to get_mcpclient() in graph.py
  • Extract Authorization from context.call_context.state in agent.py and pass it through

Same pattern as the git_issue_agent change in c8ebde1.

Why

When the weather_service agent is deployed behind a token exchange proxy (e.g., Istio waypoint with ext_authz, or AuthBridge), the proxy needs the Authorization header on outbound requests to perform RFC 8693 token exchange. Without this change, the MCP client makes unauthenticated calls to the tool, which the proxy rejects.

Test plan

  • Deploy weather_service behind waypoint proxy with token exchange enabled
  • Chat with the agent via kagenti UI
  • Verify token-exchange-service logs show both inbound and outbound exchanges

Generated with Claude Code

@huang195 huang195 force-pushed the forward-token-weather-service branch from 6bf3f3c to 4d7a28f Compare March 26, 2026 14:01
Same pattern as git_issue_agent (c8ebde1): extract the inbound
Authorization header from context.call_context.state and pass it
to the MCP client via the headers config. This enables transparent
token exchange when the agent is deployed behind a waypoint proxy
or AuthBridge — the outbound MCP call carries the token so the
proxy can validate and exchange it for the tool's audience.

Signed-off-by: Hai Huang <huang195@gmail.com>
@huang195 huang195 force-pushed the forward-token-weather-service branch from 4d7a28f to 4a7f60e Compare March 26, 2026 14:03
Copy link
Copy Markdown
Contributor

@esnible esnible left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are great! A few nits, not needed for merge.

It would also be awesome if somehow the traceparent header could be processed and/or forwarded to the MCP tool. I don't know if that should be in the same PR as this one.

}
if headers:
mcp_config["headers"] = headers
return MultiServerMCPClient({"math": mcp_config})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return MultiServerMCPClient({"math": mcp_config})
return MultiServerMCPClient({"weather": mcp_config})

This isn't your fault, but some (generated?) code is calling weather a math tool.


# Forward inbound Authorization header to outbound MCP tool calls.
# This enables transparent token exchange when deployed behind a waypoint
# or AuthBridge proxy (same pattern as git_issue_agent, see c8ebde1).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or AuthBridge proxy (same pattern as git_issue_agent, see c8ebde1).
# or [AuthBridge](https://github.com/kagenti/kagenti-extensions/tree/main/AuthBridge) proxy (same pattern as git_issue_agent, see c8ebde1).

@huang195 huang195 merged commit 6e62eec into kagenti:main Mar 26, 2026
9 checks passed
@huang195 huang195 deleted the forward-token-weather-service branch March 26, 2026 16:05
huang195 added a commit to huang195/authbridge-waypoint that referenced this pull request Mar 26, 2026
Remove the local patch overlay now that the token forwarding change
has been submitted upstream (kagenti/agent-examples#203). The official
image will include the Authorization header forwarding once merged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants