Class: RubyLLM::MCP::Roots
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Roots
- Defined in:
- lib/ruby_llm/mcp/roots.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #add(path) ⇒ Object
-
#initialize(paths: [], adapter: nil) ⇒ Roots
constructor
A new instance of Roots.
- #remove(path) ⇒ Object
- #to_h ⇒ Object
- #to_request ⇒ Object
Constructor Details
#initialize(paths: [], adapter: nil) ⇒ Roots
Returns a new instance of Roots.
8 9 10 11 |
# File 'lib/ruby_llm/mcp/roots.rb', line 8 def initialize(paths: [], adapter: nil) @paths = paths @adapter = adapter end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
6 7 8 |
# File 'lib/ruby_llm/mcp/roots.rb', line 6 def paths @paths end |
Instance Method Details
#active? ⇒ Boolean
13 14 15 |
# File 'lib/ruby_llm/mcp/roots.rb', line 13 def active? @paths.any? end |
#add(path) ⇒ Object
17 18 19 20 |
# File 'lib/ruby_llm/mcp/roots.rb', line 17 def add(path) @paths << path @adapter.roots_list_change_notification end |
#remove(path) ⇒ Object
22 23 24 25 |
# File 'lib/ruby_llm/mcp/roots.rb', line 22 def remove(path) @paths.delete(path) @adapter.roots_list_change_notification end |
#to_h ⇒ Object
38 39 40 41 42 |
# File 'lib/ruby_llm/mcp/roots.rb', line 38 def to_h { paths: to_request } end |
#to_request ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_llm/mcp/roots.rb', line 27 def to_request @paths.map do |path| name = File.basename(path, ".*") { uri: "file://#{path}", name: name } end end |