Skip to content

feat(mcp): support absolute executable commands - #377

Merged
notowen333 merged 4 commits into
strands-agents:mainfrom
notowen333:codex/mcp-absolute-commands
Nov 10, 2026
Merged

notowen333 merged 4 commits into
strands-agents:mainfrom
notowen333:codex/mcp-absolute-commands

Conversation

@notowen333

@notowen333 notowen333 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Core rejects an absolute stdio MCP executable because command[0] also names the alias in bin/. This prevents selecting an installation outside PATH, or a specific installation when another version comes first.

Accept an absolute path in the existing command array. For command = ["/opt/tools/weather-mcp", "--stdio"], the harness calls weather-mcp --stdio and Core launches the configured file. Offline schema generation uses the same executable. A symbolic link keeps its invocation filename, while policy checks the resolved executable identity.

Core already mediates stdio MCP through an executable alias in <box_dir>/bin. The harness invokes that alias, either through PATH or by its full alias path, and Core starts the declared server after authorization. Invoking the original host executable directly does not route through that broker. This launch model applies whether the alias name is derived or configured in a separate field.

Why no new TOML field

command[0] already supplies the executable to launch. Its filename supplies the agent-facing alias, so path support does not require another operator choice. A separate executable field would split the launch command across fields; an alias field would add independent naming and validation rules. We chose the existing command array plus a derived filename for this feature.

An explicit alias field would let the operator choose a name independently of the executable filename. We accept that naming limit for this feature; a differently named symlink can provide another invocation name when the program supports it. The decision is recorded at MCP executable filenames name their aliases.

Accepted limitations

  • No configurable alias override. /a/server --stdio and /b/server --stdio produce the same harness invocation, so that duplicate is refused. Distinct arguments can distinguish servers; exact matches take priority and overlapping wildcard declarations are refused. Filenames retain the restricted character set and reserved names, including python3 and sh.
  • Permission and dependency setup remains explicit. Path selection adds no grants beyond the existing implicit executable grant and runtime minimum. Additional files, interpreters, helpers, credentials, and environment still need their normal setup. Policy must permit the server's startup and calls.
  • Existing executable resolution rules remain. Core resolves a bare name through PATH or uses a literal absolute path. Its resolver has no base-directory rule for relative executable paths and does not expand ~ or ${...} in the executable. Supporting those forms is separate from how the alias is named. A missing or invalid absolute target fails without falling back to PATH.

Related Issues

None.

Type of Change

New feature

Testing

  • cargo test -p strands-box --locked --all-features: 1,339 passed, with five existing ignored tests. The non-UTF-8 pathname test reports its existing filesystem prerequisite skip on this Mac.

  • mcp_schema_generation: 21 passed. The absolute-command test checks server/discover, initialize, notifications/initialized, and tools/list in order, and retains the selected-tool and PATH-decoy assertions. The original merged-head assertion failed locally with four messages instead of three.

  • runtime_mcp_start: 20 passed, including exact off-PATH selection, a PATH decoy, symlink invocation, no fallback, and canonical policy identity.

  • The configuration regressions fail against the previous implementation.

  • Core and containment helpers build with --locked --all-features. Formatting, Core clippy with the repository allowances, and the no-default-features build pass.

  • The local deterministic suite is GREEN: 129 passed, 12 declared Linux-only cases skipped, full coverage, and no integrity problems.

  • The examples gate exits successfully and reports that no scripted examples remain. The live SDK tutorial was not run.

  • CI is rerunning for 247a396; its Linux and macOS workspace results are pending.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)

  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

Core uses the first MCP command element as both the launch target and the
agent-facing alias. It rejects absolute paths, so an operator cannot select
an executable outside PATH or choose one installation when another comes first.

## Solution

Accept a bare name or an absolute path in the existing command array. Derive
the alias from the requested filename and retain the full executable for launch
and offline schema discovery. Preserve symlink invocation spelling. Apply the
existing exact-command and wildcard collision rules to the derived alias.
Relative paths, executable token expansion, and invalid or reserved alias names
remain refused. Existing containment and permission rules remain in effect.

Records with absolute MCP commands require version 28. Older records retain
their existing version. Older Core builds refuse the new records before they
can interpret absolute commands as alias paths. No TOML field, broker frame,
policy attribute, or mechanism-crate public API is added.

Document the approved choice at
mcp-executable-filenames-name-their-aliases in docs/design/decisions.md and
update the MCP, configuration, policy, alias, and record-version references.
Boxy import and permission resolution remain a separate follow-up.

## Tests

Core and containment helpers build with --locked --all-features. The final
compiled Core library suite passes all 787 tests. runtime_mcp_start passes
20 tests and mcp_schema_generation passes 21 tests. Named coverage includes:

- an_absolute_command_keeps_its_target_and_is_called_by_its_filename:
  the alias is the filename and the raw target remains available.
- absolute_commands_share_an_alias_but_require_distinct_arguments and
  absolute_commands_keep_the_wildcard_overlap_rules: derived aliases retain
  the existing collision and matching rules.
- absolute_commands_require_a_representable_filename and
  executable_paths_are_absolute_and_do_not_expand_tokens: invalid filenames,
  relative paths, and executable token expansion are refused.
- absolute_mcp_commands_require_their_own_record_version: version 28 takes
  precedence over other features and absolute-command records with an older
  version are refused.
- an_absolute_command_starts_its_selected_symlink_instead_of_a_path_decoy:
  the selected off-PATH server starts and retains its symlink invocation name.
- a_missing_absolute_command_never_falls_back_to_path: the decoy never starts.
- a_start_is_decided_on_the_canonical_program_and_its_arguments: the policy
  observes the basename command, canonical target, and configured arguments.
- generate_schema_uses_an_absolute_command_instead_of_a_path_decoy:
  offline discovery selects the configured file.

The new configuration regressions fail against the previous implementation.
Core clippy reports no owned warnings. cargo fmt --all --check and the
no-default-features build pass. Documentation and feature reviews find no
remaining source or documentation defect.

The full package test run stops during compilation with No space left on
device. It does not have a passing verdict. The existing non-UTF-8 filesystem
test reports its host prerequisite skip. Full workspace, Linux, deterministic
containment, and exhaustive mutation checks remain unrun locally. This change
opens as a draft for CI and human review.
@notowen333
notowen333 marked this pull request as ready for review November 9, 2026 00:15
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Assessment: Approve

I reviewed head ab00ee5 and found no correctness or contract defects. I posted no inline comments. Before you take this out of draft, run the open gates from the description: just check, and the Linux aarch64 runtime suites.

Assumptions and rules checked (all held)
  • unrepresentable admits only a bare name or a literal absolute path with a usable filename. These are refused: ./x, bin/x, ~/bin/x, /, /opt/bin/, /opt/bin/., /opt/bin/.., /opt/bin/sh, /opt/${V}/x, and a filename with a space or non-ASCII character. Bare uvx behaves as before.
  • Record version 28 is stamped whenever any absolute command is present. That holds with limits, wildcards, file-attributes, and native policy enabled. A config with only bare names keeps its earlier version. An older binary refuses version 28.
  • Alias placement, for_command, the shared-command check, and the wildcard-overlap check all use the derived filename. So /a/uvx fetch and uvx fetch collide as the docs say.
  • Policy program is the filename and program_path is the canonical file. This matches spelling.rs's ProgramSpelledAsPath lint, which already steers path matching to program_path. The symlink test pins it.
  • The contained launch resolves the absolute path with no fallback to PATH. executable::resolve does this, and the change does not touch guard.judge on the program's identity.
  • Root AGENTS.md: the version bump and reference pages ship in the same commit, and the decision entry covers the alias derivation, which is frozen. The shell:spawn start-gate premise is kept: authorize_mcp_start still runs before every launch.
What I ran locally (x86_64 Linux)
  • record::config::mcp:: and absolute_mcp_commands_require_their_own_record_version: 32 passed.
  • cargo fmt --check, and cargo clippy -p strands-box --all-targets --all-features with the just clippy allowances: both clean.
  • The full --lib suite: 732 passed, 64 failed. The one failure I traced was a missing strands-box-contain-trampoline binary. I put the rest down to the same build setup but did not check each one.
  • The new runtime_mcp_start tests skip on this host, because the namespace launcher needs aarch64. So the symlink, PATH decoy and no-fallback tests only have the author's run behind them for now.

Deriving the alias from the existing command array keeps the configuration surface unchanged, and the decision entry explains that tradeoff clearly.

…commands

# Conflicts:
#	docs/design/policy.md
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Assessment: Approve (re-review at 3cc8b3d)

The new head merges upstream/main (04fa0ac, #347) into the commit I reviewed before (ab00ee5). The merge leaves the PR's own files unchanged. The only conflict was in docs/design/policy.md. The resolution keeps the new hard-link paragraph from #347 and this PR's MCP filename-matching paragraph, and neither one loses a claim.

Checked on the merged head (all held)

A note outside this PR's scope, not blocking: validate_reach in ConfiguredCommands only keeps [tool] commands out of every process's write grants. An [mcp] command, bare or absolute, gets no such check. That was already true before this PR. With absolute paths it is now easier to point command[0] at a file the agent can write, so it may deserve its own follow-up issue.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Assessment: Request Changes (re-review at b31e204)

The new head merges main (#271, #348, #381, #350, #358) into 3cc8b3d. The conflicts were only in docs, and they were resolved correctly. One of this PR's own tests now fails because #350 changed the MCP handshake (see the inline comment). The fix is a single line.

Checked on the merged head (held)
  • Conflict resolution: In mcp-discovery.md, mcp-policy.md and mcp.md, the resolution keeps both this PR's wording about the alias plus effective arguments and feat: support MCP 2026-07-28 over stdio #350's text about the modern protocol. No claim was lost.
  • feat: support MCP 2026-07-28 over stdio #350's probe: It only changes which messages are exchanged. Schema generation still launches the absolute executable, not the decoy found on PATH (the test's selected_tool/decoy_tool assertions still pass).
  • fix(box): bind a tool grammar to how box cli binds tools #358's bound_name: It changes how a [tool] grammar binds its program name. It doesn't touch how MCP aliases are derived.
  • Tests and lints: Core lib (866 tests), tool_grammars (14) and runtime_mcp_start (20) pass once the helper binaries are built. Clippy (with the just clippy allowances) and cargo fmt --check are clean.

@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review at 247a396)

The only change since b31e204 is the fix for the blocking test failure I raised. generate_schema_uses_an_absolute_command_instead_of_a_path_decoy now expects 4 requests and checks their order: server/discover, initialize, notifications/initialized, tools/list. This matches the sibling test, so if the protocol changes again the test fails with a clear message instead of only a wrong count.

Checked (held)
  • The test file: mcp_schema_generation passes 21/21 at 247a396.
  • cargo fmt --check: clean.
  • The rest of the PR: nothing else changed since b31e204, so the earlier results still apply (conflicts resolved correctly; core lib, tool_grammars and runtime_mcp_start pass; clippy with the just clippy allowances is clean).

Nice fix: checking the order of the requests is better than updating only the count.

@rvkandury
rvkandury self-requested a review November 10, 2026 05:30
@notowen333
notowen333 merged commit ec5ef77 into strands-agents:main Nov 10, 2026
17 checks passed
rvkandury added a commit to rvkandury/box-public that referenced this pull request Nov 10, 2026
…agent.ingress]]

An agent that serves HTTP, such as a `BedrockAgentCoreApp` or a Strands agent
behind a web server, cannot be reached in a box. The agent's sandbox allows
only outbound connections, through the egress gateway, so nothing outside the
sandbox can connect to the port the agent listens on. On Linux the Namespace
backend refuses a listen port, and on macOS the Seatbelt profile refuses one.

Box binds a listener in its trusted process and relays each caller to the
agent's port. The agent's code does not change, and the agent gains no reach.

- `box.toml`: `[[agent.ingress]]` is a list of up to five entries, so an
  agent that serves HTTP, MCP, and A2A on separate ports gets one listener for
  each. Each entry holds `listen`, an IP address and port that Box binds, and
  `workload_port`, the port the agent listens on in its sandbox. Both are
  required. Box binds every `listen` before the agent starts, so a port in use
  refuses the run. Each entry needs its own `listen` port and its own
  `workload_port`, and on macOS no `listen` port may equal any entry's
  `workload_port`. A `[[tool.<name>.ingress]]` is refused; a tool's ingress is
  not built yet. Ingress is experimental: `[[agent.ingress]]` loads only when
  `[experimental-features]` sets `ingress = true`, and is refused otherwise.
- New crate `strands-box-ingress` (`ingress`): `Ingress`, `IngressConfig`,
  `Source`, `Workload`, and `IngressError`. `Ingress::start` accepts each
  caller, connects to the agent, and copies bytes both ways.
- Linux: the agent's port exists only in its network namespace. The sandbox's
  PID 1 keeps the socket pair that egress already uses, marked close-on-exec
  so the agent never holds it. For each caller the relay asks PID 1 for a
  socket, and PID 1 creates an unconnected TCP socket in the namespace and
  sends it back. The relay connects it to `127.0.0.1:workload_port` itself,
  without blocking, with a timeout for each caller. Every listener's relay
  shares the one channel (`Workload::in_namespace_ports`). PID 1 sends one
  ready byte when its connector starts, and Box starts no accept loop until
  that byte arrives, at most 60 s. The listeners are bound meanwhile, so an
  early caller waits in the listen queue. Without this wait, a caller that
  arrived while the sandbox was still being set up timed out, and the timeout
  closed the channel for every listener.
  A socket keeps the namespace it was created in, so the connection reaches
  the agent. PID 1 never blocks, so a stuck agent cannot stall other callers.
- macOS: Seatbelt renders `network-bind` and `network-inbound` on
  `(local tcp "localhost:<workload_port>")`, which allows that port on any
  address of the Mac, and the relay connects to `127.0.0.1:workload_port`
  (`Workload::loopback`). Before the agent starts, Box refuses to start when
  another process already listens on `workload_port`. A local process can
  also reach the agent's port directly; that is an accepted risk on macOS. A
  profile with no listen port is byte-identical.
- Both platforms: the relay connects to `127.0.0.1` only, and PID 1 creates
  IPv4 sockets only. A relay that also tried `::1` would let another local
  user on macOS take callers while the agent is down, and on Linux the sandbox
  creates no IPv6 socket. When nothing accepts, the relay closes the caller and
  prints one line until a caller is served again.
- Box raises its own soft open-file limit to the hard limit
  (`run::descriptor_limit::raise`), and the relay holds at most an eighth of
  that limit in callers at once, between 16 and 10,000
  (`IngressConfig::connection_limit`), split evenly across the listeners. An
  eighth leaves room for the egress descriptors that each caller's request
  also opens. After an accept error,
  the relay waits one second.
- Every child that Box starts gets the soft limit that Box started with
  (`run::descriptor_limit::restore_in_child`): each process that the
  trampoline starts (the agent, each tool, each contained MCP leaf) and each
  stdio MCP server. So only the box process holds the raised limit.
- The record stores the agent's ingress in `[agent]` only. A record that holds
  one is version 29, so an earlier build refuses the box. Versions 24 to 28
  came first on `main`; an ingress takes 29, the highest, even beside them. Every other record keeps its version and its bytes.
- Docs: `docs/design/decisions.md` says `listen` now renders on both
  backends, `docs/user/config.md` gains `[[agent.ingress]]`, `crates/box/README.md`
  lists the field, and `docs/user/native-filesystem-policy.md` names version
  29.

This changes frozen surfaces and needs owner approval: `[agent]` gains a field,
`[experimental-features]` gains `ingress`,
`Record` gains version 29, `containment` lowers `Network::Localhost.listen` on
both backends, and the new crate adds a public facade. No policy decision
covers a caller; `listen` decides who can reach the agent.

- `relay::tests::an_exhausted_descriptor_limit_does_not_spin`: a child process
  with a 64-descriptor limit and every descriptor taken, while the parent holds
  callers in the queue. The workload server runs in the parent, so the child's
  CPU time is the relay's alone. On Linux the relay without the backoff fails
  this test. macOS drops a connection when `accept` fails, so it cannot spin
  there.
- `run::descriptor_limit::tests::a_child_starts_with_the_limit_the_box_had_before_it_raised_it`:
  the child starts at 256 after Box raises its own limit. Without the restore,
  the child starts at 10,240 and the test fails.
- `supervise::tests::the_ingress_connection_limit_is_an_eighth_of_the_descriptor_limit`:
  1,024 gives 128 callers, 10,240 gives 1,280, and the floor and the ceiling
  hold.
- `inherited_handles_linux::the_workload_does_not_inherit_the_channel_to_pid_one`:
  the real trampoline with a listen port and the Unix socket channel attached;
  the workload holds no descriptor above stderr. With the `close_on_exec` call
  removed, the test fails and names the channel's descriptor.
- `relay::tests::a_caller_beyond_the_limit_waits_until_one_closes`: the
  workload serves each connection on its own thread and counts them. With the
  limit replaced by 10,000, the test fails, because a second connection
  reaches the workload.
- `netns::tests::a_connector_that_starts_late_serves_the_caller_that_arrived_first`:
  the real `serve_inbound` starts 6 s late, which is more than one answer may
  take, and a caller connects before it starts. That caller and the next one
  are served.
- `workload::linux::tests::the_workloads_wait_until_pid_one_is_ready`,
  `a_channel_that_closes_before_ready_is_refused`, and
  `a_first_byte_that_is_not_ready_is_refused`.
- `record::config::tests::an_agent_ingress_needs_the_ingress_switch` (omitted
  and `false` are refused, `true` loads) and
  `a_stored_ingress_needs_the_stored_switch`.
- `workload::linux::tests::*` (fake PID 1): the relay connects the socket PID 1
  sends; nothing listening is not ready and the channel stays open; an IPv6
  socket, a datagram socket, an undefined answer, and a closed channel are
  refused.
- `workload::macos::tests::a_listener_on_the_ipv6_loopback_alone_is_not_reached`.
- `record::config::tests::an_ingress_is_declared_on_the_agent` (two entries,
  in order; the single-table `[agent.ingress]` spelling is refused) and
  `an_agent_ingress_stores_a_version_no_earlier_build_reads`.
- `record::config::ingress::tests`: several entries on distinct ports are
  accepted; six entries, two entries on one `listen` port, and two entries on
  one `workload_port` are refused; on macOS, a `listen` port that is another
  entry's `workload_port` is refused, and on Linux each port mapped to itself
  is accepted.
- `workload::linux::tests::workloads_on_one_channel_each_reach_their_own_port`.
- `boundary::tests::the_ingress_reaches_the_agent_and_no_tool`: two entries
  give the agent's boundary both `workload_port`s, and a tool gets none.
- `record::config::tests::an_agent_ingress_beside_a_shared_program_stores_the_ingress_version`
  and `an_agent_ingress_beside_an_absolute_mcp_command_stores_the_ingress_version`.
- `profile_conformance::a_localhost_listen_port_renders_one_bind_and_one_inbound_rule`,
  `listen_ports_render_beside_the_composition_ports`, and
  `preflight_new_cells_macos::a_listen_port_is_the_only_port_the_workload_can_listen_on`
  (real kernel).
- On `main` (`9c0bf1d`). macOS: `strands-box` 1302 passed,
  `strands-box-containment` 330 passed, `strands-box-ingress` 7 passed. Linux,
  in Docker (`rust:1-bookworm`, `/proc` covers unmounted, run as uid 1000
  because `main` refuses a root launch that grants a directory write):
  `strands-box` 1324 passed, `strands-box-ingress` 16 passed. One macOS test,
  `tool_grammars::a_push_is_denied_until_a_test_exits_0_and_stays_allowed_after_a_restart`,
  fails the same way on `main` without this change.
- Rebased on `main` (`ec5ef77`), after strands-agents#377 took record version 28 for an
  absolute MCP command, so ingress moved to 29. Before that, on `f4180a0`, which
  fixes the seccomp entry count: Linux
  `strands-box-containment` 693 passed and `strands-box-ingress` 16 passed, 0
  failed in each, and the macOS `record::` and ingress tests pass.
  clippy shows no new warning in `box`, `containment`, or `ingress` on either
  platform, and fmt is clean.
- Live, macOS: a `BedrockAgentCoreApp` answers through the relay, 20 parallel
  calls return 200, a held `workload_port` refuses the run, and a stopped agent
  serves again when resumed. Live, Linux:
  an agent's server answers through PID 1's socket, its port is unreachable
  from the container, 20 parallel calls return 200, and a stopped agent serves
  again when resumed. An agent that binds `::1` on Linux fails to start,
  because the sandbox creates no IPv6 socket.
- Live, two listeners into one agent, on macOS and on Linux: each listener
  reaches its own server port, 20 parallel calls across both return 200, and on
  Linux neither agent port is reachable from the container. On macOS, crossed
  ports and six entries are refused at startup. On Linux, from this revision,
  the same box without `ingress = true` is refused with the experimental
  message.
- AgentCore Runtime, from the revision before the readiness wait and the
  switch, with one `[[agent.ingress]]` entry:
  the probe, a Bedrock prompt, a WebSocket session, and 10 parallel calls
  return 200. The runtime's open-file limit is 1,024, and its log shows that
  the relay holds up to 128 callers.
- AgentCore Runtime, from this revision, with `ingress = true` and two
  `[[agent.ingress]]` entries
  (`0.0.0.0:8080` to 8081, an HTTP app; `0.0.0.0:8000` to 8000, an MCP server
  in the same agent) and `allowedPorts` 8080 and 8000: `InvokeAgentRuntime`
  returns 200, and the session endpoint reaches both listeners. On port 8000,
  signed MCP `initialize`, `tools/list`, and `tools/call` succeed, the tools
  run in the agent's sandbox, 10 parallel calls return correct results, and a
  tool's fetch goes through the egress gateway, which permits example.com and
  refuses google.com. A Bedrock prompt and a WebSocket session on 8080 also
  pass.

Not run: the GitHub MCP call through an AgentCore Gateway, because the egress
`proxy` route is not on `main`.
hanaduy added a commit that referenced this pull request Nov 10, 2026
The intro now names what Monty refuses and the host's Python runs: -m,
-I, urllib.request and a project's own modules. It no longer offers
python3 -m pytest or python3 -m venv .venv, which don't work on macOS
with the example config.

The macOS limits are now one list with their cause: a venv's packages
aren't used, so a project's dependencies must be in the base Python, and
venv with pip fails because shutil.copy2 calls chflags, which a box
refuses in its write folders.

The record-version list gains replaces at version 29, after #377 took 28.
hanaduy added a commit that referenced this pull request Nov 10, 2026
The intro now names what Monty refuses and the host's Python runs: -m,
-I, urllib.request and a project's own modules. It no longer offers
python3 -m pytest or python3 -m venv .venv, which don't work on macOS
with the example config.

The macOS limits are now one list with their cause: a venv's packages
aren't used, so a project's dependencies must be in the base Python, and
venv with pip fails because shutil.copy2 calls chflags, which a box
refuses in its write folders.

The record-version list gains replaces at version 29, after #377 took 28.
hanaduy added a commit that referenced this pull request Nov 10, 2026
The intro now names what Monty refuses and the host's Python runs: -m,
-I, urllib.request and a project's own modules. It no longer offers
python3 -m pytest or python3 -m venv .venv, which don't work on macOS
with the example config.

The macOS limits are now one list with their cause: a venv's packages
aren't used, so a project's dependencies must be in the base Python, and
venv with pip fails because shutil.copy2 calls chflags, which a box
refuses in its write folders.

The record-version list gains replaces at version 29, after #377 took 28.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants