spring-projects/spring-ai · info

No prompt methods found in the provided prompt objects: <pro

Error message

No prompt methods found in the provided prompt objects: <promptObjects>

What it means

AsyncMcpPromptProvider scans the supplied promptObjects for @McpPrompt-annotated methods with async signatures and converts them into prompt specifications. When none qualify it logs this warning naming the objects scanned. No exception is raised; the server just exposes no prompts. The warning is the library's way of signaling a probable misconfiguration (objects registered but no prompt methods found).

Source

Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/prompt/AsyncMcpPromptProvider.java:93

					var promptAnnotation = mcpPromptMethod.getAnnotation(McpPrompt.class);
					var mcpPrompt = PromptAdapter.asPrompt(promptAnnotation, mcpPromptMethod);

					BiFunction<McpAsyncServerExchange, GetPromptRequest, Mono<GetPromptResult>> methodCallback = AsyncMcpPromptMethodCallback
						.builder()
						.method(mcpPromptMethod)
						.bean(promptObject)
						.prompt(mcpPrompt)
						.build();

					return new AsyncPromptSpecification(mcpPrompt, methodCallback);
				})
				.toList())
			.flatMap(List::stream)
			.toList();

		if (promptSpecs.isEmpty()) {
			if (logger.isWarnEnabled()) {
				logger.warn("No prompt methods found in the provided prompt objects: " + this.promptObjects);
			}
		}

		return promptSpecs;
	}

	/**
	 * Returns the methods of the given bean class.
	 * @param bean the bean instance
	 * @return the methods of the bean class
	 */
	protected Method[] doGetClassMethods(Object bean) {
		return bean.getClass().getDeclaredMethods();
	}

}

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Ensure at least one method in each prompt object is annotated @McpPrompt with a signature matching the async provider's predicates
  2. Move annotated methods into the concrete class (only getDeclaredMethods is scanned)
  3. Use the sync prompt provider variants for synchronous prompt methods
  4. Remove the promptObjects registration if prompts are not used

Example fix

// before
new AsyncMcpPromptProvider(List.of(new Prompts())); // no @McpPrompt methods

// after
class Prompts {
    @McpPrompt(name = "greeting", description = "Greeting prompt")
    public PromptSpec greet(String name) { ... }
}
new AsyncMcpPromptProvider(List.of(new Prompts()));
Defensive patterns

Strategy: validation

Validate before calling

if (Arrays.stream(bean.getClass().getDeclaredMethods())
        .noneMatch(m -> m.isAnnotationPresent(McpPrompt.class))) {
    throw new IllegalStateException("No @McpPrompt methods in " + bean.getClass());
}

Type guard

static boolean hasPromptMethods(Object bean) {
    return Arrays.stream(bean.getClass().getDeclaredMethods())
        .anyMatch(m -> m.isAnnotationPresent(McpPrompt.class));
}

Prevention

When it happens

Trigger: getPromptSpecifications() produces an empty list because no method in promptObjects is annotated @McpPrompt or none passes the provider's filters (e.g. reactive-return-type filtering mismatched with the provider type, methods in superclasses, or an empty object list).

Common situations: Forgetting @McpPrompt on prompt methods; passing prompt beans to the wrong sync/async provider variant; prompt methods declared in a base class; auto-configuration registering prompt objects that were never implemented.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/16657e9038366537. Report an issue: GitHub.