How to access HTTP request headers (JWT) in a Ballerina MCP service for tool calls?
04:35 02 Jun 2026

I am building an MCP (Model Context Protocol) server using Ballerina and exposing tools for an AI agent. I need to fetch user-specific data from a JWT (passed in the Authorization header of the HTTP request) to authorize and customize the behavior of my tool calls.

Since Ballerina's MCP implementation abstracts the transport layer, my onCallTool method only gives me access to the mcp:CallToolRequest and mcp:Session objects.

jwt http-headers ballerina model-context-protocol mcp-server