da-daken opened a new pull request, #1475: URL: https://github.com/apache/flink-agents/pull/1475
Linked issue: #1452 ### Purpose of change YAML agent declarations could not declare a Java MCP server: the Python loader rejected `type: java` for `mcp_servers`, and the Java loader had no `mcp` alias for the Java bucket, so `AgentPlan.addResource` failed with "Adding a Java MCP server via Agent.addResource is not supported". This PR lets both YAML loaders declare a Java MCP server with `clazz: mcp, type: java` (or a custom FQN), and makes both plan builders carry it via a `JavaResourceProvider` so the existing runtime discovery (`JavaMCPResourceDiscovery`) picks it up unchanged. The default `mcp` alias resolves to a `MCP_SERVER_PLACEHOLDER` because the final implementation class is only known when the plan builds resource providers. Both plans (Java `AgentPlan.namedJavaMCPServerDescriptor`, Python `_add_mcp_server`) name the placeholder to `ResourceName.JAVA_MCP_SERVER` at plan build time and enforce the JDK 17+ requirement there (the bundled Java MCP implementation needs the JDK 17+ MCP SDK). Custom FQNs pass through untouched, so users can still plug their own Java MCP server on JDK 11. ### Behavioral Semantics - `clazz: mcp` + `type: java` resolves to the placeholder in both alias tables; a dotted unknown `clazz` is treated as a custom FQN; a non-dotted unknown alias raises `Unknown Java alias '<x>' for mcp_server` in both loaders. - Plan build: placeholder + JDK 17+ -> named to the bundled `MCPServer` implementation and registered as a `JavaResourceProvider`; placeholder + JDK < 17 -> `UnsupportedOperationException` with a hint to use the Python MCP server; custom FQN -> registered as-is regardless of JDK. - Runtime discovery is unchanged: Java discovery reflects over the `JavaResourceProvider`, Python discovery skips Java-owned providers, so no cross-language leakage. - `ResourceDescriptor.arguments` for MCP servers only carries scalars/string lists (endpoint etc.), which survive the plan JSON round trip. ### Tests Java (JDK 21 local; plan tests are guarded by `assumeTrue` so the JDK 11 shard skips): - `mvn -o -B --no-transfer-progress -pl api,plan,runtime -am test` — all pass. Python: - `python -m pytest flink_agents/api/yaml flink_agents/plan -q` — all pass. Cross-language / e2e (all run locally and pass): - Near-e2e: `YamlJavaMCPServerDiscoveryTest` (YAML -> plan -> `JavaMCPResourceDiscovery` -> `ResourceCache`). - Java-entry e2e: `YamlJavaMCPCrossLanguageTest` against a real MCP server (1/1 passed). - Python-entry e2e: `python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/yaml_java_mcp_cross_language_test.py` (1 passed) — a Python entry job consumes the Java MCP server's tool and prompt via a `type: java` YAML action. - Consistency guard: `e2e-test/test-scripts/check_resource_consistency.py` now also compares the MCP constants across languages (exit 0). A per-test-case list with test names is provided in a comment below. ### API - Adds `ResourceName.JAVA_MCP_SERVER` (Java) and `ResourceName.JAVA_MCP_SERVER` / `JAVA_MCP_SERVER_PLACEHOLDER` (Python); `MCP_SERVER` keeps its placeholder meaning. Additive only; no existing public API changes. ### Documentation - [x] `doc-included` <!-- Your PR already contains the necessary documentation updates --> ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes Generated-by: WorkBuddy (GLM-5.3-Flash) -- 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]
