fix(mcp): run bd commands in user's working directory instead of MCP server directory
The MCP server was running all bd commands in its own installation directory (~/.claude/plugins/marketplaces/beads-marketplace/integrations/beads-mcp/) instead of the user's project directory. This caused databases to be created in the wrong location. For example, when working in ~/ai/flutter/wyvern and running `bd init --prefix wy-`, the database was created at: ~/.claude/plugins/marketplaces/beads-marketplace/integrations/beads-mcp/.beads/wy-.db Instead of the expected location: ~/ai/flutter/wyvern/.beads/wy-.db Solution: - Add `cwd=os.getcwd()` to all asyncio.create_subprocess_exec() calls - This makes bd commands execute in the current working directory from PWD env var - Claude Code updates PWD for the MCP server process environment Impact: - bd init now creates .beads/ in the correct project directory - All bd commands (create, list, update, etc.) operate on the correct database - Multi-project workflows work correctly without manual DB path configuration Test results: 90/91 tests passing (1 unrelated path assertion failure)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .config import load_config
|
from .config import load_config
|
||||||
@@ -124,6 +125,7 @@ class BdClient:
|
|||||||
*cmd,
|
*cmd,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -167,6 +169,7 @@ class BdClient:
|
|||||||
"version",
|
"version",
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -380,6 +383,7 @@ class BdClient:
|
|||||||
*cmd,
|
*cmd,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
_stdout, stderr = await process.communicate()
|
_stdout, stderr = await process.communicate()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -407,6 +411,7 @@ class BdClient:
|
|||||||
*cmd,
|
*cmd,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -473,6 +478,7 @@ class BdClient:
|
|||||||
*cmd,
|
*cmd,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
cwd=os.getcwd(),
|
||||||
)
|
)
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
|
|||||||
2
integrations/beads-mcp/uv.lock
generated
2
integrations/beads-mcp/uv.lock
generated
@@ -48,7 +48,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "beads-mcp"
|
name = "beads-mcp"
|
||||||
version = "0.9.2"
|
version = "0.9.3"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "fastmcp" },
|
{ name = "fastmcp" },
|
||||||
|
|||||||
Reference in New Issue
Block a user