Class: ClaudeMemory::MCP::Tools

Inherits:
Object
  • Object
show all
Includes:
Handlers::ContextHandlers, Handlers::ManagementHandlers, Handlers::QueryHandlers, Handlers::SetupHandlers, Handlers::ShortcutHandlers, Handlers::StatsHandlers, ToolHelpers
Defined in:
lib/claude_memory/mcp/tools.rb

Overview

Dispatcher that routes MCP tool calls to handler modules. Each handler module (QueryHandlers, ShortcutHandlers, etc.) provides the implementation for a group of related tools.

Constant Summary collapse

RECALL_TOOLS =

Tools that represent recall/query usage - tracked for efficacy

%w[
  memory.recall memory.recall_index memory.recall_semantic
  memory.search_concepts memory.decisions memory.conventions memory.architecture
].freeze
WRITE_TOOLS =

Write tools worth tracking

%w[memory.store_extraction].freeze
TRACKED_TOOLS =
(RECALL_TOOLS + WRITE_TOOLS).freeze

Instance Method Summary collapse

Methods included from Handlers::SetupHandlers

#check_setup, #list_projects

Methods included from Handlers::StatsHandlers

#stats, #status

Methods included from Handlers::ManagementHandlers

#changes, #conflicts, #mark_distilled, #promote, #reject_fact, #store_extraction, #sweep_now

Methods included from Handlers::ContextHandlers

#facts_by_context, #facts_by_tool

Methods included from Handlers::ShortcutHandlers

#architecture, #conventions, #decisions

Methods included from Handlers::QueryHandlers

#explain, #fact_graph, #recall, #recall_details, #recall_index, #recall_semantic, #search_concepts, #undistilled

Methods included from ToolHelpers

#collect_undistilled_items, #extract_intent, #extract_limit, #extract_scope, #find_store_for_content_item, #format_fact, #format_receipt, #format_result

Constructor Details

#initialize(store_or_manager) ⇒ Tools

Returns a new instance of Tools.

Parameters:



32
33
34
35
36
37
38
39
40
# File 'lib/claude_memory/mcp/tools.rb', line 32

def initialize(store_or_manager)
  @recall = Recall.new(store_or_manager)

  if store_or_manager.is_a?(Store::StoreManager)
    @manager = store_or_manager
  else
    @legacy_store = store_or_manager
  end
end

Instance Method Details

#call(name, arguments) ⇒ Hash

Dispatch a tool call to the appropriate handler method.

Parameters:

  • name (String)

    fully-qualified tool name (e.g. “memory.recall”)

  • arguments (Hash)

    tool arguments from the MCP request

Returns:

  • (Hash)

    structured result hash for the tool response



62
63
64
65
66
67
68
69
70
# File 'lib/claude_memory/mcp/tools.rb', line 62

def call(name, arguments)
  t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  result = dispatch(name, arguments)

  log_tool_activity(name, arguments, result, t0) if TRACKED_TOOLS.include?(name)

  result
end

#definitionsArray<Hash>

Returns MCP tool definition hashes for tools/list.

Returns:

  • (Array<Hash>)

    MCP tool definition hashes for tools/list



43
44
45
# File 'lib/claude_memory/mcp/tools.rb', line 43

def definitions
  ToolDefinitions.all
end