{"record":{"id":"260b896cc1f37140","repo":"spring-projects/spring-ai","slug":"void-warn-string-message-260b89","errorCode":null,"errorMessage":"void warn(String message)","messagePattern":"void warn\\(String message\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/context/McpSyncRequestContext.java","lineNumber":93,"sourceCode":"\tvoid progress(Consumer<ProgressSpec> progressSpec);\n\n\tvoid progress(ProgressNotification progressNotification);\n\n\t// --------------------------------------\n\t// Ping\n\t// --------------------------------------\n\tvoid ping();\n\n\t// --------------------------------------\n\t// Logging\n\t// --------------------------------------\n\tvoid log(Consumer<LoggingSpec> logSpec);\n\n\tvoid debug(String message);\n\n\tvoid info(String message);\n\n\tvoid warn(String message);\n\n\tvoid error(String message);\n\n}\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/context/McpSyncRequestContext.java#L75-L98","documentation":"This is not an error but the interface method declaration warn(String) on McpSyncRequestContext: the imperative context API's method to send a WARN-level logging notification to the connected MCP client, returning void. It surfaces in listings as an API surface member, not as a thrown error.","triggerScenarios":"Invoked when a sync @McpTool method calls ctx.warn(\"message\") to forward a warning log to the MCP client via notifications/message.","commonSituations":"Sync tool implementations reporting warnings (e.g. degraded inputs, fallback behavior) so the LLM host can surface them in its log stream.","solutions":["Call ctx.warn(\"...\") directly in sync tool code — no subscription needed","In reactive tool code use the async context variant which returns Mono<Void>"],"exampleFix":"// before\nlogger.warn(\"disk nearly full\"); // only server-side logs\n// after\nctx.warn(\"disk nearly full\"); // notifies the MCP client too","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  ctx.warn(\"disk nearly full\");\n} catch (RuntimeException e) {\n  logger.warn(\"Failed to send warn log notification\", e);\n}","preventionTips":["Call sync context log methods directly — no subscription required","Verify the MCP client handles notifications/message for on-screen logs","Match context type (sync/async) to the server kind"],"tags":["spring-ai","mcp","api-surface","logging","sync-context"],"backgroundTag":null,"analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}