Documentation
¶
Index ¶
- func BuildMCPCallbackBaseURL(ctx *schemas.BifrostContext) string
- func BuildOAuthRedirectURIFromContext(ctx *schemas.BifrostContext) string
- func CanonicalizeHeaderKey(key string) string
- func CanonicalizeHeaderKeys(keys []string) []string
- func CanonicalizeHeaderMap(m map[string]string) map[string]string
- func ExtractFilteredExtras(ctx context.Context, config *schemas.MCPClientConfig) http.Header
- func FlattenHeaders(h http.Header) map[string]string
- func StaticConfigHeaders(config *schemas.MCPClientConfig) http.Header
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildMCPCallbackBaseURL ¶ added in v1.5.14
func BuildMCPCallbackBaseURL(ctx *schemas.BifrostContext) string
BuildMCPCallbackBaseURL extracts the base URL set on the BifrostContext by the HTTP middleware (e.g. "https://host"). Per-user OAuth and per-user headers resolvers append their respective paths on top.
Trailing slashes are stripped defensively. The sole writer today (lib/ctx.go BuildBaseURL) already normalizes, but OAuth providers match redirect URIs exactly — a `https://host//api/oauth/callback` produced by a future writer that forgets to trim would silently break every per-user OAuth flow. Guarding once on the read side keeps that invariant local to this function rather than spread across every potential writer.
func BuildOAuthRedirectURIFromContext ¶ added in v1.5.14
func BuildOAuthRedirectURIFromContext(ctx *schemas.BifrostContext) string
BuildOAuthRedirectURIFromContext returns the full OAuth callback URL ("<base>/api/oauth/callback") needed by the per-user OAuth flow, or empty if the base URL is unavailable.
func CanonicalizeHeaderKey ¶ added in v1.5.14
CanonicalizeHeaderKey returns the canonical lowercase + trimmed form of a single header key. Empty input returns empty.
func CanonicalizeHeaderKeys ¶ added in v1.5.14
CanonicalizeHeaderKeys returns a new slice with every entry passed through CanonicalizeHeaderKey. Nil in → nil out so a caller that uses "nil means preserve existing" semantics (e.g. resolvePerUserHeaderKeys, UpdateMCPClientConfig) keeps that signal. The input slice is not mutated.
func CanonicalizeHeaderMap ¶ added in v1.5.14
CanonicalizeHeaderMap returns a new map whose keys are passed through CanonicalizeHeaderKey. On collision (e.g. "Authorization" and "authorization" both present in the input), the last value wins — callers that need duplicate detection should run it on the raw input before calling this. Nil in → nil out.
func ExtractFilteredExtras ¶ added in v1.5.14
ExtractFilteredExtras returns just the per-request "extra" headers carried in the BifrostContext (BifrostContextKeyMCPExtraHeaders), scoped by the client's AllowedExtraHeaders. Static config headers are NOT included here — those live on the upstream transport via StaticConfigHeaders and apply automatically to every message it carries. This function exists for the per-message CredentialStore.RequestHeaders path on shared connections.
func FlattenHeaders ¶ added in v1.5.14
FlattenHeaders converts an http.Header into a map[string]string suitable for mcp-go's transport.WithHTTPHeaders, used for both shared persistent connections (clientmanager) and ephemeral per-call connections (AcquireClientConn). Multi-value headers collapse to their first value.
func StaticConfigHeaders ¶ added in v1.5.14
func StaticConfigHeaders(config *schemas.MCPClientConfig) http.Header
StaticConfigHeaders returns the admin-configured static headers from config.Headers MINUS any header whose name is a credential — Authorization always, plus any name declared in config.PerUserHeaderKeys. These are the headers that are safe to expose to MCP connect-plugins via the PreConnectionHook gate — plugins may add, remove, or rewrite them.
Why exclude:
- Authorization: credential by definition. The CredentialStore resolver for the active auth type emits the final value (config bearer for MCPAuthTypeHeaders; dynamic token for OAuth-flavored types).
- PerUserHeaderKeys: credential schema for MCPAuthTypePerUserHeaders. If an admin accidentally (or deliberately) baked one of these names into config.Headers with a static value, exposing it to plugins would leak the static fallback. The per-user-headers resolver emits the caller's value; the static fallback should never reach the wire (and never reach plugins) for per-user-headers clients.
Comparison is case-insensitive because HTTP headers are case-insensitive on the wire but case-sensitive in Go maps.
Types ¶
This section is empty.