include/entropic/mcp/servers/bash.h

← API

include/entropic/mcp/servers/bash.h

entropic::BashServer

Bash MCP server for shell command execution.

Inherits from entropic::MCPServerBase.

entropic::BashServer::BashServer(const std::filesystem::path &working_dir, const std::string &data_dir, int timeout=30)

Construct with working directory and data dir.

A thin MCPServerBase subclass: it builds its one tool, registers it, and overrides only get_permission_pattern and set_working_dir.

Parameters
  • working_dir — Default working directory for commands.
  • data_dir — Path to bundled data directory.
  • timeout — Per-command wall-clock limit in seconds (enforced since v2.13.0; mcp.bash.timeout_seconds, default 30).
  • timeout — Command timeout in seconds.

entropic::BashServer::~BashServer() override

Destructor.

std::string entropic::BashServer::get_permission_pattern(const std::string &tool_name, const std::string &args_json) const override

Permission pattern: "execute:{base_cmd} *".

Approval granularity matters here: keying on the base command means an operator's "always allow" applies to a command family rather than to every shell invocation.

Parameters
  • tool_name — Tool name.
  • args_json — Arguments JSON.
Returns
  • Permission pattern with base command.
  • "<tool>:<base command> *" — for python -m x, the pattern names python. Unparseable arguments degrade to a base command of "unknown" (logged), never a wildcard.

bool entropic::BashServer::set_working_dir(const std::string &path) override

Set working directory.

Set the working directory. Re-targets the server so a sandbox swap does not require reconstructing it.

Parameters
  • path — New working directory.
Returns
  • true on success.
  • true — the re-target always succeeds; the path itself is validated per call by is_safe_cwd.

const std::filesystem::path & entropic::BashServer::working_dir() const

Get the working directory.

Returns
  • Working directory path.
  • The directory commands default to when a call omits working_dir.

int entropic::BashServer::timeout() const

Get the enforced per-command timeout.

Get command timeout.

Returns
  • Timeout in seconds.
  • The enforced per-command timeout in seconds.