linear_addProjectToInitiative
Link a project to an initiative in Linear by specifying both IDs, enabling streamlined project organization and tracking within the Linear system.
Instructions
Add a project to an initiative
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| initiativeId | Yes | The ID of the initiative | |
| projectId | Yes | The ID of the project to add |
Implementation Reference
- The handler function that executes the linear_addProjectToInitiative tool. It validates input using a type guard, logs the action, calls the LinearService method to add the project to the initiative, and returns the result.export function addProjectToInitiativeHandler(linearService: LinearService) { return async (args: unknown) => { if (!isAddProjectToInitiativeInput(args)) { throw new Error('Invalid input for addProjectToInitiative'); } console.log( `[addProjectToInitiative] Adding project ${args.projectId} to initiative ${args.initiativeId}`, ); const result = await linearService.addProjectToInitiative(args.initiativeId, args.projectId); console.log(`[addProjectToInitiative] Project added successfully`); return result; }; }
- The tool schema definition specifying the name, description, input schema (initiativeId and projectId required), and output schema for the linear_addProjectToInitiative tool.{ name: 'linear_addProjectToInitiative', description: 'Add a project to an initiative', input_schema: { type: 'object', properties: { initiativeId: { type: 'string', description: 'The ID of the initiative', }, projectId: { type: 'string', description: 'The ID of the project to add', }, }, required: ['initiativeId', 'projectId'], }, output_schema: { type: 'object', properties: { success: { type: 'boolean' }, project: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, initiative: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, }, }, }, }, }, }, },
- src/tools/handlers/index.ts:64-126 (registration)The registration of the linear_addProjectToInitiative handler within the registerToolHandlers function, mapping the tool name to the curried handler function.export function registerToolHandlers(linearService: LinearService) { return { // User tools linear_getViewer: handleGetViewer(linearService), linear_getOrganization: handleGetOrganization(linearService), linear_getUsers: handleGetUsers(linearService), linear_getLabels: handleGetLabels(linearService), // Team tools linear_getTeams: handleGetTeams(linearService), linear_getWorkflowStates: handleGetWorkflowStates(linearService), // Project tools linear_getProjects: handleGetProjects(linearService), linear_createProject: handleCreateProject(linearService), // Project Management tools linear_updateProject: handleUpdateProject(linearService), linear_addIssueToProject: handleAddIssueToProject(linearService), linear_getProjectIssues: handleGetProjectIssues(linearService), // Cycle Management tools linear_getCycles: handleGetCycles(linearService), linear_getActiveCycle: handleGetActiveCycle(linearService), linear_addIssueToCycle: handleAddIssueToCycle(linearService), // Initiative Management tools linear_getInitiatives: getInitiativesHandler(linearService), linear_getInitiativeById: getInitiativeByIdHandler(linearService), linear_createInitiative: createInitiativeHandler(linearService), linear_updateInitiative: updateInitiativeHandler(linearService), linear_archiveInitiative: archiveInitiativeHandler(linearService), linear_unarchiveInitiative: unarchiveInitiativeHandler(linearService), linear_deleteInitiative: deleteInitiativeHandler(linearService), linear_getInitiativeProjects: getInitiativeProjectsHandler(linearService), linear_addProjectToInitiative: addProjectToInitiativeHandler(linearService), linear_removeProjectFromInitiative: removeProjectFromInitiativeHandler(linearService), // Issue tools linear_getIssues: handleGetIssues(linearService), linear_getIssueById: handleGetIssueById(linearService), linear_searchIssues: handleSearchIssues(linearService), linear_createIssue: handleCreateIssue(linearService), linear_updateIssue: handleUpdateIssue(linearService), linear_createComment: handleCreateComment(linearService), linear_addIssueLabel: handleAddIssueLabel(linearService), linear_removeIssueLabel: handleRemoveIssueLabel(linearService), // New Issue Management tools linear_assignIssue: handleAssignIssue(linearService), linear_subscribeToIssue: handleSubscribeToIssue(linearService), linear_convertIssueToSubtask: handleConvertIssueToSubtask(linearService), linear_createIssueRelation: handleCreateIssueRelation(linearService), linear_archiveIssue: handleArchiveIssue(linearService), linear_setIssuePriority: handleSetIssuePriority(linearService), linear_transferIssue: handleTransferIssue(linearService), linear_duplicateIssue: handleDuplicateIssue(linearService), linear_getIssueHistory: handleGetIssueHistory(linearService), // Comment Management tools linear_getComments: handleGetComments(linearService), }; }
- src/tools/type-guards.ts:858-873 (helper)Type guard function used in the handler to validate input arguments for the linear_addProjectToInitiative tool, ensuring initiativeId and projectId are strings./** * Type guard for linear_addProjectToInitiative tool arguments */ export function isAddProjectToInitiativeInput(args: unknown): args is { initiativeId: string; projectId: string; } { return ( typeof args === 'object' && args !== null && 'initiativeId' in args && typeof (args as { initiativeId: string }).initiativeId === 'string' && 'projectId' in args && typeof (args as { projectId: string }).projectId === 'string' ); }