Skip to main content
Glama

diagnose_failure

Read-only

Analyze failed workflow steps by evaluating MCP schema, gate constraints, and approval requirements to identify root causes and compliance issues.

Instructions

Diagnose a failed or suspect workflow step using MCP schema, workflow, gate, and approval constraints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stepNo
contextNo
toolNameNo
toolArgsNo
outputNo
errorNo
exitCodeNo
intentIdNo
approvedNo
mcpProfileNo
verificationNo
rubricScoresNo
guardrailsNo

Implementation Reference

  • The core implementation of the diagnoseFailure logic, which orchestrates various violation checks and categorizes failure root causes.
    function diagnoseFailure(options = {}) {
      const compiledConstraints = options.compiledConstraints || compileFailureConstraints({
        toolSchemas: options.toolSchemas,
        intentPlan: options.intentPlan,
        allowedToolNames: options.allowedToolNames,
        mcpProfile: options.mcpProfile,
        projectRoot: options.projectRoot,
      });
      const toolPolicyViolations = findToolPolicyViolations(
        options.toolName,
        compiledConstraints,
      );
      const toolSchemaViolations = findToolSchemaViolations(
        options.toolName,
        options.toolArgs,
        compiledConstraints.toolSchemas,
        {
          skipMissingSchema: toolPolicyViolations.length > 0,
        },
      );
      const verificationViolations = findVerificationViolations(options.verification);
      const approvalViolations = findApprovalViolations(options.intentPlan);
      const guardrailViolations = findGuardrailViolations(options);
      const workflowViolations = findWorkflowViolations(options.context, compiledConstraints, options.verification);
      const systemViolations = findSystemViolations(options);
      const category = pickCategory({
        systemViolations,
        approvalViolations,
        guardrailViolations,
        toolPolicyViolations,
        toolSchemaViolations,
        verificationViolations,
        workflowViolations,
        context: options.context,
      });
    
      const evidence = buildEvidence(options);
      const violations = [
        ...systemViolations,
        ...approvalViolations,
        ...guardrailViolations,
        ...toolPolicyViolations,
        ...toolSchemaViolations,
        ...workflowViolations,
        ...verificationViolations,
      ];
      const suspicious = options.suspect === true
        || violations.length > 0
        || (options.verification && options.verification.passed === false);
    
      if (!category) {
        return {
          diagnosed: false,
          suspicious,
          rootCauseCategory: null,
          criticalFailureStep: null,
          violations: [],
          evidence,
          constraintSummary: compiledConstraints.summary,
        };
      }
    
      return {
        diagnosed: true,
        suspicious,
        rootCauseCategory: category || 'tool_output_misread',
        criticalFailureStep: options.step || (options.healthCheck && options.healthCheck.name) || options.toolName || 'verification',
        violations,
        evidence,
        constraintSummary: compiledConstraints.summary,
        compiledConstraints: options.includeConstraints === true ? compiledConstraints : undefined,
      };
    }
  • The MCP adapter handler that calls diagnoseFailure and maps tool arguments for the execution of the diagnose_failure tool.
      const result = diagnoseFailure({
        step: args.step,
        context: args.context || '',
        toolName: args.toolName,
        toolArgs: args.toolArgs,
        output: args.output,
        error: args.error,
        exitCode: args.exitCode,
        verification: args.verification,
        guardrails: args.guardrails,
        rubricScores: args.rubricScores,
        intentPlan,
        mcpProfile: requestedProfile,
        allowedToolNames,
        toolSchemas: TOOLS.filter((tool) => allowedToolNames.includes(tool.name)),
        includeConstraints: true,
        projectRoot: args.repoPath,
      });
    
      return toTextResult(result);
    }
  • The definition and schema registration for the diagnose_failure tool.
    readOnlyTool({
      name: 'diagnose_failure',
      description: 'Diagnose a failed or suspect workflow step using MCP schema, workflow, gate, and approval constraints.',
      inputSchema: {
        type: 'object',
        properties: {
          step: { type: 'string' },
          context: { type: 'string' },
          toolName: { type: 'string' },
          toolArgs: { type: 'object' },
          output: { type: 'string' },
          error: { type: 'string' },
          exitCode: { type: 'number' },
          intentId: { type: 'string' },
          approved: { type: 'boolean' },
          mcpProfile: { type: 'string' },
          verification: { type: 'object' },
          rubricScores: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                criterion: { type: 'string' },
Behavior3/5

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

The annotation declares readOnlyHint=true, which the description doesn't contradict. The description adds value by specifying what resources are used for diagnosis (MCP schema, workflow, gate, approval constraints), providing context beyond the annotation. However, it doesn't disclose other behavioral traits like rate limits, authentication needs, or what constitutes a 'diagnosis' output format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary elaboration. It's appropriately sized and front-loaded with the main action. However, it could be more structured by separating purpose from resource details.

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 (13 parameters, nested objects, no output schema) and minimal annotations (only readOnlyHint), the description is inadequate. It doesn't explain the diagnostic process, expected outputs, or how parameters interact. For a diagnostic tool with rich input schema but no output schema, more completeness is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for 13 parameters, the description carries full burden for explaining parameters but fails to do so. It mentions general resources (MCP schema, workflow, gate, approval constraints) but doesn't map these to specific parameters like 'step', 'context', or 'rubricScores'. The description adds minimal semantic value beyond what's inferable from parameter names.

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 tool's purpose: 'Diagnose a failed or suspect workflow step' using specific resources (MCP schema, workflow, gate, and approval constraints). It uses a specific verb ('diagnose') and identifies the target resource ('workflow step'), but doesn't explicitly differentiate from sibling tools like 'describe_reliability_entity' or 'evaluate_context_pack' that might also analyze workflow components.

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 minimal guidance on when to use this tool. It mentions 'failed or suspect workflow step' which gives some context, but offers no explicit guidance on when to choose this tool versus alternatives like 'describe_reliability_entity' or 'evaluate_context_pack', nor does it mention prerequisites or exclusions. The agent must infer usage from the purpose 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/IgorGanapolsky/mcp-memory-gateway'

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