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


##########
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:
   > I think it might be better to check `supportsPrompts` inside 
`listPrompts`, so that `listPrompts` returns an empty list rather than fail 
when the server doesn't support prompts. `AgentPlan` doesn't need to be aware 
of this complexity.
   > 
   > WDYT?
   
   +1



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