RequestHeadersProvider typedef
RequestHeadersProvider =
FutureOr<Map<String, String> > Function(({String method, String url}) request)
Supplies headers for one outbound request.
Called per request, which is the point: StreamableHttpTransportConfig.headers
is fixed when the transport is built, so anything that expires — an
attestation token, a short-lived session credential — cannot live there. A
host that has to fetch the value at call time needs this instead.
Receives the request being made so one provider can serve several transports and decide per destination.
Whatever it returns is added to the request, except the names the protocol
owns (see reservedHeaderNames). Those are dropped rather than honoured: a
supplied MCP-Session-Id or Content-Type would break the exchange in a
way that looks like a server fault.
Implementation
typedef RequestHeadersProvider = FutureOr<Map<String, String>> Function(
({String url, String method}) request,
);