This commit is contained in:
lda
2026-06-15 22:37:59 +07:00 Verified
parent fe0b2b4f4d
commit e8152fd4e6
32 changed files with 138 additions and 84 deletions
+9 -3
View File
@@ -186,7 +186,9 @@ class HttpxOAuthTokenRefresher:
payload = response.json()
access_token = payload.get("access_token")
if not isinstance(access_token, str) or not access_token:
raise ValueError("OAuth token refresh response did not include access_token")
raise ValueError(
"OAuth token refresh response did not include access_token"
)
expires_in = payload.get("expires_in")
return OAuthAccessToken(
access_token=access_token,
@@ -232,7 +234,9 @@ class McpAuthBinder:
if isinstance(auth, EnvAuth):
raise ValueError("env auth is not supported for MCP HTTP")
if isinstance(auth, OpaqueAuth):
raise ValueError(f"opaque auth scheme {auth.scheme!r} is not supported for MCP HTTP")
raise ValueError(
f"opaque auth scheme {auth.scheme!r} is not supported for MCP HTTP"
)
raise TypeError(f"unsupported auth variant {type(auth).__name__}")
async def bind_stdio_auth(
@@ -244,7 +248,9 @@ class McpAuthBinder:
auth = record.auth
if isinstance(auth, EnvAuth):
return BoundMcpStdioAuth(env=dict(auth.env))
if isinstance(auth, BearerAuth | HeaderAuth | OAuthRefreshTokenAuth | OpaqueAuth):
if isinstance(
auth, BearerAuth | HeaderAuth | OAuthRefreshTokenAuth | OpaqueAuth
):
raise ValueError(f"{auth.kind} auth is not supported for MCP stdio")
raise TypeError(f"unsupported auth variant {type(auth).__name__}")
+3 -1
View File
@@ -16,7 +16,9 @@ from wf_sources_mcp.connections import McpSourceConnection
from wf_sources_mcp.transports import HttpSourceTransport, StdioSourceTransport
def _as_stored_auth(auth: AuthRecord | StoredAuthRecord | None) -> StoredAuthRecord | None:
def _as_stored_auth(
auth: AuthRecord | StoredAuthRecord | None,
) -> StoredAuthRecord | None:
if auth is None or isinstance(auth, StoredAuthRecord):
return auth
return auth_record_from_compat(
+4 -4
View File
@@ -65,10 +65,10 @@ async def _list_optional_capabilities(
root = _root_exception(exc)
if isinstance(root, McpError) and root.error.code == METHOD_NOT_FOUND:
return []
if (
isinstance(root, httpx.HTTPStatusError)
and root.response.status_code in {400, 404}
):
if isinstance(root, httpx.HTTPStatusError) and root.response.status_code in {
400,
404,
}:
return []
raise
+9 -3
View File
@@ -59,7 +59,9 @@ class AuthStore:
def save_auth_record(self, record: NeutralAuthRecord | StoredAuthRecord) -> None:
raise NotImplementedError
def load_auth_record(self, auth_ref: str) -> NeutralAuthRecord | StoredAuthRecord | None:
def load_auth_record(
self, auth_ref: str
) -> NeutralAuthRecord | StoredAuthRecord | None:
raise NotImplementedError
def delete_auth(self, connection_id: str) -> bool:
@@ -139,7 +141,9 @@ class FileAuthStore(AuthStore):
else:
self.save_auth(mcp_auth_from_neutral(record))
def load_auth_record(self, auth_ref: str) -> NeutralAuthRecord | StoredAuthRecord | None:
def load_auth_record(
self, auth_ref: str
) -> NeutralAuthRecord | StoredAuthRecord | None:
path = self._auth_path(auth_ref)
if not path.exists():
return None
@@ -258,7 +262,9 @@ class FileStore(Store):
def save_auth_record(self, record: NeutralAuthRecord | StoredAuthRecord) -> None:
self._auth.save_auth_record(record)
def load_auth_record(self, auth_ref: str) -> NeutralAuthRecord | StoredAuthRecord | None:
def load_auth_record(
self, auth_ref: str
) -> NeutralAuthRecord | StoredAuthRecord | None:
return self._auth.load_auth_record(auth_ref)
def delete_auth(self, connection_id: str) -> bool: