Module: ActionMCP::Server::Roots

Included in:
TransportHandler
Defined in:
lib/action_mcp/server/roots.rb

Instance Method Summary collapse

Instance Method Details

#refresh_roots_listObject



13
14
15
16
17
18
19
# File 'lib/action_mcp/server/roots.rb', line 13

def refresh_roots_list
  roots = session.client_capabilities&.then { |capabilities| capabilities["roots"] || capabilities[:roots] }
  return unless roots.is_a?(Hash)

  list_changed = roots["listChanged"] || roots[:listChanged]
  send_roots_list if list_changed == true
end

#send_roots_list(id = SecureRandom.uuid_v7) ⇒ Object



6
7
8
9
10
11
# File 'lib/action_mcp/server/roots.rb', line 6

def send_roots_list(id = SecureRandom.uuid_v7)
  roots = session.client_capabilities&.then { |capabilities| capabilities["roots"] || capabilities[:roots] }
  raise UnsupportedRootsError, "Client does not support roots" unless roots.is_a?(Hash)

  send_jsonrpc_request("roots/list", id: id)
end