Sprint 3 - MCP Server Branch Detection Bug (Runs From Installed Dir)
Metadata
- Implementation: Change V5.2.0: Plugin Enhancements Proposal (Sprint 3 Hooks)
- Issues: [Bug] Gitea MCP branch detection uses wrong directory (#231)
- Sprint: Sprint 3
Context
The Gitea MCP server implements branch-aware security - certain operations (like updating issues) are blocked on protected branches (main, master, production).
Problem
The branch detection code runs git branch --show-current from the MCP server's working directory, which is the installed plugin location (~/.claude/plugins/marketplaces/leo-claude-mktplace/), NOT the user's project directory.
Since the installed marketplace is typically on main branch (the stable release), the MCP server always thinks the user is on main, even when they're on a development or feature branch.
Symptom:
Error: Cannot update issues on branch 'main'. Switch to a development branch to update issues.
This error appears even when the user IS on a development branch.
Solution
Issue #231 created to track the fix. Potential solutions:
- Pass the user's working directory to the MCP server
- Use Claude's environment variables to detect the actual project path
- Remove branch-based restrictions from MCP (enforce at Claude level instead)
Workaround: Close issues via Gitea web UI until bug is fixed.
Prevention
When implementing security checks in MCP servers:
- Remember MCP servers run in their OWN sandbox/directory
- Don't assume filesystem paths match the user's project
- If project context is needed, explicitly receive it as a parameter
- Test MCP tools from different working directories
Tags
mcp, gitea, branch-detection, bug, sprint-3
Tags: mcp, gitea, branch-detection, bug, sprint-3