Skip to main content
Glama

create-event

Add new events to macOS Calendar with title, dates, and optional details like location and description.

Instructions

在macOS日历中创建新事件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarNo日历名称个人
titleYes事件标题
startDateYes开始时间,格式:YYYY-MM-DD HH:MM
endDateYes结束时间,格式:YYYY-MM-DD HH:MM
descriptionNo事件描述
locationNo事件地点

Implementation Reference

  • Handler for 'create-event' tool using MCP SDK. Formats dates, generates AppleScript to create event in specified calendar, executes via osascript.
    async createEvent(args) { const { calendar = '个人', title, startDate, endDate, description = '', location = '' } = args; const startInfo = this.formatDateForAppleScript(startDate); const endInfo = this.formatDateForAppleScript(endDate); const startTimeScript = this.generateTimeScript(startInfo, 'startTime'); const endTimeScript = this.generateTimeScript(endInfo, 'endTime'); const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" ${startTimeScript} ${endTimeScript} make new event at end of events of theCalendar with properties {summary:"${title}", start date:startTime, end date:endTime, description:"${description}", location:"${location}"} end tell `; try { const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); return { content: [ { type: 'text', text: `✅ 事件创建成功!\n📅 日历: ${calendar}\n📝 标题: ${title}\n🕒 时间: ${startDate} - ${endDate}\n📍 地点: ${location || '无'}\n📄 描述: ${description || '无'}`, }, ], }; } catch (error) { throw new Error(`创建事件失败: ${error.message}`); } }
  • Handler for 'create-event' tool. Formats dates for AppleScript, creates event in macOS Calendar.
    createEvent(args) { const { calendar = "个人", title, startDate, endDate, description = "", location = "" } = args; const formattedStart = this.formatDateForAppleScript(startDate); const formattedEnd = this.formatDateForAppleScript(endDate); const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set startDate to date "${formattedStart}" set endDate to date "${formattedEnd}" make new event at end of events of theCalendar with properties {summary:"${title}", start date:startDate, end date:endDate, description:"${description}", location:"${location}"} end tell `; try { const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); return { content: [{ type: "text", text: `✅ 事件创建成功!\n📅 日历: ${calendar}\n📝 标题: ${title}\n🕒 时间: ${startDate} - ${endDate}\n📍 地点: ${location || '无'}\n📄 描述: ${description || '无'}` }] }; } catch (error) { throw new Error(`创建事件失败: ${error.message}`); } }
  • Handler for 'create-event' tool in v1. Uses toLocaleString for date formatting to AppleScript format, executes osascript to create calendar event.
    createEvent(args) { const { calendar = "个人", title, startDate, endDate, description = "", location = "" } = args; // 转换时间格式 const formatDate = (dateStr) => { const date = new Date(dateStr); return date.toLocaleString('en-US', { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true }); }; const formattedStart = formatDate(startDate); const formattedEnd = formatDate(endDate); const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set startDate to date "${formattedStart}" set endDate to date "${formattedEnd}" make new event at end of events of theCalendar with properties {summary:"${title}", start date:startDate, end date:endDate, description:"${description}", location:"${location}"} end tell `; try { const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); return { content: [{ type: "text", text: `✅ 事件创建成功!\n📅 日历: ${calendar}\n📝 标题: ${title}\n🕒 时间: ${startDate} - ${endDate}\n📍 地点: ${location || '无'}\n📄 描述: ${description || '无'}` }] }; } catch (error) { throw new Error(`创建事件失败: ${error.message}`); } }
  • Input schema definition for the 'create-event' tool, defining parameters like calendar, title, dates, etc.
    name: 'create-event', description: '在macOS日历中创建新事件', inputSchema: { type: 'object', properties: { calendar: { type: 'string', description: '日历名称', default: '个人', }, title: { type: 'string', description: '事件标题', }, startDate: { type: 'string', description: '开始时间,格式:YYYY-MM-DD HH:MM', }, endDate: { type: 'string', description: '结束时间,格式:YYYY-MM-DD HH:MM', }, description: { type: 'string', description: '事件描述', default: '', }, location: { type: 'string', description: '事件地点', default: '', }, }, required: ['title', 'startDate', 'endDate'], additionalProperties: false, }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xybstone/macos-calendar-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server