spring-projects/spring-ai · info
void warn(String message)
Error message
void warn(String message)
What it means
This is not an error but the interface method declaration warn(String) on McpAsyncRequestContext: the reactive context API's method to send a WARN-level logging notification to the connected MCP client, returning Mono<Void>. It appears in error listings only because it is an API surface member.
Solutions
- Use ctx.warn("...") within an async tool and subscribe to (or chain) the returned Mono<Void>
- For imperative code, use the sync context's warn(String) instead
Example fix
// before (async context, imperative style)
ctx.warn("disk nearly full"); // does nothing alone
// after
return ctx.warn("disk nearly full").then(Mono.just(result)); Defensive patterns
Strategy: try-catch
Try / catch
try {
ctx.warn("disk nearly full").block();
} catch (Exception e) {
logger.warn("Failed to deliver warn log notification to MCP client", e);
} Prevention
- Remember async context logging methods return Mono<Void> and must be subscribed
- Chain logging Monos into the tool's reactive pipeline
- Use the sync context for imperative logging
When it happens
Trigger: Invoked when a tool implementation calls ctx.warn("message") on an async (reactive) MCP request context to emit a client-side warning log notification.
Common situations: Tool code that wants the MCP client (e.g. an LLM host) to display warning logs during tool execution uses this method as part of the logging family log/debug/info/warn/error.
Related errors
- void warn(String message)
- Progress notification not supported by the client!
- Async complete methods should use McpAsyncRequestContext…
- ASYNC Providers don't support imperative (non-reactive)…
- Bean must not be null
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/94db03ae11e56ae4.
Report an issue: GitHub.
Appendix: source
Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/context/McpAsyncRequestContext.java:97
Mono<Void> progress(Consumer<ProgressSpec> progressSpec); Mono<Void> progress(ProgressNotification progressNotification); // -------------------------------------- // Ping // -------------------------------------- Mono<Object> ping(); // -------------------------------------- // Logging // -------------------------------------- Mono<Void> log(Consumer<LoggingSpec> logSpec); Mono<Void> debug(String message); Mono<Void> info(String message); Mono<Void> warn(String message); Mono<Void> error(String message); }
View on GitHub (pinned to 98a7beda4f)