#719·ruflo

MCP Integration Tests: Agent file parsing errors in AgentLoader

Author: coderabbitai[bot]Created Sep 5, 2025Updated Sep 16, 2026

Problem

The MCP integration tests reference "Error parsing agent file" failures, likely related to the AgentLoader component attempting to parse agent definition files from .claude/agents/.

Error Details

  • Error type: "Error parsing agent file"
  • Component: src/agents/agent-loader.ts
  • Related files: Agent markdown files in .claude/agents/ directory

Root Cause Analysis

The AgentLoader attempts to parse agent definition files from markdown with YAML frontmatter. Potential issues:

  1. Missing or malformed YAML frontmatter in agent files
  2. Missing required fields (name, metadata.description)
  3. Invalid YAML syntax in frontmatter sections
  4. File access permissions or missing files

Impact

  • Agent definitions may not load properly
  • MCP tools that depend on agent spawning may fail
  • System initialization may be affected

Investigation Findings

  • .claude/agents/ directory exists with multiple agent files
  • AgentLoader expects specific frontmatter format:
    ---
    name: agent-name
    metadata:
      description: "Agent description"
    ---
    

Reproduction Steps

  1. Run agent loader in test environment
  2. Observe parsing errors for specific agent files
  3. Check console output for detailed error messages

Suggested Fix

  1. Validate agent file formats - Ensure all .md files have proper YAML frontmatter
  2. Add better error handling - More specific error messages for different failure types
  3. Add file validation - Pre-validate agent files during initialization
  4. Improve logging - Include file paths in error messages for easier debugging

Related Files

  • src/agents/agent-loader.ts (main parsing logic)
  • .claude/agents/**/*.md (agent definition files)
  • tests/integration/mcp.test.ts (affected test)

Backlinks: