createCalendar
Create a new calendar in Apple Calendar on macOS. Specify a title and optional color to organize events.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| color | No |
Implementation Reference
- src/index.ts:71-93 (handler)MCP handler function for the 'createCalendar' tool. It calls the helper function calendars.createCalendar(title, color) and formats the response as MCP content or error.async ({ title, color }) => { try { const result = await calendars.createCalendar(title, color); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "Calendar created", calendar: result }) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "Failed to create calendar" }) }], isError: true }; } }
- src/index.ts:67-70 (schema)Input schema using Zod validation: required 'title' string and optional 'color' string.{ title: z.string(), color: z.string().optional() },
- src/index.ts:65-94 (registration)Registration of the 'createCalendar' tool with the MCP server using server.tool(name, schema, handler).server.tool( "createCalendar", { title: z.string(), color: z.string().optional() }, async ({ title, color }) => { try { const result = await calendars.createCalendar(title, color); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "Calendar created", calendar: result }) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "Failed to create calendar" }) }], isError: true }; } } );
- src/calendars.ts:111-122 (helper)Helper function that executes the core logic: POST request to the calendar API bridge to create a new calendar.export async function createCalendar(title: string, color?: string): Promise<any> { try { const response = await axios.post(`${API_BASE_URL}/calendars`, { title, color }); return response.data; } catch (error) { console.error(`Failed to create calendar "${title}":`, error); throw new Error(`Failed to create calendar: ${error}`); } }