This is an automated email from the ASF dual-hosted git repository.

xintongsong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git


The following commit(s) were added to refs/heads/main by this push:
     new f6a3b195 [integrations][mcp] Read MCP server timeout from the 
"timeout" descriptor argument (#771)
f6a3b195 is described below

commit f6a3b195a916ee9e0254bffd3261b8cad397b572
Author: bosiew.tian <[email protected]>
AuthorDate: Sun Jun 7 00:48:36 2026 +0800

    [integrations][mcp] Read MCP server timeout from the "timeout" descriptor 
argument (#771)
---
 .../flink/agents/integrations/mcp/MCPServer.java   |  8 +++----
 .../agents/integrations/mcp/MCPServerTest.java     | 25 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git 
a/integrations/mcp/src/main/java/org/apache/flink/agents/integrations/mcp/MCPServer.java
 
b/integrations/mcp/src/main/java/org/apache/flink/agents/integrations/mcp/MCPServer.java
index 7d53cfab..5692de7a 100644
--- 
a/integrations/mcp/src/main/java/org/apache/flink/agents/integrations/mcp/MCPServer.java
+++ 
b/integrations/mcp/src/main/java/org/apache/flink/agents/integrations/mcp/MCPServer.java
@@ -81,7 +81,7 @@ public class MCPServer extends Resource {
 
     private static final String FIELD_ENDPOINT = "endpoint";
     private static final String FIELD_HEADERS = "headers";
-    private static final String FIELD_TIMEOUT_SECONDS = "timeoutSeconds";
+    private static final String FIELD_TIMEOUT = "timeout";
     private static final String FIELD_AUTH = "auth";
     private static final String FIELD_MAX_RETRIES = "maxRetries";
     private static final String FIELD_INITIAL_BACKOFF_MS = "initialBackoffMs";
@@ -95,7 +95,7 @@ public class MCPServer extends Resource {
     @JsonProperty(FIELD_HEADERS)
     private final Map<String, String> headers;
 
-    @JsonProperty(FIELD_TIMEOUT_SECONDS)
+    @JsonProperty(FIELD_TIMEOUT)
     private final long timeoutSeconds;
 
     @JsonProperty(FIELD_AUTH)
@@ -180,7 +180,7 @@ public class MCPServer extends Resource {
                         descriptor.getArgument(FIELD_ENDPOINT), "endpoint 
cannot be null");
         Map<String, String> headers = descriptor.getArgument(FIELD_HEADERS);
         this.headers = headers != null ? new HashMap<>(headers) : new 
HashMap<>();
-        Object timeoutArg = descriptor.getArgument(FIELD_TIMEOUT_SECONDS);
+        Object timeoutArg = descriptor.getArgument(FIELD_TIMEOUT);
         this.timeoutSeconds =
                 timeoutArg instanceof Number
                         ? ((Number) timeoutArg).longValue()
@@ -215,7 +215,7 @@ public class MCPServer extends Resource {
     public MCPServer(
             @JsonProperty(FIELD_ENDPOINT) String endpoint,
             @JsonProperty(FIELD_HEADERS) Map<String, String> headers,
-            @JsonProperty(FIELD_TIMEOUT_SECONDS) Long timeoutSeconds,
+            @JsonProperty(FIELD_TIMEOUT) Long timeoutSeconds,
             @JsonProperty(FIELD_AUTH) Auth auth,
             @JsonProperty(FIELD_MAX_RETRIES) Integer maxRetries,
             @JsonProperty(FIELD_INITIAL_BACKOFF_MS) Long initialBackoffMs,
diff --git 
a/integrations/mcp/src/test/java/org/apache/flink/agents/integrations/mcp/MCPServerTest.java
 
b/integrations/mcp/src/test/java/org/apache/flink/agents/integrations/mcp/MCPServerTest.java
index 6ae3a23e..c63bbd18 100644
--- 
a/integrations/mcp/src/test/java/org/apache/flink/agents/integrations/mcp/MCPServerTest.java
+++ 
b/integrations/mcp/src/test/java/org/apache/flink/agents/integrations/mcp/MCPServerTest.java
@@ -19,6 +19,9 @@
 package org.apache.flink.agents.integrations.mcp;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.flink.agents.api.resource.ResourceContext;
+import org.apache.flink.agents.api.resource.ResourceDescriptor;
+import org.apache.flink.agents.api.resource.ResourceName;
 import org.apache.flink.agents.api.resource.ResourceType;
 import org.apache.flink.agents.integrations.mcp.auth.ApiKeyAuth;
 import org.apache.flink.agents.integrations.mcp.auth.BasicAuth;
@@ -71,6 +74,28 @@ class MCPServerTest {
         assertThat(server.getAuth()).isNull();
     }
 
+    @Test
+    @DisabledOnJre(JRE.JAVA_11)
+    @DisplayName("Read timeout from ResourceDescriptor")
+    void testTimeoutFromResourceDescriptor() {
+        ResourceDescriptor descriptor =
+                ResourceDescriptor.Builder.newBuilder(ResourceName.MCP_SERVER)
+                        .addInitialArgument("endpoint", DEFAULT_ENDPOINT)
+                        .addInitialArgument("timeout", 60)
+                        .build();
+
+        MCPServer server =
+                new MCPServer(
+                        descriptor,
+                        ResourceContext.fromGetResource(
+                                (name, type) -> {
+                                    throw new UnsupportedOperationException(
+                                            "No dependencies expected");
+                                }));
+
+        assertThat(server.getTimeoutSeconds()).isEqualTo(60);
+    }
+
     @Test
     @DisabledOnJre(JRE.JAVA_11)
     @DisplayName("Builder with multiple headers")

Reply via email to