Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/_experimental/mcp_server/outbound_credentials/presented_token_store.py: 88%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 12:01 +0000

1"""One-shot ``OAuthTokenStore`` for the create/test tools preview. 

2 

3The preview tests an unsaved server, so no per-user credential is persisted yet. The operator holds 

4the just-authorized token; this serves it through the same v2 resolver path runtime uses for the 

5stored token, so the preview never relies on the caller-credential-override path that 

6``_create_mcp_client`` refuses for ``authorization_code``. It backs a single preview call, so it 

7returns its one token regardless of the lookup key. 

8""" 

9 

10from __future__ import annotations 

11 

12from dataclasses import dataclass 

13 

14from litellm.proxy._experimental.mcp_server.outbound_credentials.oauth_token_store import ( 

15 OAuthToken, 

16) 

17 

18 

19@dataclass(frozen=True, slots=True) 

20class PresentedOAuthTokenStore: 

21 """Serves one in-hand token for the single preview call it backs (no DB, no cache).""" 

22 

23 token: OAuthToken 

24 

25 async def fetch(self, user_id: str, server_id: str) -> OAuthToken | None: 

26 return self.token