Skip to main content
Glama

timeline_add_track

Create a new track to organize timeline events for social media campaigns. Use this tool to structure content across platforms like X/Twitter, LinkedIn, and Instagram by grouping related posts together.

Instructions

Create a new track for organizing timeline events. Check existing tracks with timeline_list_tracks first to avoid duplicates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
typeNoplanned
orderNoOptional order position. If not provided, will be added at the end.

Implementation Reference

  • The complete handler implementation and registration for the 'timeline_add_track' MCP tool. Includes input validation schema, logic to check for duplicates, create DB record using Drizzle ORM, generate UUID, create disk folder structure with metadata JSON, and return validated response using trackResponseSchema.
    mcp.addTool({
      name: 'timeline_add_track',
      description: 'Create a new track for organizing timeline events. Check existing tracks with timeline_list_tracks first to avoid duplicates.',
      parameters: z.object({
        name: z.string().min(1, 'Track name cannot be empty').max(100, 'Track name too long'),
        type: z.enum(['planned', 'automation']).optional().default('planned'),
        order: z.number().int().optional().describe('Optional order position. If not provided, will be added at the end.')
      }),
      execute: async (params) => {
        console.error('[Timeline MCP] Add track called with params:', params);
        
        try {
          const db = await getDb();
          
          // Check if track with same name already exists
          const existingTrack = await db.select().from(tracks)
            .where(and(
              eq(tracks.name, params.name),
              eq(tracks.type, params.type)
            ))
            .limit(1);
          
          if (existingTrack.length > 0) {
            return JSON.stringify({
              success: false,
              error: `Track "${params.name}" with type "${params.type}" already exists`,
              existingTrack: trackResponseSchema.parse({
                id: existingTrack[0].id,
                name: existingTrack[0].name,
                type: params.type === 'automation' ? 'automation' : 'schedule',
                order: existingTrack[0].order,
                createdAt: existingTrack[0].createdAt
              })
            }, null, 2);
          }
          
          // Determine order
          let order = params.order;
          if (order === undefined) {
            // Get the maximum order and add 1
            const maxOrder = await db.select({ maxOrder: tracks.order })
              .from(tracks)
              .orderBy(desc(tracks.order))
              .limit(1);
            
            order = (maxOrder[0]?.maxOrder || 0) + 1;
          }
          
          // Create new track
          const trackId = uuidv4();
          const now = new Date().toISOString();
          const postyAccountId = await getDefaultPostyAccountId();
    
          await db.insert(tracks).values({
            id: trackId,
            postyAccountId,
            name: params.name,
            type: params.type,
            order: order,
            createdAt: now,
            updatedAt: now
          });
          
          // Fetch the created track
          const [newTrack] = await db.select().from(tracks).where(eq(tracks.id, trackId));
          
          if (!newTrack) {
            throw new Error('Failed to create track');
          }
          
          // Create track folder on disk
          const workspacePath = getWorkspacePath();
          const trackFolderName = sanitizeFileName(params.name);
          const trackFolderPath = path.join(workspacePath, 'tracks', trackFolderName);
          
          try {
            await fs.mkdir(trackFolderPath, { recursive: true });
            console.error('[Timeline MCP] Created track folder:', trackFolderPath);
            
            // Create a track info file
            const trackInfoFile = path.join(trackFolderPath, '.track-info.json');
            const trackInfo = {
              id: trackId,
              name: params.name,
              type: params.type,
              order: order,
              createdAt: now,
              folderName: trackFolderName
            };
            await fs.writeFile(trackInfoFile, JSON.stringify(trackInfo, null, 2));
          } catch (folderError) {
            console.error('[Timeline MCP] Warning: Could not create track folder:', folderError);
            // Continue anyway - folder creation is not critical
          }
          
          const response = {
            success: true,
            track: trackResponseSchema.parse({
              id: newTrack.id,
              name: newTrack.name,
              type: params.type === 'automation' ? 'automation' : 'schedule',
              order: newTrack.order,
              createdAt: newTrack.createdAt
            }),
            message: `Track "${params.name}" created successfully`
          };
          
          console.error('[Timeline MCP] Track created successfully:', response);
          return JSON.stringify(response, null, 2);
          
        } catch (error) {
          console.error('[Timeline MCP] Error in add_track:', error);
          
          return JSON.stringify({
            success: false,
            error: error instanceof Error ? error.message : 'Unknown error occurred',
            stack: error instanceof Error ? error.stack : undefined
          }, null, 2);
        }
      }
    });
  • Zod schema defining the input parameters for the timeline_add_track tool: track name, type, and optional order.
    parameters: z.object({
      name: z.string().min(1, 'Track name cannot be empty').max(100, 'Track name too long'),
      type: z.enum(['planned', 'automation']).optional().default('planned'),
      order: z.number().int().optional().describe('Optional order position. If not provided, will be added at the end.')
    }),
  • trackResponseSchema used to parse and validate the track object in the tool's response.
    export const trackResponseSchema = z.object({
      id: z.string(),
      name: z.string(),
      type: z.enum(['schedule']),
      order: z.number(),
      createdAt: z.string().optional()
  • SQLite database schema definition for the 'timeline_tracks' table, directly used by the handler for inserting new tracks.
    export const tracks = sqliteTable('timeline_tracks', {
      id: text('id').primaryKey().$defaultFn(uuid.defaultFn),
      postyAccountId: text('posty_account_id').references(() => postyAccounts.id, { onDelete: 'cascade' }),
      name: text('name').notNull(),
      type: text('type', { enum: ['planned', 'automation'] }).notNull(),
      order: integer('order').notNull().default(0),
      createdAt: text('created_at').notNull().$defaultFn(timestamp.defaultNow),
      updatedAt: text('updated_at').notNull().$defaultFn(timestamp.defaultNow),
    }, (table) => ({
      accountIdx: index('timeline_tracks_account_idx').on(table.postyAccountId),
      orderIdx: index('timeline_tracks_order_idx').on(table.order),
    }));
  • sanitizeFileName helper function used to create safe folder names for the new track directory on disk.
    function sanitizeFileName(name: string): string {
      return name
        .replace(/[<>:"/\\|?*]/g, '-')
        .replace(/\s+/g, '_')
        .replace(/^\.+/, '')
        .slice(0, 100);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions checking for duplicates, it doesn't disclose other important behavioral aspects like what happens on duplicate creation (error? override?), authentication requirements, rate limits, or what the tool returns. For a creation tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that each earn their place. The first sentence states the purpose, and the second provides essential usage guidance. No wasted words, well-structured, and front-loaded with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a creation tool with no annotations and no output schema, the description provides good purpose and usage guidance but lacks behavioral context about what happens on success/failure, return values, or error conditions. It's adequate as a minimum viable description but has clear gaps given the tool's complexity and lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 33% (only the 'order' parameter has a description), so the description needs to compensate but doesn't mention any parameters. The description adds no parameter semantics beyond what the schema provides, but the schema itself has reasonable coverage through enum values and constraints. Baseline 3 is appropriate given the schema does most of the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Create a new track') and resource ('for organizing timeline events'), distinguishing it from sibling tools like timeline_list_tracks (which lists tracks) and timeline_remove_track (which removes tracks). It provides a complete purpose statement with both verb and target.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides usage guidance by stating 'Check existing tracks with timeline_list_tracks first to avoid duplicates.' This names a specific alternative tool (timeline_list_tracks) and gives a clear when-to-use recommendation (check first to avoid duplicates), which is excellent guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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