<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t" -->

---
title: MCP Logging in Spring AI | daily.dev
description: A tutorial walks through implementing MCP logging in Spring AI, covering both server-side and client-side code. On the server, a McpSyncRequestContext...
canonical: https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: MCP Logging in Spring AI | daily.dev
og:description: A tutorial walks through implementing MCP logging in Spring AI, covering both server-side and client-side code. On the server, a McpSyncRequestContext...
og:url: https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t
og:image: https://api.daily.dev/og/posts/qBBhSrn5t.png
og:image:alt: MCP Logging in Spring AI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Logging in Spring AI

**[Baeldung](https://daily.dev/sources/baeldung)** · 9 min read · 2 upvotes · 0 comments

## Summary

A tutorial walks through implementing MCP logging in Spring AI, covering both server-side and client-side code. On the server, a McpSyncRequestContext parameter injected into an @McpTool method provides debug/info/warn/error methods that package log messages into MCP notification payloads sent over stdio or SSE transport. On the client, an @McpLogging-annotated handler method receives LoggingMessageNotification objects, and the client can call setLoggingLevel() to filter which severities the server sends. A worked example evaluates password strength and shows the resulting log notifications, plus how this fits into an LLM-orchestrated agent flow. It also notes that the July 2026 MCP spec revision (2026-07-28) formally deprecated the logging feature in favor of newer mechanisms like stderr for stdio transport and OpenTelemetry for structured observability, though existing implementations continue working for at least a year.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://feeds.feedblitz.com/~/968567129/0/baeldung~MCP-Logging-in-Spring-AI>

## Questions this post answers

### Is MCP logging deprecated, and what should I use instead?

Yes, the MCP specification revision dated 2026-07-28 formally deprecated the logging feature along with other features, in favor of newer mechanisms. Existing implementations will continue to work for at least a year, but new implementations are recommended to use stderr for the stdio transport and OpenTelemetry for structured observability instead.

_Developers planning MCP integrations can track protocol deprecations like this one on daily.dev before they migrate logging._

### How does an MCP server send log messages to a client without breaking the stdio transport?

An MCP server does not write log messages directly to stdout; instead it packages them into standard MCP protocol notification payloads sent as notifications/message JSON-RPC messages over the transport layer, such as stdio or SSE. In Spring AI, this is done via the McpSyncRequestContext interface's debug(), info(), warn(), and error() methods, while stdout is reserved for JSON-RPC messages, requiring settings like logging.pattern.console= to suppress console output.

_Teams wiring up MCP servers can compare implementation details like this on daily.dev while debugging transport issues._

### How can an MCP client control which severity of log messages it receives from a server?

An MCP client sends a logging/setLevel JSON-RPC request to the server to configure log verbosity, and the server only sends messages meeting or exceeding that severity. In Spring AI, this is done programmatically with mcpSyncClient.setLoggingLevel(McpSchema.LoggingLevel.WARNING), which instructs the server to filter out DEBUG and INFO notifications and send only WARNING or higher.

_Developers tuning MCP client behavior can find implementation patterns like this on daily.dev._

## Similar posts on daily.dev

- [Introduction to the Model Context Protocol \(MCP\) Java SDK](https://daily.dev/posts/introduction-to-the-model-context-protocol-mcp-java-sdk-nhpl9gsbn) · Baeldung · 4 upvotes · 0 comments
- [foojay – a place for friends of OpenJDK](https://daily.dev/posts/foojay-a-place-for-friends-of-openjdk-rrd5vhv3d) · Foojay.io · 0 upvotes · 0 comments
- [Build Your First MCP Server in C\# with the Official SDK](https://daily.dev/posts/build-your-first-mcp-server-in-c-with-the-official-sdk-gfvr6bvsh) · Code with Mukesh · 17 upvotes · 2 comments

---

Tags: [#java](https://daily.dev/tags/java), [#logging](https://daily.dev/tags/logging), [#mcp](https://daily.dev/tags/mcp), [#spring-boot](https://daily.dev/tags/spring-boot), [#spring-ai](https://daily.dev/tags/spring-ai)

[View this post on daily.dev](https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"MCP Logging in Spring AI","url":"https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t"},"datePublished":"2026-09-06T23:41:08.148Z","dateModified":"2026-09-14T09:00:05.908Z","description":"A tutorial walks through implementing MCP logging in Spring AI, covering both server-side and client-side code. On the server, a McpSyncRequestContext...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bdf334823bf91642cdc4171ac4262e8c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bdf334823bf91642cdc4171ac4262e8c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Baeldung","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Baeldung","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/52cccfb454d946c4b7dfa5e816f9e576","url":"https://daily.dev/sources/baeldung"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,logging,mcp,spring-boot,spring-ai","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Baeldung","item":"https://daily.dev/sources/baeldung"},{"@type":"ListItem","position":3,"name":"MCP Logging in Spring AI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/mcp-logging-in-spring-ai-qbbhsrn5t#faq","mainEntity":[{"@type":"Question","name":"Is MCP logging deprecated, and what should I use instead?","acceptedAnswer":{"@type":"Answer","text":"Yes, the MCP specification revision dated 2026-07-28 formally deprecated the logging feature along with other features, in favor of newer mechanisms. Existing implementations will continue to work for at least a year, but new implementations are recommended to use stderr for the stdio transport and OpenTelemetry for structured observability instead. Developers planning MCP integrations can track protocol deprecations like this one on daily.dev before they migrate logging."}},{"@type":"Question","name":"How does an MCP server send log messages to a client without breaking the stdio transport?","acceptedAnswer":{"@type":"Answer","text":"An MCP server does not write log messages directly to stdout; instead it packages them into standard MCP protocol notification payloads sent as notifications/message JSON-RPC messages over the transport layer, such as stdio or SSE. In Spring AI, this is done via the McpSyncRequestContext interface's debug(), info(), warn(), and error() methods, while stdout is reserved for JSON-RPC messages, requiring settings like logging.pattern.console= to suppress console output. Teams wiring up MCP servers can compare implementation details like this on daily.dev while debugging transport issues."}},{"@type":"Question","name":"How can an MCP client control which severity of log messages it receives from a server?","acceptedAnswer":{"@type":"Answer","text":"An MCP client sends a logging/setLevel JSON-RPC request to the server to configure log verbosity, and the server only sends messages meeting or exceeding that severity. In Spring AI, this is done programmatically with mcpSyncClient.setLoggingLevel(McpSchema.LoggingLevel.WARNING), which instructs the server to filter out DEBUG and INFO notifications and send only WARNING or higher. Developers tuning MCP client behavior can find implementation patterns like this on daily.dev."}}]}
```

