spring-projects/spring-ai · info

No resource methods found in the provided resource objects:

Error message

No resource methods found in the provided resource objects: <resourceObjects>

What it means

AsyncMcpResourceProvider scans resourceObjects for @McpResource-annotated methods (resource reads) and converts them into resource specifications. If none are found it logs this warning naming the scanned objects; no exception is thrown and the server exposes no resources. The warning signals that registered resource objects produced zero resource methods, typically a configuration or annotation issue.

Source

Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/resource/AsyncMcpResourceProvider.java:120

					BiFunction<McpAsyncServerExchange, ReadResourceRequest, Mono<ReadResourceResult>> methodCallback = AsyncMcpResourceMethodCallback
						.builder()
						.method(mcpResourceMethod)
						.bean(resourceObject)
						.resource(mcpResource)
						.build();

					var resourceSpec = new AsyncResourceSpecification(mcpResource, methodCallback);

					return resourceSpec;
				})
				.filter(Objects::nonNull)
				.toList())
			.flatMap(List::stream)
			.toList();

		if (resourceSpecs.isEmpty()) {
			if (logger.isWarnEnabled()) {
				logger.warn("No resource methods found in the provided resource objects: " + this.resourceObjects);
			}
		}

		return resourceSpecs;
	}

	public List<AsyncResourceTemplateSpecification> getResourceTemplateSpecifications() {

		List<AsyncResourceTemplateSpecification> resourceSpecs = this.resourceObjects.stream()
			.map(resourceObject -> Stream.of(doGetClassMethods(resourceObject))
				.filter(method -> method.isAnnotationPresent(McpResource.class))
				.filter(McpPredicates.filterNonReactiveReturnTypeMethod())
				.sorted((m1, m2) -> m1.getName().compareTo(m2.getName()))
				.map(mcpResourceMethod -> {

					var resourceAnnotation = doGetMcpResourceAnnotation(mcpResourceMethod);

					var uri = resourceAnnotation.uri();

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Annotate at least one method with @McpResource in the supplied objects with a signature matching the async provider's predicates
  2. If you only have resource templates, ensure getResourceTemplateSpecifications is the intended path and register template methods with the correct annotation
  3. Move annotated methods into the bean class itself
  4. Remove resourceObjects registration when resources are intentionally absent

Example fix

// before
new AsyncMcpResourceProvider(List.of(new Resources())); // no @McpResource methods

// after
class Resources {
    @McpResource(uri = "file:///docs/{id}", name = "doc")
    public ResourceSpec doc(String id) { ... }
}
new AsyncMcpResourceProvider(List.of(new Resources()));
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: getResourceSpecifications() finds no method annotated @McpResource in the supplied objects, or all candidates are filtered out (wrong sync/async style, methods inherited from a superclass, empty objects list).

Common situations: Resource beans registered before methods were implemented; using @McpResourceTemplate-only methods while expecting resource reads; sync handlers given to the async provider; annotations on interface methods.

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/fe45944427d64c32. Report an issue: GitHub.