create_event_with_show_as
Schedule calendar events in Outlook with specific availability status like OutOfOffice for vacation or WorkingElsewhere to indicate your presence.
Instructions
Create a calendar event with specific Show As status (e.g., OutOfOffice for vacation)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subject | Yes | Event subject/title | |
| start | Yes | Start date and time (ISO 8601 format) | |
| end | Yes | End date and time (ISO 8601 format) | |
| location | No | Event location | |
| body | No | Event description/body | |
| showAs | No | Show As status (default: Busy) | |
| reminderMinutes | No | Reminder time in minutes before the event |
Implementation Reference
- src/outlook-manager.ts:573-650 (handler)The core handler function that implements the tool logic by generating and executing PowerShell script to create Outlook calendar appointment with BusyStatus (Show As) using COM interop.async createEventWithShowAs(options: { subject: string; start: Date; end: Date; location?: string; body?: string; showAs?: 'Free' | 'Tentative' | 'Busy' | 'OutOfOffice' | 'WorkingElsewhere'; reminderMinutes?: number; }): Promise<{ success: boolean; eventId: string; message: string }> { try { // Map ShowAs values to Outlook constants const showAsMap: Record<string, number> = { 'Free': 0, 'Tentative': 1, 'Busy': 2, 'OutOfOffice': 3, 'WorkingElsewhere': 4 }; const busyStatus = showAsMap[options.showAs || 'Busy']; const cleanSubject = this.cleanText(options.subject); const cleanLocation = options.location ? this.cleanText(options.location) : ''; const cleanBody = options.body ? this.cleanText(options.body) : ''; const script = ` try { Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook" -ErrorAction Stop $outlook = New-Object -ComObject Outlook.Application -ErrorAction Stop $appointmentItem = $outlook.CreateItem(1) $appointmentItem.Subject = "${cleanSubject.replace(/"/g, '""')}" $appointmentItem.Start = [DateTime]"${options.start.toISOString()}" $appointmentItem.End = [DateTime]"${options.end.toISOString()}" ${options.location ? `$appointmentItem.Location = "${cleanLocation.replace(/"/g, '""')}"` : ''} ${options.body ? `$appointmentItem.Body = "${cleanBody.replace(/"/g, '""')}"` : ''} $appointmentItem.BusyStatus = ${busyStatus} ${options.reminderMinutes !== undefined ? ` $appointmentItem.ReminderSet = $true $appointmentItem.ReminderMinutesBeforeStart = ${options.reminderMinutes} ` : ''} $appointmentItem.Save() Write-Output ([PSCustomObject]@{ Success = $true EventId = $appointmentItem.EntryID Subject = $appointmentItem.Subject ShowAs = "${options.showAs || 'Busy'}" } | ConvertTo-Json -Compress) } catch { Write-Output ([PSCustomObject]@{ Success = $false Error = $_.Exception.Message } | ConvertTo-Json -Compress) } `; const result = await this.executePowerShell(script); const cleanResult = result.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, '').trim(); const data = JSON.parse(cleanResult); if (!data.Success) { throw new Error(data.Error || 'Failed to create event'); } return { success: true, eventId: data.EventId, message: `Event created: ${data.Subject} with Show As: ${data.ShowAs}` }; } catch (error) { throw new Error(`Failed to create event with Show As: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:272-308 (schema)The input schema definition for the MCP tool, specifying parameters like subject, start/end dates, showAs enum, etc.name: "create_event_with_show_as", description: "Create a calendar event with specific Show As status (e.g., OutOfOffice for vacation)", inputSchema: { type: "object", properties: { subject: { type: "string", description: "Event subject/title" }, start: { type: "string", description: "Start date and time (ISO 8601 format)" }, end: { type: "string", description: "End date and time (ISO 8601 format)" }, location: { type: "string", description: "Event location" }, body: { type: "string", description: "Event description/body" }, showAs: { type: "string", enum: ["Free", "Tentative", "Busy", "OutOfOffice", "WorkingElsewhere"], description: "Show As status (default: Busy)" }, reminderMinutes: { type: "number", description: "Reminder time in minutes before the event" } }, required: ["subject", "start", "end"] }
- src/index.ts:703-721 (registration)The registration in the MCP request handler switch statement that parses arguments, calls the handler, and formats the response.case 'create_event_with_show_as': { const result = await outlookManager.createEventWithShowAs({ subject: (args as any)?.subject, start: new Date((args as any)?.start), end: new Date((args as any)?.end), location: (args as any)?.location, body: (args as any)?.body, showAs: (args as any)?.showAs, reminderMinutes: (args as any)?.reminderMinutes }); return { content: [ { type: 'text', text: `${result.success ? '✅' : '❌'} **Calendar Event Created**\n\n${result.message}\n\n**Event ID:** ${result.eventId}`, }, ], }; }