Background
Currently, the goose-mm-bridge manages user isolation by mapping Mattermost users to Linux accounts. Each user's Goose session relies on a config.yaml located in their home directory (~/.config/goose/config.yaml). This approach has several drawbacks:
- Security: Sensitive credentials (like API keys) are exposed in plain-text files across multiple user directories.
- Maintenance: Adding new tools or changing models requires manual updates to every user's configuration.
- Provisioning Complexity: Setting up a new user requires pre-configuring their home directory.
Proposed Change
Control the entire Goose configuration via environment variables managed centrally by the bridge process.
1. Environment Variable Overrides
Goose supports provider-specific environment variables (e.g., OPENAI_API_KEY, GOOSE_PROVIDER, GOOSE_MODEL). The bridge will be updated to accept these settings in its own .env file and pass them down to the goose acp subprocess.
2. Secure Subprocess Injection
Since sudo typically clears environment variables for security, the bridge will use /usr/bin/env to explicitly inject configuration into the subprocess:
sudo -u <user> /usr/bin/env GOOSE_PROVIDER=... OPENAI_API_KEY=... goose acp
3. Centralized Extension Management
- Built-ins: Use the
--with-builtin <name> flag when starting goose acp to enable tools like developer or summarize for all users.
- MCP Servers: Inject custom MCP servers (like the internal Mattermost bridge) dynamically during the
session/new JSON-RPC handshake. This allows the bridge to provide global tools to every user without local configuration.
4. Zero-Conf Home Directory
Instead of a config.yaml, Goose will be configured entirely via environment variables. The process will still run with the user's actual HOME directory, ensuring session databases and logs are owned by the user, but secrets never touch the disk. This eliminates the need for manual filesystem setup in user homes while maintaining strict isolation.
Implementation Plan
- Update
src/config.py: Add support for GOOSE_PROVIDER, GOOSE_MODEL, GOOSE_API_KEY, GOOSE_BUILTIN_EXTENSIONS, and GLOBAL_MCP_SERVERS.
- Refactor
src/goose_acp_client.py:
- Construct a secure environment dictionary from bridge settings.
- Modify
_start to use the /usr/bin/env injection pattern and --with-builtin flags.
- Update
create_session to dynamically merge global MCP servers.
- Simplify
setup_user.sh: Remove config.yaml generation. Focus only on user creation and sudoers entries.
- Validation: Ensure new users are ready for Goose sessions immediately after OS-level setup without manual configuration.
This plan was generated after research into Goose environment behavior and ACP protocol capabilities.
Background
Currently, the
goose-mm-bridgemanages user isolation by mapping Mattermost users to Linux accounts. Each user's Goose session relies on aconfig.yamllocated in their home directory (~/.config/goose/config.yaml). This approach has several drawbacks:Proposed Change
Control the entire Goose configuration via environment variables managed centrally by the bridge process.
1. Environment Variable Overrides
Goose supports provider-specific environment variables (e.g.,
OPENAI_API_KEY,GOOSE_PROVIDER,GOOSE_MODEL). The bridge will be updated to accept these settings in its own.envfile and pass them down to thegoose acpsubprocess.2. Secure Subprocess Injection
Since
sudotypically clears environment variables for security, the bridge will use/usr/bin/envto explicitly inject configuration into the subprocess:3. Centralized Extension Management
--with-builtin <name>flag when startinggoose acpto enable tools likedeveloperorsummarizefor all users.session/newJSON-RPC handshake. This allows the bridge to provide global tools to every user without local configuration.4. Zero-Conf Home Directory
Instead of a
config.yaml, Goose will be configured entirely via environment variables. The process will still run with the user's actualHOMEdirectory, ensuring session databases and logs are owned by the user, but secrets never touch the disk. This eliminates the need for manual filesystem setup in user homes while maintaining strict isolation.Implementation Plan
src/config.py: Add support forGOOSE_PROVIDER,GOOSE_MODEL,GOOSE_API_KEY,GOOSE_BUILTIN_EXTENSIONS, andGLOBAL_MCP_SERVERS.src/goose_acp_client.py:_startto use the/usr/bin/envinjection pattern and--with-builtinflags.create_sessionto dynamically merge global MCP servers.setup_user.sh: Removeconfig.yamlgeneration. Focus only on user creation andsudoersentries.This plan was generated after research into Goose environment behavior and ACP protocol capabilities.