MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / FlagsmithAuth

Class FlagsmithAuth

mcp/src/flagsmith_mcp/auth.py:7–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6
7class FlagsmithAuth(httpx.Auth):
8 def __init__(self, global_master_api_key: str | None = None) -> None:
9 self._global_master_api_key = global_master_api_key
10
11 def auth_flow(
12 self, request: httpx.Request
13 ) -> Generator[httpx.Request, httpx.Response, None]:
14 if "authorization" not in request.headers:
15 # Prefer the caller's forwarded MCP `--header`; fall back to the
16 # server's own static token (the only credential under stdio).
17 forwarded = get_http_headers(include={"authorization"})
18 if (
19 authorization := forwarded.get("authorization")
20 or self._global_authorization_value()
21 ):
22 request.headers["authorization"] = authorization
23 yield request
24
25 def _global_authorization_value(self) -> str | None:
26 if self._global_master_api_key:
27 return f"Api-Key {self._global_master_api_key}"
28 return None

Callers 1

create_serverFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…