avichaym commented on code in PR #539:
URL: https://github.com/apache/flink-agents/pull/539#discussion_r2872486063


##########
plan/src/main/java/org/apache/flink/agents/plan/AgentPlan.java:
##########
@@ -432,18 +432,22 @@ private void extractJavaMCPServer(Method method) throws 
Exception {
                     
JavaSerializableResourceProvider.createResourceProvider(toolName, TOOL, tool));
         }
 
-        // Call listPrompts() via reflection
-        Method listPromptsMethod = 
mcpServer.getClass().getMethod("listPrompts");
-        @SuppressWarnings("unchecked")
-        Iterable<? extends SerializableResource> prompts =
-                (Iterable<? extends SerializableResource>) 
listPromptsMethod.invoke(mcpServer);
-
-        for (SerializableResource prompt : prompts) {
-            Method getNameMethod = prompt.getClass().getMethod("getName");
-            String promptName = (String) getNameMethod.invoke(prompt);
-            addResourceProvider(
-                    JavaSerializableResourceProvider.createResourceProvider(
-                            promptName, PROMPT, prompt));
+        // Call listPrompts() only if the server supports prompts (optional 
per MCP spec).
+        // MCP servers like AgentCore Gateway only support tools, not prompts.
+        Method supportsPromptsMethod = 
mcpServer.getClass().getMethod("supportsPrompts");
+        if ((boolean) supportsPromptsMethod.invoke(mcpServer)) {

Review Comment:
    Done. Moved the supportsPrompts check inside MCPServer.listPrompts() — it 
returns an empty list when the server has no prompt capability. AgentPlan calls 
listPrompts() unconditionally and doesn't need 
   to be aware of prompt support.
   



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