Add "lessons/sprints/sprint-3---mcp-server-branch-detection-bug-runs-from-installed-dir"
41
lessons%2Fsprints%2Fsprint-3---mcp-server-branch-detection-bug-runs-from-installed-dir.-.md
Normal file
41
lessons%2Fsprints%2Fsprint-3---mcp-server-branch-detection-bug-runs-from-installed-dir.-.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Sprint 3 - MCP Server Branch Detection Bug (Runs From Installed Dir)
|
||||
|
||||
## Metadata
|
||||
- **Implementation:** [Change V5.2.0: Plugin Enhancements Proposal (Sprint 3 Hooks)](https://gitea.hotserv.cloud/personal-projects/leo-claude-mktplace/wiki/Change-V5.2.0:-Plugin-Enhancements-Proposal)
|
||||
- **Issues:** #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:
|
||||
1. Pass the user's working directory to the MCP server
|
||||
2. Use Claude's environment variables to detect the actual project path
|
||||
3. 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:
|
||||
1. Remember MCP servers run in their OWN sandbox/directory
|
||||
2. Don't assume filesystem paths match the user's project
|
||||
3. If project context is needed, explicitly receive it as a parameter
|
||||
4. Test MCP tools from different working directories
|
||||
|
||||
## Tags
|
||||
mcp, gitea, branch-detection, bug, sprint-3
|
||||
|
||||
---
|
||||
**Tags:** mcp, gitea, branch-detection, bug, sprint-3
|
||||
Reference in New Issue
Block a user