Fix Feishu MCP npx resolution

This commit is contained in:
wuyang6
2026-05-11 17:25:16 +08:00
parent 2984cc44e8
commit 4964548fd1
3 changed files with 49 additions and 2 deletions
+18 -2
View File
@@ -2283,15 +2283,27 @@ def _feishu_paths(state: AgentState, account_id: str | None) -> dict[str, Path]:
def _feishu_command() -> list[str]:
return [
'npx',
_feishu_npx_executable(),
'-y',
f'--registry={FEISHU_NPM_REGISTRY}',
FEISHU_MCP_PACKAGE,
]
def _feishu_npx_executable() -> str:
explicit = os.environ.get('CLAW_NPX_BIN')
if explicit and Path(explicit).expanduser().exists():
return str(Path(explicit).expanduser())
node_bin_dir = os.environ.get('CLAW_NODE_BIN_DIR')
if node_bin_dir:
candidate = Path(node_bin_dir).expanduser() / 'npx'
if candidate.exists():
return str(candidate)
return shutil.which('npx') or 'npx'
def _feishu_env(paths: dict[str, Path]) -> dict[str, str]:
return {
env = {
'HOME': str(paths['home']),
'XDG_CONFIG_HOME': str(paths['config']),
'npm_config_cache': str(paths['npm_cache']),
@@ -2299,6 +2311,10 @@ def _feishu_env(paths: dict[str, Path]) -> dict[str, str]:
'NO_UPDATE_NOTIFIER': 'true',
'FEISHU_LOGIN_MODE': 'devicecode',
}
node_bin_dir = os.environ.get('CLAW_NODE_BIN_DIR')
if node_bin_dir:
env['PATH'] = f'{node_bin_dir}{os.pathsep}{os.environ.get("PATH", "")}'
return env
def _run_feishu_cli(