Class: Riffer::Mcp::SearchTool
- Defined in:
- lib/riffer/mcp/search_tool.rb
Overview
Searches available MCP tools by name or description.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- IDENTIFIER =
"mcp_search"
Constants included from Tools::Toolable
Tools::Toolable::DEFAULT_TIMEOUT
Instance Method Summary collapse
-
#call(context:, query:) ⇒ Object
Searches progressive MCP tools and returns a
Resultwithdiscovered_tools.
Methods inherited from Tool
#call_with_validation, #error, #json, #text
Methods included from Tools::Toolable
all, #description, extended, #identifier, #kind, #name, #parameters_schema, #params, #timeout, #to_tool_schema, #validate_as_tool!
Instance Method Details
#call(context:, query:) ⇒ Object
Searches progressive MCP tools and returns a Result with discovered_tools. – : (context: Riffer::Agent::Context?, query: String) -> Riffer::Tools::Response
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/riffer/mcp/search_tool.rb', line 31 def call(context:, query:) return error("Provide a search query to find MCP tools by name or description.") if query.strip.empty? tools = context&.mcp_progressive_tools || [] matches = filter(tools, query) return text("No tools found matching '#{query}'.") if matches.empty? names = matches.map(&:name).join(", ") Result.new( "Found #{matches.length} tool(s): #{names}. They are now available — call them directly.", matches ) end |