BUG: MCP File-Reading Tools Broken — "Maximum call stack size exceeded" Blocks Agent Operations #2205

Open
opened 2026-04-03 09:30:56 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/mcp-file-reading-tools-stack-overflow
  • Commit Message: fix(tooling): resolve maximum call stack size exceeded error in MCP file-reading tools
  • Milestone: v3.8.0
  • Parent Epic: #1678

Summary

Multiple MCP file-reading tools are throwing a fatal Maximum call stack size exceeded JavaScript/runtime error, rendering them completely non-functional. This blocks any agent that depends on reading local files — including the ca-ref-reader sub-agent and any agent that needs to inspect source code, configuration, or documentation files during task execution.

Affected Tools

The following tools are confirmed broken (all return Maximum call stack size exceeded):

  • Read — reads a file or directory from the local filesystem
  • filesystem_read_file — reads file contents as text
  • filesystem_read_text_file — reads file contents as text (alternate)
  • filesystem_read_multiple_files — reads multiple files simultaneously

All attempts to read /app/CONTRIBUTING.md, /app/docs/specification.md, and /app/docs/timeline.md failed with the same error.

Impact

  • ca-ref-reader sub-agent is fully blocked — it cannot read project reference materials and returns an error on every invocation.
  • Any agent requiring file inspection is blocked — agents cannot read source files, configuration, or documentation to perform their tasks.
  • Issue creation quality is degraded — without access to CONTRIBUTING.md, agents cannot verify issue formatting rules and must rely on cached/inferred knowledge.
  • Cascading failures — any workflow that calls ca-ref-reader or uses file-reading tools will fail silently or with a stack overflow error.

Steps to Reproduce

  1. Invoke any of the affected tools with a valid file path (e.g., /app/CONTRIBUTING.md)
  2. Observe: tool returns Maximum call stack size exceeded instead of file contents

Expected Behavior

File-reading tools should return the contents of the requested file without error.

Actual Behavior

Error: Maximum call stack size exceeded.

Root Cause Hypothesis

The error is consistent with infinite recursion in the MCP tool server implementation — likely a circular dependency, recursive middleware, or a recursive call in the file-reading handler that has no base case or termination condition. This may have been introduced by a recent change to the MCP server configuration or a dependency update.

Subtasks

  • Identify the MCP server component responsible for the Read / filesystem_read_* tools
  • Reproduce the stack overflow locally with a minimal test case
  • Trace the call stack to identify the recursive loop or circular dependency
  • Apply fix (break the recursion / circular dependency)
  • Verify all affected tools (Read, filesystem_read_file, filesystem_read_text_file, filesystem_read_multiple_files) return correct results
  • Verify ca-ref-reader sub-agent can successfully read CONTRIBUTING.md, docs/specification.md, and docs/timeline.md
  • Add a regression test to prevent reintroduction of this error
  • Run nox (all default sessions) and fix any errors
  • Verify coverage > 97% via nox -s coverage_report

Definition of Done

  • All affected file-reading MCP tools return correct file contents without error
  • ca-ref-reader sub-agent successfully reads all three project reference files
  • A regression test is in place to catch future stack overflow errors in MCP tool handlers
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(tooling): resolve maximum call stack size exceeded error in MCP file-reading tools), followed by a blank line, then additional details
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (fix/mcp-file-reading-tools-stack-overflow)
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done
  • All nox stages pass
  • Coverage > 97%

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-state-updater

## Metadata - **Branch**: `fix/mcp-file-reading-tools-stack-overflow` - **Commit Message**: `fix(tooling): resolve maximum call stack size exceeded error in MCP file-reading tools` - **Milestone**: v3.8.0 - **Parent Epic**: #1678 ## Summary Multiple MCP file-reading tools are throwing a fatal `Maximum call stack size exceeded` JavaScript/runtime error, rendering them completely non-functional. This blocks any agent that depends on reading local files — including the `ca-ref-reader` sub-agent and any agent that needs to inspect source code, configuration, or documentation files during task execution. ## Affected Tools The following tools are confirmed broken (all return `Maximum call stack size exceeded`): - `Read` — reads a file or directory from the local filesystem - `filesystem_read_file` — reads file contents as text - `filesystem_read_text_file` — reads file contents as text (alternate) - `filesystem_read_multiple_files` — reads multiple files simultaneously All attempts to read `/app/CONTRIBUTING.md`, `/app/docs/specification.md`, and `/app/docs/timeline.md` failed with the same error. ## Impact - **`ca-ref-reader` sub-agent is fully blocked** — it cannot read project reference materials and returns an error on every invocation. - **Any agent requiring file inspection is blocked** — agents cannot read source files, configuration, or documentation to perform their tasks. - **Issue creation quality is degraded** — without access to `CONTRIBUTING.md`, agents cannot verify issue formatting rules and must rely on cached/inferred knowledge. - **Cascading failures** — any workflow that calls `ca-ref-reader` or uses file-reading tools will fail silently or with a stack overflow error. ## Steps to Reproduce 1. Invoke any of the affected tools with a valid file path (e.g., `/app/CONTRIBUTING.md`) 2. Observe: tool returns `Maximum call stack size exceeded` instead of file contents ## Expected Behavior File-reading tools should return the contents of the requested file without error. ## Actual Behavior ``` Error: Maximum call stack size exceeded. ``` ## Root Cause Hypothesis The error is consistent with infinite recursion in the MCP tool server implementation — likely a circular dependency, recursive middleware, or a recursive call in the file-reading handler that has no base case or termination condition. This may have been introduced by a recent change to the MCP server configuration or a dependency update. ## Subtasks - [ ] Identify the MCP server component responsible for the `Read` / `filesystem_read_*` tools - [ ] Reproduce the stack overflow locally with a minimal test case - [ ] Trace the call stack to identify the recursive loop or circular dependency - [ ] Apply fix (break the recursion / circular dependency) - [ ] Verify all affected tools (`Read`, `filesystem_read_file`, `filesystem_read_text_file`, `filesystem_read_multiple_files`) return correct results - [ ] Verify `ca-ref-reader` sub-agent can successfully read `CONTRIBUTING.md`, `docs/specification.md`, and `docs/timeline.md` - [ ] Add a regression test to prevent reintroduction of this error - [ ] Run `nox` (all default sessions) and fix any errors - [ ] Verify coverage > 97% via `nox -s coverage_report` ## Definition of Done - [ ] All affected file-reading MCP tools return correct file contents without error - [ ] `ca-ref-reader` sub-agent successfully reads all three project reference files - [ ] A regression test is in place to catch future stack overflow errors in MCP tool handlers - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(tooling): resolve maximum call stack size exceeded error in MCP file-reading tools`), followed by a blank line, then additional details - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`fix/mcp-file-reading-tools-stack-overflow`) - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done - [ ] All nox stages pass - [ ] Coverage > 97% --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-state-updater
freemo added this to the v3.8.0 milestone 2026-04-03 09:31:08 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Critical — MCP file-reading tools are completely broken, blocking all agents that depend on reading local files including ca-ref-reader. This is a foundational infrastructure failure.
  • Milestone: v3.8.0 (already assigned)
  • MoSCoW: Should Have — While this is a critical operational bug, it affects the agent tooling infrastructure rather than core product functionality required by the specification. The v3.8.0 milestone focuses on Server Implementation; this bug blocks agent operations but not the core server deliverables.
  • Parent Epic: #1678 (CI Execution Time Optimization — already linked in issue body)

Duplicate check: Related to but distinct from #2210 (which is a broader meta-issue encompassing this bug plus additional Forgejo MCP and bash tool failures). This issue focuses specifically on the Maximum call stack size exceeded error in file-reading tools.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified ✅ - **Priority**: Critical — MCP file-reading tools are completely broken, blocking all agents that depend on reading local files including `ca-ref-reader`. This is a foundational infrastructure failure. - **Milestone**: v3.8.0 (already assigned) - **MoSCoW**: Should Have — While this is a critical operational bug, it affects the agent tooling infrastructure rather than core product functionality required by the specification. The v3.8.0 milestone focuses on Server Implementation; this bug blocks agent operations but not the core server deliverables. - **Parent Epic**: #1678 (CI Execution Time Optimization — already linked in issue body) **Duplicate check**: Related to but distinct from #2210 (which is a broader meta-issue encompassing this bug plus additional Forgejo MCP and bash tool failures). This issue focuses specifically on the `Maximum call stack size exceeded` error in file-reading tools. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#2205
No description provided.