Skip to content

Commit f923e49

Browse files
committed
Add support for the optional description parameter in serverInfo
This PR adds support for the optional `description` parameter in `serverInfo`. This parameter has been supported since the 2025-11-25 MCP specification. https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
1 parent 4eab486 commit f923e49

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

lib/mcp/server.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def initialize(method_name)
3131

3232
include Instrumentation
3333

34-
attr_accessor :name, :title, :version, :instructions, :tools, :prompts, :resources, :server_context, :configuration, :capabilities, :transport
34+
attr_accessor :description, :name, :title, :version, :instructions, :tools, :prompts, :resources, :server_context, :configuration, :capabilities, :transport
3535

3636
def initialize(
37+
description: nil,
3738
name: "model_context_protocol",
3839
title: nil,
3940
version: DEFAULT_VERSION,
@@ -47,6 +48,7 @@ def initialize(
4748
capabilities: nil,
4849
transport: nil
4950
)
51+
@description = description
5052
@name = name
5153
@title = title
5254
@version = version
@@ -174,7 +176,14 @@ def prompts_get_handler(&block)
174176
private
175177

176178
def validate!
177-
# NOTE: The draft protocol version is the next version after 2025-03-26.
179+
# NOTE: The draft protocol version is the next version after 2025-11-25.
180+
if @configuration.protocol_version <= "2025-06-18"
181+
if server_info.key?(:description)
182+
message = "Error occurred in server_info. `description` is not supported in protocol version 2025-06-18 or earlier"
183+
raise ArgumentError, message
184+
end
185+
end
186+
178187
if @configuration.protocol_version <= "2025-03-26"
179188
if server_info.key?(:title)
180189
message = "Error occurred in server_info. `title` is not supported in protocol version 2025-03-26 or earlier"
@@ -255,6 +264,7 @@ def default_capabilities
255264

256265
def server_info
257266
@server_info ||= {
267+
description:,
258268
name:,
259269
title:,
260270
version:,

test/mcp/server_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class ServerTest < ActiveSupport::TestCase
6868
configuration.instrumentation_callback = instrumentation_helper.callback
6969

7070
@server = Server.new(
71+
description: "Test server",
7172
name: @server_name,
7273
title: "Example Server Display Name",
7374
version: "1.2.3",
@@ -140,6 +141,7 @@ class ServerTest < ActiveSupport::TestCase
140141
tools: { listChanged: true },
141142
},
142143
serverInfo: {
144+
description: "Test server",
143145
name: @server_name,
144146
title: "Example Server Display Name",
145147
version: "1.2.3",
@@ -815,6 +817,21 @@ def call(message:, server_context: nil)
815817
refute response[:result].key?(:instructions)
816818
end
817819

820+
test "server uses description when configured with protocol version 2025-11-25" do
821+
configuration = Configuration.new(protocol_version: "2025-11-25")
822+
server = Server.new(description: "Test server", name: "test_server", configuration: configuration)
823+
assert_equal("test server.", server.instructions)
824+
end
825+
826+
test "raises error if description is used with protocol version 2025-06-18" do
827+
configuration = Configuration.new(protocol_version: "2025-06-18")
828+
829+
exception = assert_raises(ArgumentError) do
830+
Server.new(description: "Test server", name: "test_server", configuration: configuration)
831+
end
832+
assert_equal("Error occurred in server_info. `description` is not supported in protocol version 2025-06-18 or earlier", exception.message)
833+
end
834+
818835
test "server uses instructions when configured with protocol version 2025-03-26" do
819836
configuration = Configuration.new(protocol_version: "2025-03-26")
820837
server = Server.new(name: "test_server", instructions: "The server instructions.", configuration: configuration)

0 commit comments

Comments
 (0)