Class: Sidekiq::Mcp::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/mcp/server.rb

Constant Summary collapse

PROTOCOL_VERSION =
"2025-06-18"

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



10
11
12
# File 'lib/sidekiq/mcp/server.rb', line 10

def initialize
  @tools = ToolsRegistry.new
end

Instance Method Details

#handle_request(body) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sidekiq/mcp/server.rb', line 14

def handle_request(body)
  request = JSON.parse(body)
  
  case request["method"]
  when "initialize"
    handle_initialize(request)
  when "tools/list"
    handle_tools_list(request)
  when "tools/call"
    handle_tools_call(request)
  when "notifications/initialized"
    handle_initialized(request)
  else
    error_response(request["id"], -32601, "Method not found")
  end
rescue JSON::ParserError
  error_response(nil, -32700, "Parse error")
rescue => e
  error_response(request&.dig("id"), -32603, "Internal error: #{e.message}")
end