list_month_events
Retrieve a complete list of all events for a specified year and month from Google Calendar using natural language commands with OAuth2 authentication.
Instructions
지정한 연/월의 모든 일정 목록 조회
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| month | Yes | ||
| year | Yes |
Implementation Reference
- google_calendar_mcp/server.py:8-27 (handler)Handler function for 'list_month_events' tool. Queries Google Calendar API for all events in the specified year and month, returns count and list of events.@mcp.tool() def list_month_events(year: int, month: int) -> dict[str, Any]: """지정한 연/월의 모든 일정 목록 조회""" service = get_calendar_service() start_date = datetime(year, month, 1) if month == 12: end_date = datetime(year + 1, 1, 1) else: end_date = datetime(year, month + 1, 1) time_min = start_date.isoformat() + 'Z' time_max = end_date.isoformat() + 'Z' events_result = service.events().list( calendarId='primary', timeMin=time_min, timeMax=time_max, singleEvents=True, orderBy='startTime' ).execute() events = events_result.get('items', []) return {"count": len(events), "events": events}
- google_calendar_mcp/server.py:8-8 (registration)The @mcp.tool() decorator registers the list_month_events function as an MCP tool.@mcp.tool()
- Helper utility to obtain an authenticated Google Calendar service instance, used by the tool handler.def get_calendar_service(): creds = None if os.path.exists(TOKEN_FILE): with open(TOKEN_FILE, "rb") as token: creds = pickle.load(token) if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES) creds = flow.run_local_server(port=0) with open(TOKEN_FILE, "wb") as token: pickle.dump(creds, token) service = build("calendar", "v3", credentials=creds) return service