feat(agent): add MCP toolchain shims with config isolation#1879
Draft
wpfleger96 wants to merge 1 commit into
Draft
feat(agent): add MCP toolchain shims with config isolation#1879wpfleger96 wants to merge 1 commit into
wpfleger96 wants to merge 1 commit into
Conversation
db73ea3 to
ca20a52
Compare
Bundled shell shims that resolve bare uv, uvx, npx, and node commands to hermit-managed, config-isolated toolchains for MCP server spawning. Fixes the incident where a salt-managed /etc/uv/uv.toml with unsupported system-certs broke all MCP servers using bare uv commands. Shell shims (setup-common.sh + per-tool wrappers) bootstrap hermit with SHA-verified installer and isolated state. uv/uvx set UV_NO_CONFIG=1; npx/node use distinct empty npmrc files to avoid npm's double-load crash. Rust resolver rewrites bare commands to shim paths when available. build_child_env() propagates BUZZ_MCP_SHIM_DIR, BUZZ_MCP_HERMIT_DIR, and BUZZ_MCP_LOG_DIR through env_clear() with spec.env last-write-wins. mcp_init_timeout bumped from 30s to 300s (env-overridable). Desktop integration bundles shims as Tauri resources with ensure_shims_executable() and separates writable hermit state from the signed app bundle.
ca20a52 to
3baf39e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundled shell shims that resolve bare
uv,uvx,npx, andnodecommands to hermit-managed, config-isolated toolchains for MCP server spawning. This fixes the incident where a salt-managed/etc/uv/uv.tomlwith unsupportedsystem-certsbroke all MCP servers using bareuvcommands.Shell shims (
crates/buzz-agent/resources/shims/)setup-common.sh: shared hermit bootstrap with SHA-verified installer,mkdir-based lock with PID+timestamp stale detection (600s), isolatedHERMIT_STATE_DIR, macOS PATH fix, Linux temp-binary workaround. Logging to$BUZZ_MCP_LOG_DIR/mcp-shim.logwithumask 077— never logs arguments or env var values.uv/uvx:UV_NO_CONFIG=1suppresses all uv config file discovery — direct defense against the incident.npx/node: two distinct empty npmrc files (empty-user-npmrc+empty-global-npmrc) avoid npm's double-load crash,NPM_CONFIG_LOCATION=globalsuppresses project.npmrcdiscovery.Rust changes
mcp.rs): purecfg(unix)resolve_shim_command(command, shim_dir)rewrites bareuv/uvx/npx/nodeto<shim_dir>/<command>when the shim file exists. Absolute paths and unknown commands pass through unchanged.mcp.rs):build_child_env()/build_child_env_with()propagatesBUZZ_MCP_SHIM_DIR,BUZZ_MCP_HERMIT_DIR, andBUZZ_MCP_LOG_DIRthroughenv_clear()into the child process, then appliesspec.envwith last-write-wins semantics so explicit server overrides take precedence.config.rs):mcp_init_timeoutdefault bumped from 30s to 300s (matches Goose). Env-overridable viaBUZZ_AGENT_MCP_INIT_TIMEOUT_SECS.Desktop integration (
runtime.rs,tauri.conf.json)ensure_shims_executable()for execute-bit preservation.BUZZ_MCP_SHIM_DIRset fromresource_dir/shims(read-only bundle resources).BUZZ_MCP_HERMIT_DIRset fromapp_data_dir/mcp-hermit(writable state) — separated from the signed app bundle.BUZZ_MCP_LOG_DIRset fromdata_local_dir/xyz.block.buzz.app/logs.Tests
Unit tests (9 new in
mcp.rs):Noneshim dir, missing shim file.build_child_env_propagates_shim_vars_and_spec_overrides): verifies all threeBUZZ_MCP_*variables propagate throughbuild_child_env_with()and that explicitspec.envoverrides win via last-write-wins.Integration tests (7 in
tests/shim_hostile_config.rs):npm_uses_distinct_config_files: user and global npmrc are separate files.uv,uvx,npx, andnodewrappers throughsetup-common.shwith a pre-seeded fake hermit dir containing probe scripts. VerifiesUV_NO_CONFIG=1for uv/uvx, npm isolation vars for npx/node, and explicitUV_INDEX_URLoverride passthrough. No network dependency.