Class: GoogleCalendarMcp::Tools::GetEvent

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/google_calendar_mcp/tools/get_event.rb

Class Method Summary collapse

Class Method Details

.call(event_id:, calendar_id: "primary", server_context:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/google_calendar_mcp/tools/get_event.rb', line 27

def call(event_id:, calendar_id: "primary", server_context:)
  service = GoogleCalendarMcp::Auth.build_service
  event = service.get_event(calendar_id, event_id)

  attendees = event.attendees&.map do |a|
    { email: a.email, response_status: a.response_status, display_name: a.display_name }
  end

  result = {
    id: event.id,
    summary: event.summary,
    description: event.description,
    start: event.start&.date_time&.to_s || event.start&.date,
    end: event.end&.date_time&.to_s || event.end&.date,
    location: event.location,
    status: event.status,
    creator: event.creator&.email,
    organizer: event.organizer&.email,
    attendees: attendees,
    hangout_link: event.hangout_link,
    html_link: event.html_link,
    created: event.created&.to_s,
    updated: event.updated&.to_s
  }

  MCP::Tool::Response.new([
    { type: "text", text: JSON.pretty_generate(result) }
  ])
end