Class: GoogleCalendarMcp::Tools::ListCalendars

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

Class Method Summary collapse

Class Method Details

.call(server_context:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/google_calendar_mcp/tools/list_calendars.rb', line 17

def call(server_context:)
  service = GoogleCalendarMcp::Auth.build_service
  response = service.list_calendar_lists

  calendars = response.items.map do |calendar|
    {
      id: calendar.id,
      summary: calendar.summary,
      primary: calendar.primary || false,
      access_role: calendar.access_role
    }
  end

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