Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

list_pipeline_runs

Retrieve recent pipeline execution records with filtering options for state, result, branch, and time range to monitor build and deployment activities.

Instructions

List recent runs for a pipeline

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
pipelineIdYesPipeline numeric ID
topNoMaximum number of runs to return (1-100)
continuationTokenNoContinuation token for pagination
branchNoBranch to filter by (e.g., "main" or "refs/heads/main")
stateNoFilter by current run state
resultNoFilter by final run result
createdFromNoFilter runs created at or after this time (ISO 8601)
createdToNoFilter runs created at or before this time (ISO 8601)
orderByNoSort order for run creation datecreatedDate desc

Implementation Reference

  • Implements the core logic for listing pipeline runs using the Azure DevOps Pipelines REST API. Constructs the API URL with filters for top count, continuation token, branch, state, result, date range, and order. Handles pagination, errors like authentication, not found, and generic failures.
    export async function listPipelineRuns(
      connection: WebApi,
      options: ListPipelineRunsOptions,
    ): Promise<ListPipelineRunsResult> {
      try {
        const pipelinesApi = await connection.getPipelinesApi();
        const projectId = options.projectId ?? defaultProject;
        const pipelineId = options.pipelineId;
    
        const baseUrl = connection.serverUrl.replace(/\/+$/, '');
        const route = `${encodeURIComponent(projectId)}/_apis/pipelines/${pipelineId}/runs`;
        const url = new URL(`${route}`, `${baseUrl}/`);
    
        url.searchParams.set('api-version', API_VERSION);
    
        const top = Math.min(Math.max(options.top ?? 50, 1), 100);
        url.searchParams.set('$top', top.toString());
    
        if (options.continuationToken) {
          url.searchParams.set('continuationToken', options.continuationToken);
        }
    
        const branch = normalizeBranch(options.branch);
        if (branch) {
          url.searchParams.set('branch', branch);
        }
    
        if (options.state) {
          url.searchParams.set('state', options.state);
        }
    
        if (options.result) {
          url.searchParams.set('result', options.result);
        }
    
        if (options.createdFrom) {
          url.searchParams.set('createdDate/min', options.createdFrom);
        }
    
        if (options.createdTo) {
          url.searchParams.set('createdDate/max', options.createdTo);
        }
    
        url.searchParams.set('orderBy', options.orderBy ?? 'createdDate desc');
    
        const requestOptions = pipelinesApi.createRequestOptions(
          'application/json',
          API_VERSION,
        );
    
        const response = await pipelinesApi.rest.get<{
          value?: Run[];
          continuationToken?: string;
        }>(url.toString(), requestOptions);
    
        if (response.statusCode === 404 || !response.result) {
          throw new AzureDevOpsResourceNotFoundError(
            `Pipeline ${pipelineId} or project ${projectId} not found`,
          );
        }
    
        const runs =
          (pipelinesApi.formatResponse(
            response.result,
            TypeInfo.Run,
            true,
          ) as Run[]) ?? [];
    
        const continuationToken = extractContinuationToken(
          response.headers as Record<string, unknown>,
          response.result,
        );
    
        return continuationToken ? { runs, continuationToken } : { runs };
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
    
        if (error instanceof Error) {
          const message = error.message.toLowerCase();
          if (
            message.includes('authentication') ||
            message.includes('unauthorized') ||
            message.includes('401')
          ) {
            throw new AzureDevOpsAuthenticationError(
              `Failed to authenticate: ${error.message}`,
            );
          }
    
          if (
            message.includes('not found') ||
            message.includes('does not exist') ||
            message.includes('404')
          ) {
            throw new AzureDevOpsResourceNotFoundError(
              `Pipeline or project not found: ${error.message}`,
            );
          }
        }
    
        throw new AzureDevOpsError(
          `Failed to list pipeline runs: ${
            error instanceof Error ? error.message : String(error)
          }`,
        );
      }
    }
  • Zod schema for validating input arguments to the list_pipeline_runs tool, including optional projectId, required pipelineId, pagination top/continuationToken, filters for branch/state/result/date, and ordering.
    export const ListPipelineRunsSchema = z.object({
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      pipelineId: z.number().int().min(1).describe('Pipeline numeric ID'),
      top: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum number of runs to return (1-100)'),
      continuationToken: z
        .string()
        .optional()
        .describe('Continuation token for pagination'),
      branch: z
        .string()
        .optional()
        .describe('Branch to filter by (e.g., "main" or "refs/heads/main")'),
      state: z
        .enum(['notStarted', 'inProgress', 'completed', 'cancelling', 'postponed'])
        .optional()
        .describe('Filter by current run state'),
      result: z
        .enum(['succeeded', 'partiallySucceeded', 'failed', 'canceled', 'none'])
        .optional()
        .describe('Filter by final run result'),
      createdFrom: z
        .string()
        .datetime()
        .optional()
        .describe('Filter runs created at or after this time (ISO 8601)'),
      createdTo: z
        .string()
        .datetime()
        .optional()
        .describe('Filter runs created at or before this time (ISO 8601)'),
      orderBy: z
        .enum(['createdDate desc', 'createdDate asc'])
        .default('createdDate desc')
        .describe('Sort order for run creation date'),
    });
  • Registers the list_pipeline_runs tool in the MCP tool definitions array, specifying name, description, input schema converted to JSON schema, and MCP enabled flag.
    {
      name: 'list_pipeline_runs',
      description: 'List recent runs for a pipeline',
      inputSchema: zodToJsonSchema(ListPipelineRunsSchema),
      mcp_enabled: true,
    },
  • Dispatch handler in pipelines/index.ts that matches on tool name 'list_pipeline_runs', parses arguments using the schema, calls the listPipelineRuns function with default project fallback, and returns JSON stringified result.
    case 'list_pipeline_runs': {
      const args = ListPipelineRunsSchema.parse(request.params.arguments);
      const result = await listPipelineRuns(connection, {
        ...args,
        projectId: args.projectId ?? defaultProject,
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose if this is a read-only operation, how pagination works (implied by 'continuationToken' but not explained), rate limits, authentication needs, or what 'recent' means (timeframe or default). The description adds minimal context beyond the basic action.

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 directly states the tool's purpose without fluff. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 (10 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain return values (e.g., format of runs list), pagination behavior, error handling, or usage context. For a tool with rich filtering options, more guidance is needed to help an agent use it effectively.

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 10 parameters. The description adds no additional parameter semantics beyond implying filtering for 'recent' runs, which is vague and not parameter-specific. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('List') and resource ('recent runs for a pipeline'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_pipeline_run' (which likely fetches a single run) or 'list_pipelines' (which lists pipelines rather than runs), missing explicit sibling distinction.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a pipeline ID), compare to similar tools like 'get_pipeline_run' for single runs, or specify scenarios (e.g., monitoring vs. detailed analysis).

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