Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

get_pipeline_log

Retrieve specific pipeline logs from Azure DevOps using timeline identifiers to access detailed run information for debugging and analysis.

Instructions

Retrieve a specific pipeline log using the timeline log identifier

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
runIdYesPipeline run identifier
logIdYesLog identifier from the timeline record
formatNoOptional format for the log contents (plain or json)
startLineNoOptional starting line number for the log segment
endLineNoOptional ending line number for the log segment
pipelineIdNoOptional pipeline numeric ID for reference only

Implementation Reference

  • Implements the core logic for retrieving pipeline logs from Azure DevOps, handling both JSON and plain text formats, with error handling for authentication and not found cases.
    export async function getPipelineLog(
      connection: WebApi,
      options: GetPipelineLogOptions,
    ): Promise<PipelineLogContent> {
      try {
        const buildApi = await connection.getBuildApi();
        const projectId = options.projectId ?? defaultProject;
        const { runId, logId, format, startLine, endLine } = options;
    
        if (format === 'json') {
          const route = `${encodeURIComponent(projectId)}/_apis/build/builds/${runId}/logs/${logId}`;
          const baseUrl = connection.serverUrl.replace(/\/+$/, '');
          const url = new URL(`${route}`, `${baseUrl}/`);
          url.searchParams.set('api-version', API_VERSION);
          url.searchParams.set('format', 'json');
          if (typeof startLine === 'number') {
            url.searchParams.set('startLine', startLine.toString());
          }
          if (typeof endLine === 'number') {
            url.searchParams.set('endLine', endLine.toString());
          }
    
          const requestOptions = buildApi.createRequestOptions(
            'application/json',
            API_VERSION,
          );
    
          const response = await buildApi.rest.get<PipelineLogContent | null>(
            url.toString(),
            requestOptions,
          );
    
          if (response.statusCode === 404 || response.result === null) {
            throw new AzureDevOpsResourceNotFoundError(
              `Log ${logId} not found for run ${runId} in project ${projectId}`,
            );
          }
    
          return response.result;
        }
    
        const lines = await buildApi.getBuildLogLines(
          projectId,
          runId,
          logId,
          startLine,
          endLine,
        );
    
        if (!lines) {
          throw new AzureDevOpsResourceNotFoundError(
            `Log ${logId} not found for run ${runId} in project ${projectId}`,
          );
        }
    
        return lines.join('\n');
      } 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 log or project not found: ${error.message}`,
            );
          }
        }
    
        throw new AzureDevOpsError(
          `Failed to retrieve pipeline log: ${
            error instanceof Error ? error.message : String(error)
          }`,
        );
      }
    }
  • Zod schema defining and validating the input parameters for the get_pipeline_log tool.
    export const GetPipelineLogSchema = z.object({
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      runId: z.number().int().min(1).describe('Pipeline run identifier'),
      logId: z
        .number()
        .int()
        .min(1)
        .describe('Log identifier from the timeline record'),
      format: z
        .enum(['plain', 'json'])
        .optional()
        .describe('Optional format for the log contents (plain or json)'),
      startLine: z
        .number()
        .int()
        .min(0)
        .optional()
        .describe('Optional starting line number for the log segment'),
      endLine: z
        .number()
        .int()
        .min(0)
        .optional()
        .describe('Optional ending line number for the log segment'),
      pipelineId: z
        .number()
        .int()
        .min(1)
        .optional()
        .describe('Optional pipeline numeric ID for reference only'),
    });
  • Registers the get_pipeline_log tool in the MCP tool definitions array, including name, description, and converted input schema.
    {
      name: 'get_pipeline_log',
      description:
        'Retrieve a specific pipeline log using the timeline log identifier',
      inputSchema: zodToJsonSchema(GetPipelineLogSchema),
      mcp_enabled: true,
    },
  • Dispatches the get_pipeline_log tool request by parsing arguments, calling the handler, and formatting the response in the pipelines request handler.
    case 'get_pipeline_log': {
      const args = GetPipelineLogSchema.parse(request.params.arguments);
      const result = await getPipelineLog(connection, {
        ...args,
        projectId: args.projectId ?? defaultProject,
      });
      const text =
        typeof result === 'string' ? result : JSON.stringify(result, null, 2);
      return {
        content: [{ type: 'text', text }],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a retrieval operation, implying read-only behavior, but doesn't specify authentication requirements, rate limits, error conditions, or what the return format looks like (though it mentions 'log contents' indirectly). For a tool with 7 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 that gets straight to the point with zero wasted words. It's appropriately sized for a retrieval tool and front-loads the core purpose without unnecessary elaboration.

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 tool's complexity (7 parameters, no output schema, no annotations), the description is inadequate. It doesn't explain what a 'pipeline log' contains, how it relates to other pipeline tools, what authentication is needed, or what the return value looks like. For a tool that likely returns structured log data, more context about the output would be helpful despite the lack of output schema.

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 already documents all parameters thoroughly. The description mentions 'timeline log identifier' which loosely maps to 'logId', but adds no additional meaning about parameter relationships, constraints, or usage patterns beyond what the schema provides. The baseline of 3 is appropriate when 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 ('Retrieve') and resource ('a specific pipeline log'), making the purpose understandable. It specifies using a 'timeline log identifier' which adds specificity. However, it doesn't explicitly differentiate from sibling tools like 'get_pipeline_run' or 'pipeline_timeline' that might also provide pipeline-related information.

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, context for when this retrieval is appropriate, or how it differs from other pipeline-related tools in the sibling list. The agent must infer usage from the name and parameters alone.

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