Skip to content

fix(mcp): stop prepending bin to PATH, export LLM_BIN instead - #226

Open
syf2211 wants to merge 1 commit into
sigoden:mainfrom
syf2211:fix/225-llm-bin-path-conflict
Open

syf2211 wants to merge 1 commit into
sigoden:mainfrom
syf2211:fix/225-llm-bin-path-conflict

Conversation

@syf2211

@syf2211 syf2211 commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Stop prepending llm-functions/bin to PATH during MCP tool execution. Export LLM_BIN instead and spawn tools via absolute bin paths.

Motivation

When an agent tool script runs a system command by bare name (e.g. xclock), prepending bin/ to PATH causes the shell to resolve llm-functions/bin/xclock instead of the real system binary if an agent shares that name. This leads to recursive agent invocation or confusing failures (#225).

Changes

  • mcp/server/index.js: remove PATH prepend; add resolveBinCommand() and spawn via absolute bin path; handle Windows .cmd shims
  • scripts/run-tool.* / run-agent.*: export LLM_BIN for nested llm-functions invocations
  • Document LLM_BIN in docs/environment-variables.md and mcp/server/README.md

Tests

argc link-web-search web_search_perplexity.sh
argc link-code-interpreter execute_js_code.js
argc test
  • demo_sh and demo_js tests pass; output confirms LLM_BIN is exported
  • demo_py.py test skipped by project tool list (pre-existing)

Notes

  • Agent/tool scripts that need to call other llm-functions commands should use $LLM_BIN/<name> explicitly
  • MCP server still invokes tools directly via absolute paths; no PATH mutation required

Fixes #225

When MCP tool scripts run system commands by bare name (e.g. xclock),
prepending llm-functions/bin to PATH caused recursive agent invocation
when an agent shared the same name.

- Spawn MCP tools via absolute bin path instead of PATH lookup
- Export LLM_BIN from all run-tool/run-agent entry points
- Handle Windows .cmd shims when spawning
- Document LLM_BIN in environment variable docs

Fixes sigoden#225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inside of a tool call the PATH environment variable starts with an entry to llm-functions/bin

1 participant