Class: RubyEventStore::MCP::Tools::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/mcp/tools/search.rb

Instance Method Summary collapse

Instance Method Details

#call(event_store, args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_event_store/mcp/tools/search.rb', line 30

def call(event_store, args)
  specification = args.key?("stream") ? event_store.read.stream(args.fetch("stream")) : event_store.read
  events = ReadEvents.of(
    specification,
    type: args["type"],
    after: args["after"],
    before: args["before"],
    limit: args.fetch("limit", 50)
  )
  return "(no events found)" if events.empty?
  format_events(events)
end

#nameObject



9
10
11
# File 'lib/ruby_event_store/mcp/tools/search.rb', line 9

def name
  "search"
end

#schemaObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_event_store/mcp/tools/search.rb', line 13

def schema
  {
    name: name,
    description: "Search events across all streams by type, time range, or stream name",
    inputSchema: {
      type: "object",
      properties: {
        type: { type: "string", description: "Filter by event type class name" },
        after: { type: "string", description: "Filter events newer than timestamp (ISO8601)" },
        before: { type: "string", description: "Filter events older than timestamp (ISO8601)" },
        stream: { type: "string", description: "Limit search to a specific stream" },
        limit: { type: "integer", description: "Max number of events (default: 50)" }
      }
    }
  }
end