get_events_by_date
Retrieve events for a specific date using the MCP Calendar Server. Input the date in YYYY-MM-DD format to fetch and manage calendar events efficiently.
Instructions
특정 날짜의 이벤트를 조회합니다.
Args:
date: 날짜 (YYYY-MM-DD 형식)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes |
Implementation Reference
- src/main.py:250-277 (handler)The MCP tool handler for 'get_events_by_date'. Decorated with @mcp.tool(), it validates the date input, fetches events using calendar_service, filters by the target date, converts to response models, and handles errors.@mcp.tool() def get_events_by_date(date: str) -> List[CalendarEventResponse]: """ 특정 날짜의 이벤트를 조회합니다. Args: date: 날짜 (YYYY-MM-DD 형식) """ try: try: target_date = datetime.fromisoformat(date).date() except ValueError: raise InvalidEventData("date", date) result = calendar_service.fetch_events(DEFAULT_USER_ID) if result.success and result.data: filtered_events = [ event for event in result.data if event.start_time.date() == target_date ] return [calendar_service.to_response(event) for event in filtered_events] return [] except CalendarException: raise except Exception as e: raise Exception(f"날짜별 이벤트 조회 중 오류가 발생했습니다: {str(e)}")
- src/models/__init__.py:79-96 (schema)Pydantic schema/model for the CalendarEventResponse, which is the return type of the get_events_by_date tool (as List[CalendarEventResponse]). Includes field definitions and datetime serialization.class CalendarEventResponse(BaseModel): """캘린더 이벤트 응답""" id: int title: str description: Optional[str] = None location: Optional[str] = None start_time: datetime duration: int category: EventCategory stamina_cost: int status: EventStatus stamina_after_completion: Optional[int] = None created_at: datetime @field_serializer('start_time', 'created_at') def serialize_datetime(self, value: datetime) -> str: return value.isoformat() class ApiResponse(BaseModel):
- src/main.py:250-250 (registration)The @mcp.tool() decorator registers the get_events_by_date function as an MCP tool.@mcp.tool()
- http_server.py:203-221 (handler)Duplicate handler logic for 'get_events_by_date' in the HTTP server dispatch function, handling function calls by name.elif function_name == "get_events_by_date": date_str = args.get("date") if not date_str: raise ValueError("date is required") try: target_date = datetime.fromisoformat(date_str).date() except ValueError: raise ValueError(f"Invalid date format: {date_str}") result = calendar_service.fetch_events(DEFAULT_USER_ID) if result.success and result.data: filtered_events = [ event for event in result.data if event.start_time.date() == target_date ] return [calendar_service.to_response(event).dict() for event in filtered_events] return []