{"record":{"id":"4bf38646f69f626f","repo":"spring-projects/spring-ai","slug":"no-prompt-methods-found-in-the-provided-prompt-obj-4bf386","errorCode":null,"errorMessage":"No prompt methods found in the provided prompt objects: <promptObjects>","messagePattern":"No prompt methods found in the provided prompt objects: <promptObjects>","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/prompt/SyncStatelessMcpPromptProvider.java","lineNumber":93,"sourceCode":"\t\t\t\t\tvar promptAnnotation = mcpPromptMethod.getAnnotation(McpPrompt.class);\n\t\t\t\t\tvar mcpPrompt = PromptAdapter.asPrompt(promptAnnotation, mcpPromptMethod);\n\n\t\t\t\t\tBiFunction<McpTransportContext, GetPromptRequest, GetPromptResult> methodCallback = SyncStatelessMcpPromptMethodCallback\n\t\t\t\t\t\t.builder()\n\t\t\t\t\t\t.method(mcpPromptMethod)\n\t\t\t\t\t\t.bean(promptObject)\n\t\t\t\t\t\t.prompt(mcpPrompt)\n\t\t\t\t\t\t.build();\n\n\t\t\t\t\treturn new SyncPromptSpecification(mcpPrompt, methodCallback);\n\t\t\t\t})\n\t\t\t\t.toList())\n\t\t\t.flatMap(List::stream)\n\t\t\t.toList();\n\n\t\tif (promptSpecs.isEmpty()) {\n\t\t\tif (logger.isWarnEnabled()) {\n\t\t\t\tlogger.warn(\"No prompt methods found in the provided prompt objects: \" + this.promptObjects);\n\t\t\t}\n\t\t}\n\n\t\treturn promptSpecs;\n\t}\n\n\t/**\n\t * Returns the methods of the given bean class.\n\t * @param bean the bean instance\n\t * @return the methods of the bean class\n\t */\n\tprotected Method[] doGetClassMethods(Object bean) {\n\t\treturn bean.getClass().getDeclaredMethods();\n\t}\n\n}\n","sourceCodeStart":75,"sourceCodeEnd":110,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/prompt/SyncStatelessMcpPromptProvider.java#L75-L110","documentation":"SyncStatelessMcpPromptProvider scans promptObjects for @McpPrompt methods with synchronous, stateless-compatible signatures and produces prompt specifications. When none are found it logs this warning listing the objects; it does not throw. The warning flags that registered prompt objects yielded zero usable prompt methods, usually a wiring or annotation mistake.","triggerScenarios":"getPromptSpecifications() yields an empty list: no @McpPrompt annotation present, predicate filters reject all methods (reactive return type, wrong parameters), methods reside in superclasses, or promptObjects is empty.","commonSituations":"Scaffolding a stateless MCP server before implementing prompts; passing beans whose prompt methods return Mono/Flux to the sync provider; annotated methods in base classes; config classes registering placeholder objects.","solutions":["Add a method annotated @McpPrompt with a sync signature to one of the supplied objects","Use the async prompt provider if methods return Mono/Flux","Move annotated methods into the concrete bean class","Remove promptObjects from the provider when prompts are not used"],"exampleFix":"// before\nclass MyPrompts { }\n\n// after\nclass MyPrompts {\n    @McpPrompt(name = \"code-review\")\n    public PromptSpec codeReview(@McpPromptParam String code) { ... }\n}\nnew SyncStatelessMcpPromptProvider(List.of(new MyPrompts()));","handlingStrategy":"validation","validationCode":"if (Arrays.stream(bean.getClass().getDeclaredMethods())\n        .noneMatch(m -> m.isAnnotationPresent(McpPrompt.class))) {\n    throw new IllegalStateException(\"No @McpPrompt methods in \" + bean.getClass());\n}","typeGuard":"static boolean hasSyncPromptMethods(Object bean) {\n    return Arrays.stream(bean.getClass().getDeclaredMethods())\n        .anyMatch(m -> m.isAnnotationPresent(McpPrompt.class));\n}","tryCatchPattern":null,"preventionTips":["Use async providers for Mono/Flux prompt methods","Keep annotated prompt methods in the registered bean class itself","Assert prompt specification counts in startup tests"],"tags":["mcp","spring-ai","annotation-scanning","prompt"],"backgroundTag":"empty-result-set","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}