Class: Foobara::McpConnector::Commands::Initialize

Inherits:
Command
  • Object
show all
Defined in:
foobara-mcp-connector-0.0.4/src/commands/initialize.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Attributes included from CommandPatternImplementation::Concerns::Subcommands

#is_subcommand

Attributes included from CommandPatternImplementation::Concerns::Runtime

#exception, #outcome

Attributes included from CommandPatternImplementation::Concerns::Errors

#error_collection

Attributes included from CommandPatternImplementation::Concerns::Inputs

#inputs, #raw_inputs

Instance Method Summary collapse

Methods inherited from Command

install!, reset_all

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Methods included from CommandPatternImplementation::Concerns::Reflection

#initialize

Methods included from CommandPatternImplementation::Concerns::DomainMappers

#domain_map, #domain_map!, #run_mapped_subcommand!

Methods included from CommandPatternImplementation::Concerns::Subcommands

#run_subcommand!, #subcommand?

Methods included from CommandPatternImplementation::Concerns::Entities

#load_entities, #load_records

Methods included from CommandPatternImplementation::Concerns::Transactions

#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions

Methods included from CommandPatternImplementation::Concerns::StateMachine

#state_machine

Methods included from CommandPatternImplementation::Concerns::Runtime

#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records

Methods included from CommandPatternImplementation::Concerns::Errors

#initialize

Methods included from CommandPatternImplementation::Concerns::Inputs

#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?

Methods included from TruncatedInspect

#inspect, truncating

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs

Instance Attribute Details

#sessionObject

Returns the value of attribute session.



57
58
59
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 57

def session
  @session
end

#versionObject

Returns the value of attribute version.



57
58
59
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 57

def version
  @version
end

Instance Method Details

#build_resultObject

Just hard-coding a bunch of these values to a limited set of abilities for now



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 84

def build_result
  {
    protocolVersion: version,
    capabilities: {
      # We only support tools for now and don't yet support updating lists of tools
      tools: { listChanged: false }
    },
    serverInfo: {
      name: command_connector.server_name,
      version: command_connector.server_version
    },
    instructions: command_connector.instructions
  }
end

#command_connectorObject



67
68
69
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 67

def command_connector
  request.command_connector
end

#create_sessionObject



59
60
61
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 59

def create_session
  self.session = Session.new(inputs.except(:request))
end

#determine_versionObject



71
72
73
74
75
76
77
78
79
80
81
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 71

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

#executeObject



49
50
51
52
53
54
55
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 49

def execute
  create_session
  notify_connector_of_session
  determine_version

  build_result
end

#notify_connector_of_sessionObject



63
64
65
# File 'foobara-mcp-connector-0.0.4/src/commands/initialize.rb', line 63

def notify_connector_of_session
  command_connector.session_created(session)
end