Class: Tools::UpdateFaqTool
- Inherits:
-
ApplicationTool
- Object
- MCP::Tool
- ApplicationTool
- Tools::UpdateFaqTool
- Defined in:
- app/mcp/tools/update_faq_tool.rb
Overview
MCP tool for patching existing FAQ content, associations, and landing-page
placements without replacing fields the caller omitted.
Constant Summary collapse
- UNSET =
Sentinel distinguishing omitted patch fields from explicit nil values.
Object.new.freeze
Class Method Summary collapse
-
.call(id:, question: UNSET, answer: UNSET, description: UNSET, show_on_sales_pages: UNSET, show_on_support_pages: UNSET, product_line_names: UNSET, add_tags: nil, remove_tags: nil, add_page_paths: nil, remove_page_paths: nil, _server_context: nil) ⇒ MCP::Tool::Response
MCP keyword arguments intentionally mirror the public JSON schema.
Class Method Details
.call(id:, question: UNSET, answer: UNSET, description: UNSET, show_on_sales_pages: UNSET, show_on_support_pages: UNSET, product_line_names: UNSET, add_tags: nil, remove_tags: nil, add_page_paths: nil, remove_page_paths: nil, _server_context: nil) ⇒ MCP::Tool::Response
MCP keyword arguments intentionally mirror the public JSON schema.
rubocop:disable Metrics/ParameterLists
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'app/mcp/tools/update_faq_tool.rb', line 101 def call( id:, question: UNSET, answer: UNSET, description: UNSET, show_on_sales_pages: UNSET, show_on_support_pages: UNSET, product_line_names: UNSET, add_tags: nil, remove_tags: nil, add_page_paths: nil, remove_page_paths: nil, _server_context: nil ) faq = ArticleFaq.find_by(id: id) return error_response("No FAQ found with id=#{id}") unless faq result = Faq::Update.call( faq: faq, faq_changes: build_changes( question: question, answer: answer, description: description, show_on_sales_pages: show_on_sales_pages, show_on_support_pages: show_on_support_pages ), product_line_names: product_line_names.equal?(UNSET) ? nil : product_line_names, add_tags: , remove_tags: , add_page_paths: add_page_paths, remove_page_paths: remove_page_paths ) return error_response(result.error) unless result.success? json_response( success: true, faq: format_faq(result.faq), changed_fields: result.changed_fields, added_tags: result., removed_tags: result., added_page_paths: result.added_page_paths, removed_page_paths: result.removed_page_paths, refreshed_posts: result.refreshed_posts, cache_purged: result.cache_purged, warnings: result.warnings.presence, message: result.changed_fields.any? ? 'FAQ updated successfully.' : 'FAQ already matched the requested state.' ) rescue StandardError => e ErrorReporting.error(e, tool: 'update_faq') error_response("Unexpected error updating FAQ: #{e.}") end |