get_event_by_id
Retrieve a specific calendar event by its unique ID using this tool. Integrates with the MCP Calendar Server for efficient event management and tracking.
Instructions
ID로 특정 캘린더 이벤트를 조회합니다.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes |
Implementation Reference
- src/main.py:42-55 (handler)MCP tool handler for 'get_event_by_id' decorated with @mcp.tool(). Handles input validation via types, delegates to service, converts response, and manages errors.@mcp.tool() def get_event_by_id(event_id: int) -> CalendarEventResponse: """ ID로 특정 캘린더 이벤트를 조회합니다. """ try: result = calendar_service.get_event_by_id(event_id, DEFAULT_USER_ID) if result.success and result.data: return calendar_service.to_response(result.data) raise EventNotFound(event_id) except CalendarException: raise except Exception as e: raise Exception(f"이벤트 조회 중 오류가 발생했습니다: {str(e)}")
- src/models/__init__.py:79-95 (schema)Pydantic schema for the output of get_event_by_id tool (CalendarEventResponse). Defines structure and 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()
- Core business logic helper in CalendarService: retrieves event from in-memory DB, authorizes user, returns McpResult.def get_event_by_id(self, event_id: int, user_id: int) -> McpResult: """ID로 특정 이벤트 조회""" try: if event_id not in self.events_db: raise EventNotFound(event_id) event = self.events_db[event_id] if event.user_id != user_id: raise UnauthorizedAccess(user_id, event_id) return McpResult(success=True, data=event) except CalendarException: raise except Exception as e: return McpResult(success=False, error=str(e))
- Helper method to convert internal CalendarEvent entity to public CalendarEventResponse.def to_response(self, event: CalendarEvent) -> CalendarEventResponse: """Entity를 Response로 변환""" return CalendarEventResponse( id=event.id, title=event.title, description=event.description, location=event.location, start_time=event.start_time, duration=event.duration, category=event.category, stamina_cost=event.stamina_cost, status=event.status, stamina_after_completion=event.stamina_after_completion, created_at=event.created_at )