diff --git a/tools/mcp_oauth.py b/tools/mcp_oauth.py index 7910c3cdc..a0ec9dc0e 100644 --- a/tools/mcp_oauth.py +++ b/tools/mcp_oauth.py @@ -233,7 +233,7 @@ class HermesTokenStorage: return None async def set_tokens(self, tokens: "OAuthToken") -> None: - payload = tokens.model_dump(exclude_none=True) + payload = tokens.model_dump(mode="json", exclude_none=True) # Persist an absolute ``expires_at`` so a process restart can # reconstruct the correct remaining TTL. Without this the MCP SDK's # ``_initialize`` reloads a relative ``expires_in`` which has no @@ -265,7 +265,7 @@ class HermesTokenStorage: return None async def set_client_info(self, client_info: "OAuthClientInformationFull") -> None: - _write_json(self._client_info_path(), client_info.model_dump(exclude_none=True)) + _write_json(self._client_info_path(), client_info.model_dump(mode="json", exclude_none=True)) logger.debug("OAuth client info saved for %s", self._server_name) # -- cleanup ----------------------------------------------------------- @@ -508,7 +508,7 @@ def _maybe_preregister_client( info_dict["scope"] = cfg["scope"] client_info = OAuthClientInformationFull.model_validate(info_dict) - _write_json(storage._client_info_path(), client_info.model_dump(exclude_none=True)) + _write_json(storage._client_info_path(), client_info.model_dump(mode="json", exclude_none=True)) logger.debug("Pre-registered client_id=%s for '%s'", client_id, storage._server_name)