Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

trigger_pipeline

Start a pipeline run in Azure DevOps by specifying the pipeline ID, branch, variables, and optional parameters to control execution.

Instructions

Trigger a pipeline run

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
pipelineIdYesThe numeric ID of the pipeline to trigger
branchNoThe branch to run the pipeline on (e.g., "main", "feature/my-branch"). If left empty, the default branch will be used
variablesNoVariables to pass to the pipeline run
templateParametersNoParameters for template-based pipelines
stagesToSkipNoStages to skip in the pipeline run

Implementation Reference

  • The core handler function that triggers a pipeline run using the Azure DevOps Pipelines API. It prepares run parameters including variables, template parameters, stages to skip, and branch resources, then calls pipelinesApi.runPipeline() and handles errors appropriately.
    export async function triggerPipeline(
      connection: WebApi,
      options: TriggerPipelineOptions,
    ): Promise<Run> {
      try {
        const pipelinesApi = await connection.getPipelinesApi();
        const {
          projectId = defaultProject,
          pipelineId,
          branch,
          variables,
          templateParameters,
          stagesToSkip,
        } = options;
    
        // Prepare run parameters
        const runParameters: Record<string, unknown> = {};
    
        // Add variables
        if (variables) {
          runParameters.variables = variables;
        }
    
        // Add template parameters
        if (templateParameters) {
          runParameters.templateParameters = templateParameters;
        }
    
        // Add stages to skip
        if (stagesToSkip && stagesToSkip.length > 0) {
          runParameters.stagesToSkip = stagesToSkip;
        }
    
        // Prepare resources (including branch)
        const resources: Record<string, unknown> = branch
          ? { repositories: { self: { refName: `refs/heads/${branch}` } } }
          : {};
    
        // Add resources to run parameters if not empty
        if (Object.keys(resources).length > 0) {
          runParameters.resources = resources;
        }
        // Call pipeline API to run pipeline
        const result = await pipelinesApi.runPipeline(
          runParameters,
          projectId,
          pipelineId,
        );
    
        return result;
      } catch (error) {
        // Handle specific error types
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
    
        // Check for specific error types and convert to appropriate Azure DevOps errors
        if (error instanceof Error) {
          if (
            error.message.includes('Authentication') ||
            error.message.includes('Unauthorized') ||
            error.message.includes('401')
          ) {
            throw new AzureDevOpsAuthenticationError(
              `Failed to authenticate: ${error.message}`,
            );
          }
    
          if (
            error.message.includes('not found') ||
            error.message.includes('does not exist') ||
            error.message.includes('404')
          ) {
            throw new AzureDevOpsResourceNotFoundError(
              `Pipeline or project not found: ${error.message}`,
            );
          }
        }
    
        // Otherwise, wrap it in a generic error
        throw new AzureDevOpsError(
          `Failed to trigger pipeline: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod schema defining the input parameters for the trigger_pipeline tool, including projectId, pipelineId, branch, variables, templateParameters, and stagesToSkip.
    export const TriggerPipelineSchema = z.object({
      // The project containing the pipeline
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      // The ID of the pipeline to trigger
      pipelineId: z
        .number()
        .int()
        .positive()
        .describe('The numeric ID of the pipeline to trigger'),
      // The branch to run the pipeline on
      branch: z
        .string()
        .optional()
        .describe(
          'The branch to run the pipeline on (e.g., "main", "feature/my-branch"). If left empty, the default branch will be used',
        ),
      // Variables to pass to the pipeline run
      variables: z
        .record(
          z.object({
            value: z.string(),
            isSecret: z.boolean().optional(),
          }),
        )
        .optional()
        .describe('Variables to pass to the pipeline run'),
      // Parameters for template-based pipelines
      templateParameters: z
        .record(z.string())
        .optional()
        .describe('Parameters for template-based pipelines'),
      // Stages to skip in the pipeline run
      stagesToSkip: z
        .array(z.string())
        .optional()
        .describe('Stages to skip in the pipeline run'),
    });
  • Tool registration in the pipelinesTools array, defining the name, description, input schema, and MCP enablement.
      {
        name: 'trigger_pipeline',
        description: 'Trigger a pipeline run',
        inputSchema: zodToJsonSchema(TriggerPipelineSchema),
        mcp_enabled: true,
      },
    ];
  • Dispatch handler in the pipelines request switch statement that parses arguments with TriggerPipelineSchema and calls the triggerPipeline function.
    case 'trigger_pipeline': {
      const args = TriggerPipelineSchema.parse(request.params.arguments);
      const result = await triggerPipeline(connection, {
        ...args,
        projectId: args.projectId ?? defaultProject,
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Inclusion of 'trigger_pipeline' in the isPipelinesRequest tool name check.
    'trigger_pipeline',
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Trigger a pipeline run' implies a write/mutation operation, but it doesn't specify permissions required, whether it's idempotent, rate limits, what happens on success/failure, or the expected outcome (e.g., starts execution, returns a run ID). This leaves critical behavioral traits unclear for an agent.

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 a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, earning full marks for conciseness.

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

Completeness2/5

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

Given the complexity (6 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It lacks details on behavioral traits, usage context, and expected outcomes, which are crucial for a mutation tool like this. The high schema coverage helps with parameters, but overall guidance is insufficient.

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 100%, so the schema fully documents all 6 parameters with clear descriptions (e.g., 'branch' specifies default behavior). The description adds no parameter-specific information beyond what's in the schema, meeting the baseline of 3 for high schema coverage without extra value.

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

Purpose3/5

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

The description 'Trigger a pipeline run' clearly states the action (trigger) and resource (pipeline run), but it's vague about scope and doesn't differentiate from sibling tools like 'get_pipeline', 'list_pipelines', or 'pipeline_timeline'. It lacks specificity about what 'trigger' entails beyond the basic verb.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. There's no mention of prerequisites (e.g., needing a pipeline ID), exclusions, or comparisons to sibling tools like 'get_pipeline' for inspection or 'list_pipeline_runs' for monitoring. The description offers no context for tool selection.

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

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