Class: Tools::WebGet
- Inherits:
-
Base
- Object
- Base
- Tools::WebGet
show all
- Defined in:
- lib/tools/web_get.rb
Overview
Fetches content from a URL via HTTP GET. Returns the response body as plain text, truncated to MAX_RESPONSE_BYTES to prevent memory issues.
Only http and https schemes are allowed.
Constant Summary
collapse
- MAX_RESPONSE_BYTES =
100_000
- REQUEST_TIMEOUT =
10
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, schema
Constructor Details
This class inherits a constructor from Tools::Base
Class Method Details
.description ⇒ Object
16
|
# File 'lib/tools/web_get.rb', line 16
def self.description = "Fetch content from a URL via HTTP GET and return the response body"
|
18
19
20
21
22
23
24
25
26
|
# File 'lib/tools/web_get.rb', line 18
def self.input_schema
{
type: "object",
properties: {
url: {type: "string", description: "The URL to fetch (http or https)"}
},
required: ["url"]
}
end
|
14
|
# File 'lib/tools/web_get.rb', line 14
def self.tool_name = "web_get"
|
Instance Method Details
#execute(input) ⇒ String, Hash
31
32
33
|
# File 'lib/tools/web_get.rb', line 31
def execute(input)
validate_and_fetch(input["url"].to_s)
end
|