Fix bd-8zf2: MCP server auto-detects workspace from CWD
- Add _find_beads_db_in_tree() to walk up looking for .beads/*.db - Update _get_client() to auto-detect when workspace not set - Matches CLI behavior (no manual set_context needed after restart) - Add 8 comprehensive tests for auto-detection - Update existing tests to mock auto-detection in error cases Fixes silent failures after Amp restart. Amp-Thread-ID: https://ampcode.com/threads/T-c47f524d-c101-40d5-839a-659f52b9be48 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -430,16 +430,18 @@ class TestEdgeCases:
|
||||
async def test_no_workspace_raises_error(self):
|
||||
"""Test calling without workspace raises helpful error."""
|
||||
import os
|
||||
from beads_mcp import tools
|
||||
|
||||
# Clear env
|
||||
# Clear context and env
|
||||
tools.current_workspace.set(None)
|
||||
os.environ.pop("BEADS_WORKING_DIR", None)
|
||||
|
||||
# No ContextVar set, no env var
|
||||
# No ContextVar set, no env var, and auto-detect fails
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with patch("beads_mcp.tools.create_bd_client") as mock_create:
|
||||
with patch("beads_mcp.tools._find_beads_db_in_tree", return_value=None):
|
||||
await beads_ready_work()
|
||||
|
||||
assert "No workspace set" in str(exc_info.value)
|
||||
assert "No beads workspace found" in str(exc_info.value)
|
||||
|
||||
def test_canonicalize_path_cached(self, temp_projects):
|
||||
"""Test path canonicalization is cached for performance."""
|
||||
|
||||
Reference in New Issue
Block a user