Skip to main content
Glama
stefanskiasan

Azure DevOps MCP Server for Cline

trigger_pipeline

Start a pipeline run in Azure DevOps by specifying the pipeline ID, branch, and optional variables to automate build and deployment processes.

Instructions

Trigger a pipeline run

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pipelineIdYesPipeline ID to trigger
branchNoBranch to run the pipeline on (optional, defaults to default branch)
variablesNoPipeline variables to override (optional)

Implementation Reference

  • The core handler function that triggers the Azure DevOps pipeline using the Build API, handling arguments validation, pipeline definition retrieval, build queuing, and error handling.
    export async function triggerPipeline(args: TriggerPipelineArgs, config: AzureDevOpsConfig) {
      if (!args.pipelineId) {
        throw new McpError(ErrorCode.InvalidParams, 'Pipeline ID is required');
      }
    
      AzureDevOpsConnection.initialize(config);
      const connection = AzureDevOpsConnection.getInstance();
      const pipelineApi = await connection.getBuildApi();
    
      try {
        // Get pipeline definition first
        const definition = await pipelineApi.getDefinition(
          config.project,
          args.pipelineId
        );
    
        if (!definition) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Pipeline with ID ${args.pipelineId} not found`
          );
        }
    
        // Create build parameters
        const build = {
          definition: {
            id: args.pipelineId,
          },
          project: definition.project,
          sourceBranch: args.branch || definition.repository?.defaultBranch || 'main',
          parameters: args.variables ? JSON.stringify(args.variables) : undefined,
        };
    
        // Queue new build
        const queuedBuild = await pipelineApi.queueBuild(build, config.project);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(queuedBuild, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        if (error instanceof McpError) throw error;
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to trigger pipeline: ${errorMessage}`
        );
      }
    }
  • The MCP tool definition including name, description, and inputSchema for validating trigger_pipeline arguments.
    {
      name: 'trigger_pipeline',
      description: 'Trigger a pipeline run',
      inputSchema: {
        type: 'object',
        properties: {
          pipelineId: {
            type: 'number',
            description: 'Pipeline ID to trigger',
          },
          branch: {
            type: 'string',
            description: 'Branch to run the pipeline on (optional, defaults to default branch)',
          },
          variables: {
            type: 'object',
            description: 'Pipeline variables to override (optional)',
            additionalProperties: {
              type: 'string',
            },
          },
        },
        required: ['pipelineId'],
      },
    },
  • Exports the pipeline tools module with initialize function that provides the triggerPipeline handler wrapper and tool definitions.
    export const pipelineTools = {
      initialize: (config: AzureDevOpsConfig) => ({
        getPipelines: (args: any) => getPipelines(args, config),
        triggerPipeline: (args: any) => triggerPipeline(args, config),
        definitions,
      }),
      definitions,
    };
  • src/index.ts:163-167 (registration)
    Registers the tool handler in the main MCP server switch statement, routing 'trigger_pipeline' calls to the pipeline tools instance.
    case 'trigger_pipeline':
      result = await tools.pipeline.triggerPipeline(
        validateArgs(request.params.arguments, 'Pipeline trigger arguments required')
      );
      break;

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/stefanskiasan/azure-devops-mcp-server'

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