Merge pull request #119 from koic/add_title_to_server_info
Add `title` to `serverInfo`
This commit is contained in:
commit
b982074daa
3 changed files with 19 additions and 1 deletions
|
|
@ -158,6 +158,7 @@ class ApplicationController < ActionController::Base
|
||||||
def index
|
def index
|
||||||
server = MCP::Server.new(
|
server = MCP::Server.new(
|
||||||
name: "my_server",
|
name: "my_server",
|
||||||
|
title: "Example Server Display Name", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
instructions: "Use the tools of this server as a last resort",
|
instructions: "Use the tools of this server as a last resort",
|
||||||
tools: [SomeTool, AnotherTool],
|
tools: [SomeTool, AnotherTool],
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,11 @@ module MCP
|
||||||
|
|
||||||
include Instrumentation
|
include Instrumentation
|
||||||
|
|
||||||
attr_accessor :name, :version, :instructions, :tools, :prompts, :resources, :server_context, :configuration, :capabilities, :transport
|
attr_accessor :name, :title, :version, :instructions, :tools, :prompts, :resources, :server_context, :configuration, :capabilities, :transport
|
||||||
|
|
||||||
def initialize(
|
def initialize(
|
||||||
name: "model_context_protocol",
|
name: "model_context_protocol",
|
||||||
|
title: nil,
|
||||||
version: DEFAULT_VERSION,
|
version: DEFAULT_VERSION,
|
||||||
instructions: nil,
|
instructions: nil,
|
||||||
tools: [],
|
tools: [],
|
||||||
|
|
@ -47,6 +48,7 @@ module MCP
|
||||||
transport: nil
|
transport: nil
|
||||||
)
|
)
|
||||||
@name = name
|
@name = name
|
||||||
|
@title = title
|
||||||
@version = version
|
@version = version
|
||||||
@instructions = instructions
|
@instructions = instructions
|
||||||
@tools = tools.to_h { |t| [t.name_value, t] }
|
@tools = tools.to_h { |t| [t.name_value, t] }
|
||||||
|
|
@ -218,6 +220,7 @@ module MCP
|
||||||
def server_info
|
def server_info
|
||||||
@server_info ||= {
|
@server_info ||= {
|
||||||
name:,
|
name:,
|
||||||
|
title:,
|
||||||
version:,
|
version:,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ module MCP
|
||||||
|
|
||||||
@server = Server.new(
|
@server = Server.new(
|
||||||
name: @server_name,
|
name: @server_name,
|
||||||
|
title: "Example Server Display Name",
|
||||||
version: "1.2.3",
|
version: "1.2.3",
|
||||||
instructions: "Optional instructions for the client",
|
instructions: "Optional instructions for the client",
|
||||||
tools: [@tool, @tool_that_raises],
|
tools: [@tool, @tool_that_raises],
|
||||||
|
|
@ -140,6 +141,7 @@ module MCP
|
||||||
},
|
},
|
||||||
serverInfo: {
|
serverInfo: {
|
||||||
name: @server_name,
|
name: @server_name,
|
||||||
|
title: "Example Server Display Name",
|
||||||
version: "1.2.3",
|
version: "1.2.3",
|
||||||
},
|
},
|
||||||
instructions: "Optional instructions for the client",
|
instructions: "Optional instructions for the client",
|
||||||
|
|
@ -769,6 +771,18 @@ module MCP
|
||||||
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
|
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
|
||||||
end
|
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
|
test "server uses default version when not configured" do
|
||||||
server = Server.new(name: "test_server")
|
server = Server.new(name: "test_server")
|
||||||
request = {
|
request = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue