stampAuth attaches the configured bearer and authorizer URL to the outgoing gRPC call. A no-op when neither is set. This is the bridge that lets gRPC handlers see "who is calling" (security audit H1) and which host minted the token (issuer validation) when invoked from MCP.
(ctx context.Context)
| 147 | // lets gRPC handlers see "who is calling" (security audit H1) and which |
| 148 | // host minted the token (issuer validation) when invoked from MCP. |
| 149 | func (s *Server) stampAuth(ctx context.Context) context.Context { |
| 150 | if s.bearer != "" { |
| 151 | ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+s.bearer) |
| 152 | } |
| 153 | if s.authorizerURL != "" { |
| 154 | ctx = metadata.AppendToOutgoingContext(ctx, "x-authorizer-url", s.authorizerURL) |
| 155 | } |
| 156 | return ctx |
| 157 | } |
| 158 | |
| 159 | // registerTool wires one ToolBinding into the MCP server. The handler: |
| 160 | // 1. Constructs a fresh proto.Message of the right type via dynamicpb |
no outgoing calls