@@ -93,12 +93,14 @@ import {
9393 GetPipelineSchema ,
9494 ListPipelinesSchema ,
9595 ListPipelineJobsSchema ,
96+ ListPipelineTriggerJobsSchema ,
9697 CreatePipelineSchema ,
9798 RetryPipelineSchema ,
9899 CancelPipelineSchema ,
99100 // pipeline job schemas
100101 GetPipelineJobOutputSchema ,
101102 GitLabPipelineJobSchema ,
103+ GitLabPipelineTriggerJobSchema ,
102104 // Discussion Schemas
103105 GitLabDiscussionNoteSchema , // Added
104106 GitLabDiscussionSchema ,
@@ -130,10 +132,12 @@ import {
130132 type ListPipelinesOptions ,
131133 type GetPipelineOptions ,
132134 type ListPipelineJobsOptions ,
135+ type ListPipelineTriggerJobsOptions ,
133136 type CreatePipelineOptions ,
134137 type RetryPipelineOptions ,
135138 type CancelPipelineOptions ,
136139 type GitLabPipelineJob ,
140+ type GitLabPipelineTriggerJob ,
137141 type GitLabMilestones ,
138142 type ListProjectMilestonesOptions ,
139143 type GetProjectMilestoneOptions ,
@@ -643,6 +647,11 @@ const allTools = [
643647 description : "List all jobs in a specific pipeline" ,
644648 inputSchema : zodToJsonSchema ( ListPipelineJobsSchema ) ,
645649 } ,
650+ {
651+ name : "list_pipeline_trigger_jobs" ,
652+ description : "List all trigger jobs (bridges) in a specific pipeline that trigger downstream pipelines" ,
653+ inputSchema : zodToJsonSchema ( ListPipelineTriggerJobsSchema ) ,
654+ } ,
646655 {
647656 name : "get_pipeline_job" ,
648657 description : "Get details of a GitLab pipeline job number" ,
@@ -766,6 +775,7 @@ const readOnlyTools = [
766775 "get_pipeline" ,
767776 "list_pipelines" ,
768777 "list_pipeline_jobs" ,
778+ "list_pipeline_trigger_jobs" ,
769779 "get_pipeline_job" ,
770780 "get_pipeline_job_output" ,
771781 "list_projects" ,
@@ -816,6 +826,7 @@ const pipelineToolNames = [
816826 "list_pipelines" ,
817827 "get_pipeline" ,
818828 "list_pipeline_jobs" ,
829+ "list_pipeline_trigger_jobs" ,
819830 "get_pipeline_job" ,
820831 "get_pipeline_job_output" ,
821832 "create_pipeline" ,
@@ -2816,6 +2827,49 @@ async function listPipelineJobs(
28162827 const data = await response . json ( ) ;
28172828 return z . array ( GitLabPipelineJobSchema ) . parse ( data ) ;
28182829}
2830+
2831+ /**
2832+ * List all trigger jobs (bridges) in a specific pipeline
2833+ *
2834+ * @param {string } projectId - The ID or URL-encoded path of the project
2835+ * @param {number } pipelineId - The ID of the pipeline
2836+ * @param {Object } options - Options for filtering trigger jobs
2837+ * @returns {Promise<GitLabPipelineTriggerJob[]> } List of pipeline trigger jobs
2838+ */
2839+ async function listPipelineTriggerJobs (
2840+ projectId : string ,
2841+ pipelineId : number | string ,
2842+ options : Omit < ListPipelineTriggerJobsOptions , "project_id" | "pipeline_id" > = { }
2843+ ) : Promise < GitLabPipelineTriggerJob [ ] > {
2844+ projectId = decodeURIComponent ( projectId ) ; // Decode project ID
2845+ const url = new URL (
2846+ `${ GITLAB_API_URL } /projects/${ encodeURIComponent ( getEffectiveProjectId ( projectId ) ) } /pipelines/${ pipelineId } /bridges`
2847+ ) ;
2848+
2849+ // Add all query parameters
2850+ Object . entries ( options ) . forEach ( ( [ key , value ] ) => {
2851+ if ( value !== undefined ) {
2852+ if ( typeof value === "boolean" ) {
2853+ url . searchParams . append ( key , value ? "true" : "false" ) ;
2854+ } else {
2855+ url . searchParams . append ( key , value . toString ( ) ) ;
2856+ }
2857+ }
2858+ } ) ;
2859+
2860+ const response = await fetch ( url . toString ( ) , {
2861+ ...DEFAULT_FETCH_CONFIG ,
2862+ } ) ;
2863+
2864+ if ( response . status === 404 ) {
2865+ throw new Error ( `Pipeline not found` ) ;
2866+ }
2867+
2868+ await handleGitLabError ( response ) ;
2869+ const data = await response . json ( ) ;
2870+ return z . array ( GitLabPipelineTriggerJobSchema ) . parse ( data ) ;
2871+ }
2872+
28192873async function getPipelineJob ( projectId : string , jobId : number | string ) : Promise < GitLabPipelineJob > {
28202874 projectId = decodeURIComponent ( projectId ) ; // Decode project ID
28212875 const url = new URL ( `${ GITLAB_API_URL } /projects/${ encodeURIComponent ( getEffectiveProjectId ( projectId ) ) } /jobs/${ jobId } ` ) ;
@@ -4131,6 +4185,21 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
41314185 } ;
41324186 }
41334187
4188+ case "list_pipeline_trigger_jobs" : {
4189+ const { project_id, pipeline_id, ...options } = ListPipelineTriggerJobsSchema . parse (
4190+ request . params . arguments
4191+ ) ;
4192+ const triggerJobs = await listPipelineTriggerJobs ( project_id , pipeline_id , options ) ;
4193+ return {
4194+ content : [
4195+ {
4196+ type : "text" ,
4197+ text : JSON . stringify ( triggerJobs , null , 2 ) ,
4198+ } ,
4199+ ] ,
4200+ } ;
4201+ }
4202+
41344203 case "get_pipeline_job" : {
41354204 const { project_id, job_id } = GetPipelineJobOutputSchema . parse ( request . params . arguments ) ;
41364205 const jobDetails = await getPipelineJob ( project_id , job_id ) ;
0 commit comments