Skip to content

[Bug]: MCP server writes to main repo instead of git worktree #558

@mrkre

Description

@mrkre

Description

When using Backlog.md MCP server from within a git worktree, task files are created in the main repository's backlog/tasks/ directory instead of the current worktree's directory.

Steps to Reproduce

  1. Set up a project with Backlog.md and a protected main branch
  2. Create a git worktree: git worktree add .worktrees/feature-branch -b feature-branch main
  3. Open Claude Code (or any MCP client) with CWD set to the worktree
  4. Create a task via the MCP task_create tool

Expected: Task file created in .worktrees/feature-branch/backlog/tasks/
Actual: Task file created in the main repo's backlog/tasks/

Impact

Since main is protected, the task files created by MCP can't be committed. The workaround is to manually copy files from the main repo to the worktree, then delete the originals — which defeats the purpose of MCP automation.

Suggested Fix

Resolve the project root using process.cwd() or git rev-parse --show-toplevel at the time of each file operation, rather than at server startup. In a worktree, --show-toplevel correctly returns the worktree path.

Environment

  • Backlog.md: latest (installed via homebrew)
  • MCP config: backlog mcp start (stdio, user scope)
  • Git worktrees via git worktree add
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions