Class: Foobara::McpConnector::Commands::Initialize
- Inherits:
-
Command
- Object
- Command
- Foobara::McpConnector::Commands::Initialize
show all
- Defined in:
- foobara-mcp-connector-1.0.1/src/commands/initialize.rb
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Command
install!
#inspect, truncating
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
58
59
60
|
# File 'src/commands/initialize.rb', line 58
def session
@session
end
|
#version ⇒ Object
Returns the value of attribute version.
58
59
60
|
# File 'src/commands/initialize.rb', line 58
def version
@version
end
|
Instance Method Details
#build_result ⇒ Object
Just hard-coding a bunch of these values to a limited set of abilities for now
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'src/commands/initialize.rb', line 85
def build_result
{
protocolVersion: version,
capabilities: {
tools: { listChanged: false }
},
serverInfo: {
name: command_connector.server_name,
version: command_connector.server_version
},
instructions: command_connector.instructions
}
end
|
#command_connector ⇒ Object
68
69
70
|
# File 'src/commands/initialize.rb', line 68
def command_connector
request.command_connector
end
|
#create_session ⇒ Object
60
61
62
|
# File 'src/commands/initialize.rb', line 60
def create_session
self.session = Session.new(inputs.except(:request))
end
|
#determine_version ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'src/commands/initialize.rb', line 72
def determine_version
versions_to_choose_from = SUPPORTED_VERSIONS.select do |supported_version|
supported_version <= protocolVersion
end
if versions_to_choose_from.empty?
versions_to_choose_from = SUPPORTED_VERSIONS
end
self.version = versions_to_choose_from.max
end
|
#execute ⇒ Object
50
51
52
53
54
55
56
|
# File 'src/commands/initialize.rb', line 50
def execute
create_session
notify_connector_of_session
determine_version
build_result
end
|
#notify_connector_of_session ⇒ Object
64
65
66
|
# File 'src/commands/initialize.rb', line 64
def notify_connector_of_session
command_connector.session_created(session)
end
|