Class: MCPServer::Tools::GetProducts
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- MCPServer::Tools::GetProducts
- Defined in:
- lib/mcp_server/tools/get_products.rb
Overview
Tool to retrieve all products from the inventory.
Class Method Summary collapse
Class Method Details
.call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mcp_server/tools/get_products.rb', line 15 def self.call(*) unless MCPServer::Config.db_running? return MCP::Tool::Response.new([{ type: 'text', text: 'Inventory database is not running.' }], is_error: true) end firestore = MCPServer::Config.firestore products = firestore.col('inventory').get.map { |doc| MCPServer::DatabaseHelper.doc_to_product(doc) } MCP::Tool::Response.new( [{ type: 'text', text: JSON.pretty_generate(products) }] ) end |