Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(api): read the MCP provider updated_at as UTC in the console response (#45465)
Eapp1e741699a03deb
diff --git a/api/core/entities/mcp_provider.py b/api/core/entities/mcp_provider.pyindex d28f93816cc..b7a9533cc4e 100644--- a/api/core/entities/mcp_provider.py+++ b/api/core/entities/mcp_provider.py@@ -16,6 +16,7 @@ from core.mcp.types import OAuthClientInformation, OAuthClientMetadata, OAuthTokfrom core.tools.entities.common_entities import I18nObjectfrom core.tools.entities.tool_entities import ToolProviderTypefrom graphon.file import helpers as file_helpers+from libs.datetime_utils import to_utc_timestampif TYPE_CHECKING:from models.tools import MCPToolProvider@@ -177,7 +178,7 @@ class MCPProviderEntity(BaseModel):"is_team_authorization": self.authed,"server_url": self.masked_server_url(),"server_identifier": self.server_identifier,- "updated_at": int(self.updated_at.timestamp()),+ "updated_at": to_utc_timestamp(self.updated_at),"label": I18nObject(en_US=self.name, zh_Hans=self.name).to_dict(),"description": I18nObject(en_US="", zh_Hans="").to_dict(),"identity_mode": self.identity_mode,diff --git a/api/tests/unit_tests/core/entities/test_mcp_provider.py b/api/tests/unit_tests/core/entities/test_mcp_provider.pyindex 16db07c2f7f..5125dd68cfd 100644--- a/api/tests/unit_tests/core/entities/test_mcp_provider.py+++ b/api/tests/unit_tests/core/entities/test_mcp_provider.py@@ -1,3 +1,5 @@+import time+from collections.abc import Iteratorfrom datetime import UTC, datetimefrom unittest.mock import patch@@ -12,6 +14,20 @@ from core.mcp.types import OAuthTokensfrom models.tools import MCPToolProvider+def non_utc_host_timezone(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:+ """Run the test with a host timezone that is not UTC, where the platform supports it."""+ if not hasattr(time, "tzset"):+ pytest.skip("tzset is only available on POSIX platforms")+ monkeypatch.setenv("TZ", "Asia/Shanghai")+ time.tzset()+ try:+ yield+ finally:+ monkeypatch.undo()+ time.tzset()++def _build_mcp_provider_entity() -> MCPProviderEntity:now = datetime(2025, 1, 1, tzinfo=UTC)return MCPProviderEntity(@@ -447,3 +463,18 @@ def test_decrypt_headers_and_credentials_delegate_to_decrypt_dict() -> None:assert mock.call_count == 2assert headers == {"h": "v"}assert credentials == {"c": "v"}++[email protected]("non_utc_host_timezone")+def test_to_api_response_reads_the_updated_at_as_utc() -> None:+ """Persisted datetimes are naive UTC, so the host timezone must not shift them."""+ # Arrange+ recorded_at = datetime(2024, 5, 1)+ entity = _build_mcp_provider_entity().model_copy(update={"updated_at": recorded_at, "icon": {"en_US": "icon.png"}})++ with patch.object(MCPProviderEntity, "masked_server_url", return_value="https://api.example.com/******"):+ # Act+ response = entity.to_api_response(include_sensitive=False)++ # Assert+ assert response["updated_at"] == int(recorded_at.replace(tzinfo=UTC).timestamp())