Skip to main content
Glama
oaslananka

MCP Health Monitor

Get Pipeline Logs

get_pipeline_logs
Read-only

Fetch logs from Azure DevOps builds to diagnose pipeline failures. Specify pipeline group and name, optionally target a specific build or filter to failed steps only.

Instructions

Fetch logs from a specific Azure DevOps build to investigate pipeline failures.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_nameYesPipeline group name
pipeline_nameYesSpecific pipeline name (e.g. "mcp-ssh-tool CI")
build_idNoSpecific build ID. If omitted, fetches the latest build.
failed_onlyNoOnly return logs from failed steps

Implementation Reference

  • Core handler that fetches pipeline build logs from Azure DevOps. Retrieves the build timeline, filters records (optionally for failed steps only), and fetches the last 50 lines of log text for up to 5 steps.
    export async function getPipelineLogs(
      org: string,
      project: string,
      buildId: number,
      pat: string,
      failedOnly: boolean
    ): Promise<string> {
      const timelineUrl = `${BASE}/${org}/${project}/_apis/build/builds/${buildId}/timeline?api-version=7.1`;
      const timeline = asObject(await azureGet(timelineUrl, pat));
      const records = Array.isArray(timeline.records) ? timeline.records.map(asObject) : [];
      const selected = records.filter((record) =>
        failedOnly
          ? asString(record.result) === 'failed' && getNestedString(record, 'log', 'url')
          : getNestedString(record, 'log', 'url')
      );
    
      if (!selected.length) {
        return 'No failed steps found or logs not available yet.';
      }
    
      const authHeader = `Basic ${Buffer.from(`:${pat}`, 'utf8').toString('base64')}`;
      const parts: string[] = [];
    
      for (const record of selected.slice(0, 5)) {
        const logUrl = getNestedString(record, 'log', 'url');
        const stepName = asString(record.name) ?? 'unknown-step';
        const result = asString(record.result) ?? 'unknown';
    
        if (!logUrl) {
          continue;
        }
    
        try {
          const text = await fetchAzureLogText(logUrl, authHeader);
          const relevant = text.split('\n').slice(-50).join('\n');
          parts.push(`\n=== ${stepName} (${result}) ===\n${relevant}`);
        } catch {
          parts.push(`\n=== ${stepName} - log fetch failed ===`);
        }
      }
    
      return parts.join('\n');
    }
  • Zod schema defining the input parameters for the get_pipeline_logs tool: group_name, pipeline_name, optional build_id, and failed_only (default true).
    export const RegisteredPipelineLogsSchema = z.object({
      group_name: z.string().describe('Pipeline group name'),
      pipeline_name: z.string().describe('Specific pipeline name (e.g. "mcp-ssh-tool CI")'),
      build_id: z
        .number()
        .int()
        .optional()
        .describe('Specific build ID. If omitted, fetches the latest build.'),
      failed_only: z.boolean().default(true).describe('Only return logs from failed steps')
    });
  • TypeScript type inferred from the RegisteredPipelineLogsSchema.
    export type RegisteredPipelineLogsInput = z.infer<typeof RegisteredPipelineLogsSchema>;
  • src/app.ts:424-479 (registration)
    Registration of the 'get_pipeline_logs' tool on the MCP server, including the handler that looks up the pipeline from the registry, optionally fetches the latest build ID, then delegates to the core getPipelineLogs function.
    server.registerTool(
      'get_pipeline_logs',
      {
        title: 'Get Pipeline Logs',
        description:
          'Fetch logs from a specific Azure DevOps build to investigate pipeline failures.',
        inputSchema: RegisteredPipelineLogsSchema,
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          openWorldHint: true
        }
      },
      async (input: RegisteredPipelineLogsInput) => {
        const row = getAzurePipeline(input.group_name, input.pipeline_name);
    
        if (!row) {
          throw new Error(`Pipeline not registered: ${input.group_name}/${input.pipeline_name}`);
        }
    
        if (!row.pipeline_id) {
          throw new Error(`Pipeline ID not resolved for ${input.group_name}/${input.pipeline_name}`);
        }
    
        const pat = decodePatToken(row.pat_token_encrypted);
        let buildId = input.build_id;
    
        if (!buildId) {
          const latest = await getLatestRun(row.organization, row.project, row.pipeline_id, pat);
          buildId = latest?.id;
    
          if (latest) {
            recordPipelineRun(row.group_name, row.pipeline_name, latest);
          }
        }
    
        if (!buildId) {
          throw new Error('No recent builds found');
        }
    
        const logs = await getPipelineLogs(
          row.organization,
          row.project,
          buildId,
          pat,
          input.failed_only
        );
    
        return formatResponse({
          group: input.group_name,
          pipeline: input.pipeline_name,
          build_id: buildId,
          logs
        });
      }
    );
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the safety profile is clear. The description adds 'to investigate pipeline failures' but doesn't disclose additional behavioral traits like pagination or log format. No contradiction with annotations.

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?

Single sentence with no fluff, directly states purpose and context. Every word earns its place.

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

Completeness4/5

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

With no output schema, the description could explain return format (e.g., text logs), but the input parameters are fully described in the schema. The addition of 'to investigate pipeline failures' provides usage context. Slightly incomplete but adequate for a simple logs tool.

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 baseline is 3. The description does not add extra meaning beyond the schema; it mentions investigating failures but doesn't tie directly to parameters like failed_only. It meets the minimum but doesn't enhance understanding.

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

Purpose5/5

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

The description clearly states the tool fetches logs from a specific Azure DevOps build to investigate pipeline failures. The verb 'fetch' and resource 'logs' are specific, and the context of investigating failures distinguishes it from sibling tools like check_pipeline_status.

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

Usage Guidelines3/5

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

The description implies usage for investigating pipeline failures but does not explicitly state when not to use it or mention alternatives like check_pipeline_status for overall status checks. The intent is clear but lacks exclusions.

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/oaslananka/mcp-health-monitor'

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