Class: MCPServer::Tools::GetProductById
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- MCPServer::Tools::GetProductById
- Defined in:
- lib/mcp_server/tools/get_product_by_id.rb
Overview
Tool to retrieve a specific product by its ID.
Class Method Summary collapse
Class Method Details
.call(id:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mcp_server/tools/get_product_by_id.rb', line 21 def self.call(id:) unless MCPServer::Config.db_running? return MCP::Tool::Response.new([{ type: 'text', text: 'Database not running.' }], is_error: true) end doc = MCPServer::Config.firestore.col('inventory').doc(id).get unless doc.exists? return MCP::Tool::Response.new([{ type: 'text', text: 'Product not found.' }], is_error: true) end product = MCPServer::DatabaseHelper.doc_to_product(doc) MCP::Tool::Response.new([{ type: 'text', text: JSON.pretty_generate(product) }]) end |