apply_track
Create tasks from a track template by applying it to an opportunity or project. Tasks get due dates computed from the start date and template offsets.
Instructions
Apply a track definition to an opportunity or project. Creates a track instance and auto-creates tasks per the track's task definitions; tasks' dueOn is computed from startDate (defaults to today) plus each task's daysAfter offset. Use list_track_definitions to discover available templates. NOT IDEMPOTENT — applying the same trackDefinitionId twice creates two independent track instances and two sets of auto-tasks (no de-duplication). If you want to apply only once, call list_entity_tracks first and check for an existing instance with the same trackDefinition.id (but mind that list_entity_tracks can include auto-applied tracks from board stage rules, not just manual applies).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity | Yes | Which entity to apply the track to. Use 'kases' for projects. | |
| entityId | Yes | ||
| trackDefinitionId | Yes | The trackDefinition to apply (from list_track_definitions). Auto-creates task definitions on the target entity per the track's rules. | |
| startDate | No | Optional ISO-8601 date (YYYY-MM-DD) the track should start from — drives task due-date calculations (each task's `dueOn` is computed as startDate + the track-definition's `daysAfter` offset). Defaults to today if omitted. Useful for scheduling a renewal-queue track against a future contract end-date, or backfilling tracks for historical projects. |
Implementation Reference
- src/server/register-tool.ts:39-59 (helper)The registerTool helper function that wraps tool handlers into MCP's expected response shape (JSON stringified into text content).
export function registerTool<Schema extends z.ZodObject<ZodRawShape>>( server: McpServer, name: string, description: string, schema: Schema, handler: (input: z.infer<Schema>) => Promise<unknown>, ): void { // Use the SDK config-form registerTool with the full Zod schema. The // deprecated shape overload rebuilds z.object(schema.shape), which drops // object-level refinements such as superRefine. const registerWithSchema = server.registerTool.bind(server) as ( toolName: string, config: { description: string; inputSchema: Schema }, callback: (input: z.infer<Schema>) => Promise<CallToolResult>, ) => void; registerWithSchema(name, { description, inputSchema: schema }, async (input) => { const result = await handler(input); return wrapAsText(result); }); }