Class: BioRuby::MCP::Server::KEGGSearchTool
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- BioRuby::MCP::Server::KEGGSearchTool
- Defined in:
- lib/bioruby/mcp/server/kegg_tools.rb
Overview
KEGG compound search tool
Constant Summary collapse
- KEGG_REST_BASE =
'http://rest.kegg.jp'
Class Method Summary collapse
Class Method Details
.call(query:, database: 'compound', server_context: nil) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/bioruby/mcp/server/kegg_tools.rb', line 235 def call(query:, database: 'compound', server_context: nil) # Use KEGG REST API to search for compounds results = kegg_find_entries(database, query) if results.nil? || results.empty? return ::MCP::Tool::Response.new([{ type: 'text', text: "No compounds found for query: #{query}" }]) end # Parse and format results formatted_results = results.split("\n").first(20).map do |line| parts = line.split("\t") "#{parts[0]}: #{parts[1]}" if parts.length >= 2 end.compact ::MCP::Tool::Response.new([{ type: 'text', text: "Search results for '#{query}' (first 20):\n#{formatted_results.join("\n")}" }]) rescue => e ::MCP::Tool::Response.new([{ type: 'text', text: "Error searching compounds: #{e.message}" }]) end |