[Bug] Projman diagnostic failure: MCP tools require explicit repo format #70

Closed
opened 2026-01-21 21:20:39 +00:00 by lmiranda · 1 comment
Owner

Summary

The projman Gitea MCP tools fail when called without an explicit repo parameter, even when operating within a project that has Gitea configuration documented in CLAUDE.md.

Failed Tests

Command: /projman:labels-sync

First Attempt (Failed):

mcp__plugin_projman_gitea__validate_repo_org()
mcp__plugin_projman_gitea__get_labels()

Error Message:

Error: Use 'owner/repo' format (e.g. 'org/repo-name')

Second Attempt (Success):

mcp__plugin_projman_gitea__validate_repo_org(repo="personal-projects/personal-portfolio")
mcp__plugin_projman_gitea__get_labels(repo="personal-projects/personal-portfolio")

Expected Behavior

The MCP tools should either:

  1. Read a default repository from project configuration (e.g., from CLAUDE.md or a .projman config file)
  2. Infer the repository from git remote configuration
  3. Provide a clearer error message suggesting how to configure a default

Repository Context

  • Project: personal-portfolio
  • Gitea Repo: personal-projects/personal-portfolio
  • Host: gitea.hotserv.cloud
  • CLAUDE.md contains: Full Gitea configuration including repo path, host, and SSH URL

Additional Observations

  • Once repo parameter is provided explicitly, all tools work correctly
  • The repo parameter is marked as optional in tool descriptions ("for PMO mode") but appears to be required
  • This creates friction for single-repo workflows where the repo should be implicit

Suggested Fix

Consider adding a configuration mechanism (environment variable, config file, or git remote detection) to set a default repository context for non-PMO workflows.


Labels: Type: Bug, Source: Internal

## Summary The projman Gitea MCP tools fail when called without an explicit `repo` parameter, even when operating within a project that has Gitea configuration documented in CLAUDE.md. ## Failed Tests **Command:** `/projman:labels-sync` **First Attempt (Failed):** ``` mcp__plugin_projman_gitea__validate_repo_org() mcp__plugin_projman_gitea__get_labels() ``` **Error Message:** ``` Error: Use 'owner/repo' format (e.g. 'org/repo-name') ``` **Second Attempt (Success):** ``` mcp__plugin_projman_gitea__validate_repo_org(repo="personal-projects/personal-portfolio") mcp__plugin_projman_gitea__get_labels(repo="personal-projects/personal-portfolio") ``` ## Expected Behavior The MCP tools should either: 1. Read a default repository from project configuration (e.g., from CLAUDE.md or a `.projman` config file) 2. Infer the repository from git remote configuration 3. Provide a clearer error message suggesting how to configure a default ## Repository Context - **Project:** personal-portfolio - **Gitea Repo:** `personal-projects/personal-portfolio` - **Host:** `gitea.hotserv.cloud` - **CLAUDE.md contains:** Full Gitea configuration including repo path, host, and SSH URL ## Additional Observations - Once repo parameter is provided explicitly, all tools work correctly - The `repo` parameter is marked as optional in tool descriptions ("for PMO mode") but appears to be required - This creates friction for single-repo workflows where the repo should be implicit ## Suggested Fix Consider adding a configuration mechanism (environment variable, config file, or git remote detection) to set a default repository context for non-PMO workflows. --- **Labels:** Type: Bug, Source: Internal
Author
Owner

Fix Applied

Root Cause

The MCP server runs with cwd set to the plugin directory (${CLAUDE_PLUGIN_ROOT}/mcp-servers/gitea), not the user's project directory. This caused:

  • Path.cwd() to return the plugin directory
  • git remote get-url origin to run in the wrong directory
  • Auto-detection to fail

Solution

Added _find_project_directory() method in config.py with multiple detection strategies:

  1. CLAUDE_PROJECT_DIR - Environment variable (if set by Claude Code)
  2. PWD - Original working directory before cwd override (if has .git or .env)
  3. cwd - Current directory fallback (for tests and direct execution)

The git remote command now runs in the detected project directory.

Tests Added

  • test_find_project_directory_from_env
  • test_find_project_directory_from_cwd
  • test_find_project_directory_none_when_no_markers

All 9 config tests passing.

PRs

  • PR #71: Fix merged to development
  • PR #72: Ready for release to main

Workaround (if needed before update)

If the fix doesn't work in your environment, set GITEA_REPO explicitly in your project's .env:

GITEA_REPO=personal-projects/personal-portfolio
## Fix Applied ### Root Cause The MCP server runs with `cwd` set to the plugin directory (`${CLAUDE_PLUGIN_ROOT}/mcp-servers/gitea`), not the user's project directory. This caused: - `Path.cwd()` to return the plugin directory - `git remote get-url origin` to run in the wrong directory - Auto-detection to fail ### Solution Added `_find_project_directory()` method in `config.py` with multiple detection strategies: 1. **CLAUDE_PROJECT_DIR** - Environment variable (if set by Claude Code) 2. **PWD** - Original working directory before cwd override (if has `.git` or `.env`) 3. **cwd** - Current directory fallback (for tests and direct execution) The git remote command now runs in the detected project directory. ### Tests Added - `test_find_project_directory_from_env` - `test_find_project_directory_from_cwd` - `test_find_project_directory_none_when_no_markers` **All 9 config tests passing.** ### PRs - PR #71: Fix merged to development - PR #72: Ready for release to main ### Workaround (if needed before update) If the fix doesn't work in your environment, set `GITEA_REPO` explicitly in your project's `.env`: ``` GITEA_REPO=personal-projects/personal-portfolio ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/leo-claude-mktplace#70