spring-projects/spring-ai · info

Multiple elicitation methods found: <count>

Error message

Multiple elicitation methods found: <count>

What it means

SyncMcpElicitationProvider allows a single elicitation handler; discovering more than one @McpElicitation-annotated method in the supplied objects triggers this warning with the handler count. Execution continues and all handlers are returned, but the configuration is ambiguous since MCP expects one server-level elicitation handler.

Source

Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/elicitation/SyncMcpElicitationProvider.java:117

					Function<ElicitRequest, ElicitResult> methodCallback = SyncMcpElicitationMethodCallback.builder()
						.method(mcpElicitationMethod)
						.bean(elicitationObject)
						.elicitation(elicitationAnnotation)
						.build();

					return new SyncElicitationSpecification(elicitationAnnotation.clients(), methodCallback);
				})
				.toList())
			.flatMap(List::stream)
			.toList();

		if (elicitationHandlers.isEmpty()) {
			logger.warn("No elicitation methods found");
		}
		if (elicitationHandlers.size() > 1) {
			if (logger.isWarnEnabled()) {
				logger.warn("Multiple elicitation methods found: " + elicitationHandlers.size());
			}
		}

		return elicitationHandlers;
	}

	/**
	 * 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. Un-annotate or remove all but one @McpElicitation method across the registered objects
  2. Consolidate logic into the single surviving handler
  3. Audit the bean list passed to SyncMcpElicitationProvider for duplicate elicitation services

Example fix

// before
@Service class H1 { @McpElicitation ElicitResult a(ElicitRequest r){...} }
@Service class H2 { @McpElicitation ElicitResult b(ElicitRequest r){...} }

// after
@Service class H1 { @McpElicitation ElicitResult handle(ElicitRequest r){...} }
// H2's method no longer annotated
Defensive patterns

Strategy: validation

Validate before calling

long count = beans.stream()
    .flatMap(b -> Arrays.stream(b.getClass().getDeclaredMethods()))
    .filter(m -> m.isAnnotationPresent(McpElicitation.class))
    .count();
if (count > 1) throw new IllegalStateException("Expected 1 elicitation handler, found " + count);

Type guard

static boolean singleSyncElicitationHandler(List<Object> beans) {
    return beans.stream()
        .flatMap(b -> Arrays.stream(b.getClass().getDeclaredMethods()))
        .filter(m -> m.isAnnotationPresent(McpElicitation.class))
        .count() <= 1;
}

Prevention

When it happens

Trigger: elicitationHandlers.size() > 1 in getElicitationSpecifications(): two or more methods annotated @McpElicitation across the provider's objects (multiple beans, or multiple annotated methods in one bean).

Common situations: Duplicate handler beans registered via configuration plus component scanning; leftover test/example handlers; merge conflicts that kept both handler implementations.

Related errors


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