Skip to main content
Glama

timeline_update_scheduled_event

Modify scheduled social media posts by updating content, timing, approval status, or platform settings for events across multiple networks.

Instructions

Update an existing scheduled event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventIdYes
updatesYes

Implementation Reference

  • The handler function executes the tool logic: fetches DB, applies updates to the event (name, prompt, time, etc.), validates scheduled time is future, prepares for SQLite, updates and selects the event, returns JSON success with event details or error.
    execute: async (params) => { const db = await getDb(); try { const updates: any = { updatedAt: new Date() }; if (params.updates.name) updates.name = params.updates.name; if (params.updates.prompt) { updates.prompt = params.updates.prompt; // Store prompt string directly updates.contentGenerated = false; // Reset generation status if prompt changes } if (params.updates.scheduledTime) { const newScheduledTime = new Date(params.updates.scheduledTime); if (newScheduledTime <= new Date()) { throw new Error('Scheduled time must be in the future'); } updates.scheduledTime = newScheduledTime; updates.generationTime = calculateGenerationTime(newScheduledTime); } if (params.updates.approved !== undefined) updates.approved = params.updates.approved; if (params.updates.platform) updates.platform = params.updates.platform; if (params.updates.metadata) updates.metadata = JSON.stringify(params.updates.metadata); // Convert dates and booleans for SQLite const dbUpdates = prepareEventForDb(updates); await db.update(events) .set(dbUpdates) .where(eq(events.id, params.eventId)); const [updated] = await db.select().from(events).where(eq(events.id, params.eventId)); if (!updated) { return JSON.stringify({ success: false, error: 'Event not found' }, null, 2); } return JSON.stringify({ success: true, event: { id: updated.id, name: updated.name, scheduledTime: updated.scheduledTime, approved: updated.approved, platform: updated.platform } }, null, 2); } catch (error) { if (error instanceof z.ZodError) { return JSON.stringify({ success: false, error: 'Validation error', details: error.errors }, null, 2); } throw error; } }
  • Zod schema defining required eventId (UUID) and updates object with optional fields for name, prompt, scheduledTime, approved, platform, metadata; ensures at least one update field.
    parameters: z.object({ eventId: z.string().uuid(), updates: z.object({ name: z.string().min(1).max(200).optional(), prompt: z.string().min(1).max(5000).optional(), scheduledTime: isoDateTimeSchema.optional(), approved: z.boolean().optional(), platform: platformSchema.optional(), metadata: z.record(z.any()).optional().describe('Platform-specific metadata') }).refine(data => Object.keys(data).length > 0, { message: 'At least one update field must be provided' }) }),
  • Registers the tool with MCP using addTool, specifying name, description, input schema, and handler function.
    mcp.addTool({ name: 'timeline_update_scheduled_event', description: 'Update an existing scheduled event', parameters: z.object({ eventId: z.string().uuid(), updates: z.object({ name: z.string().min(1).max(200).optional(), prompt: z.string().min(1).max(5000).optional(), scheduledTime: isoDateTimeSchema.optional(), approved: z.boolean().optional(), platform: platformSchema.optional(), metadata: z.record(z.any()).optional().describe('Platform-specific metadata') }).refine(data => Object.keys(data).length > 0, { message: 'At least one update field must be provided' }) }), execute: async (params) => { const db = await getDb(); try { const updates: any = { updatedAt: new Date() }; if (params.updates.name) updates.name = params.updates.name; if (params.updates.prompt) { updates.prompt = params.updates.prompt; // Store prompt string directly updates.contentGenerated = false; // Reset generation status if prompt changes } if (params.updates.scheduledTime) { const newScheduledTime = new Date(params.updates.scheduledTime); if (newScheduledTime <= new Date()) { throw new Error('Scheduled time must be in the future'); } updates.scheduledTime = newScheduledTime; updates.generationTime = calculateGenerationTime(newScheduledTime); } if (params.updates.approved !== undefined) updates.approved = params.updates.approved; if (params.updates.platform) updates.platform = params.updates.platform; if (params.updates.metadata) updates.metadata = JSON.stringify(params.updates.metadata); // Convert dates and booleans for SQLite const dbUpdates = prepareEventForDb(updates); await db.update(events) .set(dbUpdates) .where(eq(events.id, params.eventId)); const [updated] = await db.select().from(events).where(eq(events.id, params.eventId)); if (!updated) { return JSON.stringify({ success: false, error: 'Event not found' }, null, 2); } return JSON.stringify({ success: true, event: { id: updated.id, name: updated.name, scheduledTime: updated.scheduledTime, approved: updated.approved, platform: updated.platform } }, null, 2); } catch (error) { if (error instanceof z.ZodError) { return JSON.stringify({ success: false, error: 'Validation error', details: error.errors }, null, 2); } throw error; } } });

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/derekalia/timeline-mcp'

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