Class: Ask::WebFetch::MCP::Tool
- Inherits:
-
Object
- Object
- Ask::WebFetch::MCP::Tool
- Defined in:
- lib/ask/web_fetch/mcp/tool.rb
Overview
The ask_web_fetch tool, duck-typed for Ask::MCP's ToolServer adapter (name / description / params_schema / call). The tool framing lives with its consumer — this server — not in the library: the capability is Ask::WebFetch.fetch, this is the agent-facing shell around it.
Instance Method Summary collapse
-
#call(args) ⇒ Object
Returns the fetched markdown (a String is a success for the adapter) or raises.
- #description ⇒ Object
- #name ⇒ Object
- #params_schema ⇒ Object
Instance Method Details
#call(args) ⇒ Object
Returns the fetched markdown (a String is a success for the adapter) or raises. The terminal verdicts — ParkedDomainError, EmptyContentError, FetchError — reach the client as their class, so it never retries the unretryable; transient failures raise the base Error.
39 40 41 42 43 44 45 |
# File 'lib/ask/web_fetch/mcp/tool.rb', line 39 def call(args) url = args['url'].to_s raise ArgumentError, 'missing required parameter: url' if url.empty? max_chars = args['max_chars'] Ask::WebFetch.fetch(url, max_chars: max_chars || Ask::WebFetch::DEFAULT_MAX_CHARS) end |
#description ⇒ Object
18 19 20 21 |
# File 'lib/ask/web_fetch/mcp/tool.rb', line 18 def description 'Fetch a URL and return its content as clean markdown for LLM consumption. ' \ 'Use this to read web pages, articles, and documentation.' end |
#name ⇒ Object
14 15 16 |
# File 'lib/ask/web_fetch/mcp/tool.rb', line 14 def name 'ask_web_fetch' end |
#params_schema ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ask/web_fetch/mcp/tool.rb', line 23 def params_schema { 'type' => 'object', 'properties' => { 'url' => { 'type' => 'string', 'description' => 'The URL to fetch' }, 'max_chars' => { 'type' => 'integer', 'description' => 'Maximum number of characters to return (default 20000)' } }, 'required' => ['url'] } end |