Class: HTM::MCP::FindByTopicTool
- Inherits:
-
FastMcp::Tool
- Object
- FastMcp::Tool
- HTM::MCP::FindByTopicTool
- Defined in:
- lib/htm/mcp/tools.rb
Overview
Tool: Find nodes by topic with fuzzy option
Instance Method Summary collapse
Instance Method Details
#call(topic:, fuzzy: false, exact: false, limit: 20, min_similarity: 0.3) ⇒ Object
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/htm/mcp/tools.rb', line 383 def call(topic:, fuzzy: false, exact: false, limit: 20, min_similarity: 0.3) Session.logger&.info "FindByTopicTool called: topic=#{topic.inspect}, fuzzy=#{fuzzy}, exact=#{exact}" htm = Session.htm_instance ltm = htm.instance_variable_get(:@long_term_memory) nodes = ltm.nodes_by_topic( topic, fuzzy: fuzzy, exact: exact, min_similarity: min_similarity, limit: limit ) # Enrich with tags results = nodes.map do |node_attrs| node = HTM::Models::Node.eager(:tags).first(id: node_attrs['id']) next unless node { id: node.id, content: node.content[0..200], tags: node..map(&:name), created_at: node.created_at.iso8601 } end.compact Session.logger&.info "FindByTopicTool complete: found #{results.length} nodes" { success: true, topic: topic, fuzzy: fuzzy, exact: exact, count: results.length, results: results }.to_json end |