wenjin272 commented on code in PR #1422:
URL: https://github.com/apache/flink-agents/pull/1422#discussion_r4639996433


##########
python/flink_agents/integrations/mcp/mcp.py:
##########
@@ -164,13 +166,23 @@ class MCPServer(Resource, ABC):
     # HTTP connection parameters
     endpoint: str
     headers: Dict[str, Any] | None = None
-    timeout: int = 30
-    sse_read_timeout: int = 60 * 5
+    timeout: timedelta = timedelta(seconds=30)
+    sse_read_timeout: timedelta = timedelta(minutes=5)
     auth: httpx.Auth | None = None
 
     session: ClientSession = Field(default=None, exclude=True)
     connection_context: AsyncExitStack = Field(default=None, exclude=True)
 
+    @field_validator("timeout", "sse_read_timeout", mode="before")
+    @classmethod
+    def validate_timeout(cls, value: Any) -> timedelta:
+        """Parse a positive MCP timeout."""
+        duration = parse_duration(value)

Review Comment:
   Could we also migrate `timeout=1` in 
[`test_real_startup_timeout_without_a_json_rpc_response`](https://github.com/apache/flink-agents/blob/dfa78352a3a4da8c4de148130b617d4c9ea8e824/python/flink_agents/runtime/tests/test_mcp_resource_discovery.py#L321)
 to `"1 s"` or `timedelta(seconds=1)`? With the new parser, it becomes 1 
millisecond instead of 1 second. The test can then pass before the server 
receives the initialization request, weakening its coverage of a reachable 
server that never returns the initialization JSON-RPC response. I observed this 
in a local run; keeping an explicit 1-second timeout preserves the original 
test intent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to