eemario commented on code in PR #1475:
URL: https://github.com/apache/flink-agents/pull/1475#discussion_r4734555765
##########
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:
Is there a supported way to express the Java MCP bearer-auth example in
YAML? I tried `auth: {authType: bearer, token: example}` on JDK 17. The YAML
loads and the plan builds, but creating the server fails with
`ClassCastException` because the descriptor carries a `LinkedHashMap` and the
constructor expects an `Auth` instance. If this mapping is intended to work,
could we cover it with a test that constructs the server?
##########
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:
The Python plan records the bundled Java class name here. On JDK 11, I
verified that loading the provider’s resource fails with
`ClassNotFoundException` when the MCP class is absent, or
`UnsupportedClassVersionError` when the Java 17 JAR is present. Could we check
the JDK version on the execution JVM before discovery loads the bundled class,
so users get a clear message that it requires JDK 17+?
--
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]