da-daken commented on code in PR #1475:
URL: https://github.com/apache/flink-agents/pull/1475#discussion_r4740790755


##########
plan/src/main/java/org/apache/flink/agents/plan/AgentPlan.java:
##########
@@ -458,6 +458,28 @@ private void extractJavaMCPServer(Method method) throws 
Exception {
         addResourceProvider(new JavaResourceProvider(name, MCP_SERVER, 
descriptor));
     }
 
+    /**
+     * Names the default Java MCP server implementation for a declaration that 
carries the {@link
+     * ResourceName#MCP_SERVER} placeholder, checking the bundled server's JDK 
17+ requirement
+     * against the actual execution environment. Custom fully-qualified 
implementations pass through
+     * unchanged and own their own compatibility. This mirrors {@link 
#extractJavaMCPServer(Method)}
+     * for the {@code Agent.addResource} path used by the YAML loaders.
+     */
+    private ResourceDescriptor namedJavaMCPServerDescriptor(ResourceDescriptor 
descriptor) {
+        if (!ResourceName.MCP_SERVER.equals(descriptor.getClazz())) {
+            return descriptor;
+        }
+        int javaVersion = Runtime.version().feature();
+        if (javaVersion < 17) {
+            throw new UnsupportedOperationException(
+                    "Java version is less than 17, please use python MCP 
server.");
+        }
+        return new ResourceDescriptor(
+                descriptor.getModule(),
+                JAVA_MCP_SERVER_CLASS_NAME,
+                new HashMap<>(descriptor.getInitialArguments()));

Review Comment:
   Thanks for the detailed testing. I've already fixed it in the latest commit.



##########
python/flink_agents/plan/agent_plan.py:
##########
@@ -561,10 +563,25 @@ def _add_mcp_server(
 
     The server is not contacted here. Its tools and prompts are discovered when
     the operator starts, see ``flink_agents.runtime.mcp_resource_discovery``.
+
+    A Java declaration is carried by a ``JavaResourceProvider`` for the Java
+    runtime, which owns its discovery; the Python runtime never provides it.
+    The ``mcp`` alias resolves to a declaration placeholder, and the default
+    implementation is named here, mirroring the Java plan.
     """
-    resource_providers.append(
-        PythonResourceProvider.get(name=name, descriptor=descriptor)
-    )
+    if descriptor.language == "java":
+        if descriptor.target_clazz == ResourceName.JAVA_MCP_SERVER_PLACEHOLDER:
+            descriptor = JavaResourceDescriptor(
+                clazz=ResourceName.JAVA_MCP_SERVER,

Review Comment:
   Thanks for the review. I added a validation for JavaMCPResourceDiscovery 
during the open phase, while also keeping the validation during AgentPlan 
construction on the Java side.



-- 
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