Class: Harbor::MCP::Server
- Inherits:
-
Object
- Object
- Harbor::MCP::Server
- Defined in:
- lib/harbor/mcp/server.rb
Constant Summary collapse
- PROTOCOL_VERSION =
"2024-11-05"
Instance Method Summary collapse
-
#initialize(config) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/harbor/mcp/server.rb', line 16 def run $stdout.sync = true log("Harbor MCP server starting...") $stdin.each_line do |line| line = line.strip next if line.empty? begin request = JSON.parse(line) rescue JSON::ParserError => e write_error(nil, -32700, "Parse error: #{e.}") next end # Notifications have no id unless request.key?("id") log("Notification: #{request['method']}") next end response = handle_request(request) write_response(response) if response end rescue Interrupt, SignalException log("Shutting down...") end |