Add title to serverInfo

Follow-up to #109.

`title` has also been added to `serverInfo` and `clientInfo` by
https://github.com/modelcontextprotocol/modelcontextprotocol/pull/663.

Since `clientInfo` is not treated as product code, support is implemented only in `serverInfo`.

See also https://modelcontextprotocol.io/specification/2025-06-18/schema#implementation.
This commit is contained in:
Koichi ITO 2025-08-29 01:36:24 +09:00
commit ef56280518

View file

@ -69,6 +69,7 @@ module MCP
@server = Server.new(
name: @server_name,
title: "Example Server Display Name",
version: "1.2.3",
instructions: "Optional instructions for the client",
tools: [@tool, @tool_that_raises],
@ -140,6 +141,7 @@ module MCP
},
serverInfo: {
name: @server_name,
title: "Example Server Display Name",
version: "1.2.3",
},
instructions: "Optional instructions for the client",
@ -769,6 +771,18 @@ module MCP
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
end
test "server uses default title when not configured" do
server = Server.new(name: "test_server")
request = {
jsonrpc: "2.0",
method: "initialize",
id: 1,
}
response = server.handle(request)
assert_nil response[:result][:serverInfo][:title]
end
test "server uses default version when not configured" do
server = Server.new(name: "test_server")
request = {