You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-1Lines changed: 82 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,7 @@ The server provides three notification methods:
113
113
-`notify_tools_list_changed` - Send a notification when the tools list changes
114
114
-`notify_prompts_list_changed` - Send a notification when the prompts list changes
115
115
-`notify_resources_list_changed` - Send a notification when the resources list changes
116
+
-`notify_log_message` - Send a structured logging notification message
116
117
117
118
#### Notification Format
118
119
@@ -121,6 +122,87 @@ Notifications follow the JSON-RPC 2.0 specification and use these method names:
121
122
-`notifications/tools/list_changed`
122
123
-`notifications/prompts/list_changed`
123
124
-`notifications/resources/list_changed`
125
+
-`notifications/message`
126
+
127
+
#### Logging
128
+
129
+
The MCP Ruby SDK supports structured logging through the `notify_log_message` method, following the [MCP Logging specification](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging).
130
+
131
+
The `notifications/message` notification is used for structured logging between client and server.
132
+
133
+
##### Log Levels
134
+
135
+
The SDK supports 8 log levels with increasing severity:
136
+
137
+
| Level | Severity | Description |
138
+
|-------|----------|-------------|
139
+
|`debug`| 0 | Detailed debugging information |
140
+
|`info`| 1 | General informational messages |
141
+
|`notice`| 2 | Normal but significant events |
142
+
|`warning`| 3 | Warning conditions |
143
+
|`error`| 4 | Error conditions |
144
+
|`critical`| 5 | Critical conditions |
145
+
|`alert`| 6 | Action must be taken immediately |
146
+
|`emergency`| 7 | System is unusable |
147
+
148
+
##### How Logging Works
149
+
150
+
1.**Client Configuration**: The client sends a `logging/setLevel` request to configure the minimum log level
151
+
2.**Server Filtering**: The server only sends log messages at the configured level or higher severity
152
+
3.**Notification Delivery**: Log messages are sent as `notifications/message` to the client
153
+
154
+
For example, if the client sets the level to `"error"` (severity 4), the server will send messages with levels: `error`, `critical`, `alert`, and `emergency`.
155
+
156
+
##### Server Capability
157
+
158
+
According to the [MCP specification](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging#capabilities), servers that support logging **MUST** declare the `logging` capability. The Ruby SDK includes `logging: {}` in the default server capabilities automatically, so logging support is enabled by default without any additional configuration.
159
+
160
+
##### Using Logging in Your Server
161
+
162
+
```ruby
163
+
server =MCP::Server.new(name:"my_server")
164
+
transport =MCP::Server::Transports::StdioTransport.new(server)
0 commit comments