Skip to content

Fix wtc_list MCP tool always reporting status as "up"#4

Open
samjbobb wants to merge 1 commit into
LevwTech:mainfrom
samjbobb:fix-mcp-list-status
Open

Fix wtc_list MCP tool always reporting status as "up"#4
samjbobb wants to merge 1 commit into
LevwTech:mainfrom
samjbobb:fix-mcp-list-status

Conversation

@samjbobb
Copy link
Copy Markdown

@samjbobb samjbobb commented May 10, 2026

Summary

The wtc_list MCP tool reports status: "up" for every worktree regardless of whether its compose stack is actually running. The CLI's wtc list is correct; the MCP version isn't.

Root cause

docker compose -p <project> ps --format json exits 0 with empty output when the project doesn't exist. The MCP server's check is:

const up =
  execSafe(`docker compose -p "${project}" ps --format json`, {
    cwd: wt.path,
  }) !== null;

execSafe returns null only when the command throws — empty stdout from a non-existent project still returns a string, so up is always true.

The CLI already handles this correctly in src/commands/list.ts:

return result !== null && result.length > 2;

This PR applies the same length > 2 guard in the MCP listWorktrees.

Repro

With no worktree compose stacks running:

$ docker compose -p valencia-wt-2-mybranch ps --format json
$ echo $?
0

Empty output, exit 0 → MCP reports up, CLI correctly reports down.

After

MCP wtc_list status field now matches the CLI.

Test plan

  • pnpm build passes
  • pnpm test — all 33 existing tests pass
  • Manual: with no compose stacks running, MCP wtc_list returns status: "down" for all worktrees, matching wtc list
  • Manual: after wtc start <n>, MCP wtc_list returns status: "up" for that worktree

Summary by CodeRabbit

  • Bug Fixes
    • Improved worktree status detection to be more accurate and reliable when determining operational status.

Review Change Stack

`docker compose -p <project> ps --format json` exits 0 with empty output
for a project that doesn't exist, so the previous `execSafe(...) !== null`
check treated every worktree as up regardless of whether its compose
stack was actually running.

The CLI's `listCommand` already guards against this with a
`result.length > 2` check (in src/commands/list.ts). Apply the same
guard in the MCP server's `listWorktrees` so its `status` field matches
the CLI output.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 683ae189-f963-499a-bd2e-968d927332be

📥 Commits

Reviewing files that changed from the base of the PR and between abcc90c and ff49a7b.

📒 Files selected for processing (1)
  • src/mcp/server.ts

📝 Walkthrough

Walkthrough

The listWorktrees function now refines container status detection by validating both the presence and meaningful content of docker compose ps --format json output. The status is marked "up" only when output is non-null with length greater than 2, replacing the prior check that only validated non-nullity.

Changes

Container Status Detection

Layer / File(s) Summary
Status Logic Refinement
src/mcp/server.ts
Container status is now determined by assigning execSafe output to psOutput and validating both non-nullity and length > 2, replacing the prior non-null-only check.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

A rabbit checks the Docker stream,
No longer trusting null's mere gleam,
For length must pass the test of two,
Now status glows with certainty true! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix wtc_list MCP tool always reporting status as "up"' directly and clearly describes the main bug being fixed in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant