spring-projects/spring-ai · warning

No resource methods found in the provided resource objects:

Error message

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

What it means

SyncStatelessMcpResourceProvider.getResourceSpecifications logs this warning when annotation scanning of the supplied resource objects finds no @McpResource-annotated methods, producing an empty resource specification list. The server will advertise zero resources; the library treats a fully empty provider as a likely configuration mistake worth surfacing.

Source

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

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

					var resourceSpec = new SyncResourceSpecification(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<SyncResourceTemplateSpecification> getResourceTemplateSpecifications() {

		List<SyncResourceTemplateSpecification> resourceSpecs = this.resourceObjects.stream()
			.map(resourceObject -> Stream.of(doGetClassMethods(resourceObject))
				.filter(method -> method.isAnnotationPresent(McpResource.class))
				.filter(McpPredicates.filterReactiveReturnTypeMethod())
				.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. Add or fix @McpResource annotations on public methods inside the resource objects given to the provider.
  2. Verify the object list passed to the SyncStatelessMcpResourceProvider constructor is non-empty and contains the annotated classes.
  3. Check the annotation import resolves to org.springframework.ai.mcp annotation, not a different one.
  4. If intentional, drop the provider registration to avoid a no-op resource provider.

Example fix

// before
class DocResources { public String read(String id) { ... } } // no annotation
// after
class DocResources { @McpResource(uri = "doc://{id}") public String read(String id) { ... } }
Defensive patterns

Strategy: validation

Validate before calling

// Guard before constructing the sync provider:
List<Object> annotated = resourceObjects.stream()
    .filter(o -> Arrays.stream(o.getClass().getDeclaredMethods())
        .anyMatch(m -> m.isAnnotationPresent(McpResource.class)))
    .toList();
if (annotated.isEmpty()) throw new IllegalArgumentException("No resource objects with @McpResource methods");

Prevention

When it happens

Trigger: Passing resource objects without any public @McpResource methods to SyncStatelessMcpResourceProvider, methods annotated but not visible/signature-incompatible to the scanner, or an empty resource objects list — empty resourceSpecs triggers the warn at SyncStatelessMcpResourceProvider.java:119.

Common situations: Missing @McpResource annotation after a copy-paste; wrong bean wired into the provider; annotation on a non-public method; package rename broke the annotation import (e.g. importing a similarly named annotation from another library).

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