Class: RubyEventStore::MCP::Server
- Inherits:
-
Object
- Object
- RubyEventStore::MCP::Server
- Defined in:
- lib/ruby_event_store/mcp/server.rb
Constant Summary collapse
- PROTOCOL_VERSION =
"2024-11-05"
Instance Attribute Summary collapse
-
#event_store ⇒ Object
readonly
Returns the value of attribute event_store.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(event_store:, name: "ruby-event-store", version: VERSION) ⇒ Server
constructor
A new instance of Server.
- #register(tool) ⇒ Object
- #start(input: $stdin, output: $stdout) ⇒ Object
Constructor Details
#initialize(event_store:, name: "ruby-event-store", version: VERSION) ⇒ Server
Returns a new instance of Server.
12 13 14 15 16 17 |
# File 'lib/ruby_event_store/mcp/server.rb', line 12 def initialize(event_store:, name: "ruby-event-store", version: VERSION) @event_store = event_store @name = name @version = version @tools = [] end |
Instance Attribute Details
#event_store ⇒ Object (readonly)
Returns the value of attribute event_store.
10 11 12 |
# File 'lib/ruby_event_store/mcp/server.rb', line 10 def event_store @event_store end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/ruby_event_store/mcp/server.rb', line 10 def name @name end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
10 11 12 |
# File 'lib/ruby_event_store/mcp/server.rb', line 10 def tools @tools end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/ruby_event_store/mcp/server.rb', line 10 def version @version end |
Instance Method Details
#register(tool) ⇒ Object
19 20 21 22 |
# File 'lib/ruby_event_store/mcp/server.rb', line 19 def register(tool) tools << tool self end |
#start(input: $stdin, output: $stdout) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ruby_event_store/mcp/server.rb', line 24 def start(input: $stdin, output: $stdout) output.sync = true input.each_line do |line| request = JSON.parse(line.strip) response = handle(request) output.puts(JSON.generate(response)) if response end end |