Module: ClaudeMemory::MCP::Handlers::ContextHandlers

Included in:
Tools
Defined in:
lib/claude_memory/mcp/handlers/context_handlers.rb

Overview

Context-aware query handlers (facts by tool, branch, directory)

Instance Method Summary collapse

Instance Method Details

#facts_by_context(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/claude_memory/mcp/handlers/context_handlers.rb', line 17

def facts_by_context(args)
  scope = extract_scope(args)
  limit = extract_limit(args, default: 20)

  if args["git_branch"]
    results = @recall.facts_by_branch(args["git_branch"], limit: limit, scope: scope)
    context_type = "git_branch"
    context_value = args["git_branch"]
  elsif args["cwd"]
    results = @recall.facts_by_directory(args["cwd"], limit: limit, scope: scope)
    context_type = "cwd"
    context_value = args["cwd"]
  else
    return {error: "Must provide either git_branch or cwd parameter"}
  end

  ResponseFormatter.format_context_facts(context_type, context_value, scope, results)
end

#facts_by_tool(args) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/claude_memory/mcp/handlers/context_handlers.rb', line 8

def facts_by_tool(args)
  tool_name = args["tool_name"]
  scope = extract_scope(args)
  limit = extract_limit(args, default: 20)

  results = @recall.facts_by_tool(tool_name, limit: limit, scope: scope)
  ResponseFormatter.format_tool_facts(tool_name, scope, results)
end