diff --git a/crates/goose-cli/src/commands/session.rs b/crates/goose-cli/src/commands/session.rs index bb40be017..6c1e77c52 100644 --- a/crates/goose-cli/src/commands/session.rs +++ b/crates/goose-cli/src/commands/session.rs @@ -15,8 +15,8 @@ use mcp_client::transport::Error as McpClientError; pub async fn build_session( name: Option, resume: bool, - extension: Option, - builtin: Option, + extensions: Vec, + builtins: Vec, ) -> Session<'static> { // Load config and get provider/model let config = Config::global(); @@ -64,8 +64,8 @@ pub async fn build_session( } } - // Add extension if provided - if let Some(extension_str) = extension { + // Add extensions if provided + for extension_str in extensions { let mut parts: Vec<&str> = extension_str.split_whitespace().collect(); let mut envs = std::collections::HashMap::new(); @@ -104,8 +104,8 @@ pub async fn build_session( }); } - // Add builtin extension if provided - if let Some(name) = builtin { + // Add builtin extensions + for name in builtins { let config = ExtensionConfig::Builtin { name }; agent.add_extension(config).await.unwrap_or_else(|e| { eprintln!("Failed to start builtin extension: {}", e); diff --git a/crates/goose-cli/src/main.rs b/crates/goose-cli/src/main.rs index 84f0a9cac..941044961 100644 --- a/crates/goose-cli/src/main.rs +++ b/crates/goose-cli/src/main.rs @@ -62,23 +62,25 @@ enum Command { )] resume: bool, - /// Add a stdio extension with environment variables and command + /// Add stdio extensions with environment variables and commands #[arg( long = "with-extension", value_name = "COMMAND", - help = "Add a stdio extension (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')", - long_help = "Add a stdio extension from a full command with environment variables. Format: 'ENV1=val1 ENV2=val2 command args...'" + help = "Add stdio extensions (can be specified multiple times)", + long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'", + action = clap::ArgAction::Append )] - extension: Option, + extension: Vec, - /// Add a builtin extension by name + /// Add builtin extensions by name #[arg( long = "with-builtin", value_name = "NAME", - help = "Add a builtin extension by name (e.g., 'developer')", - long_help = "Add a builtin extension that is bundled with goose by specifying its name" + help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')", + long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated", + value_delimiter = ',' )] - builtin: Option, + builtin: Vec, }, /// Execute commands from an instruction file @@ -125,23 +127,25 @@ enum Command { )] resume: bool, - /// Add a stdio extension with environment variables and command + /// Add stdio extensions with environment variables and commands #[arg( long = "with-extension", value_name = "COMMAND", - help = "Add a stdio extension with environment variables and command (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')", - long_help = "Add a stdio extension with environment variables and command. Format: 'ENV1=val1 ENV2=val2 command args...'" + help = "Add stdio extensions (can be specified multiple times)", + long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'", + action = clap::ArgAction::Append )] - extension: Option, + extension: Vec, - /// Add a builtin extension by name + /// Add builtin extensions by name #[arg( long = "with-builtin", value_name = "NAME", - help = "Add a builtin extension by name (e.g., 'developer')", - long_help = "Add a builtin extension that is compiled into goose by specifying its name" + help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')", + long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated", + value_delimiter = ',' )] - builtin: Option, + builtin: Vec, }, /// List available agent versions diff --git a/documentation/docs/getting-started/using-extensions.md b/documentation/docs/getting-started/using-extensions.md index a022a87ff..e352329cd 100644 --- a/documentation/docs/getting-started/using-extensions.md +++ b/documentation/docs/getting-started/using-extensions.md @@ -251,7 +251,7 @@ You can remove installed extensions. You can start a tailored goose session with specific extensions directly from the CLI. To do this, run the following command: ```bash -goose session --with-extension "{extension command}" +goose session --with-extension "{extension command}" --with-extension "{antoher extension command}" ``` :::info @@ -261,6 +261,14 @@ goose session --with-extension "VAR=value command arg1 arg2" ``` ::: +:::tip +You can also start a session with built-in extensions by using the `--with-builtin` flag. +```bash +goose session --with-builtin "developer,memory" +goose session --with-builtin developer --with-builtin memory +``` +::: + ## Developing Extensions Goose extensions are implemented with MCP, a standard protocol that allows AI models and agents to securely connect with local or remote resources. Learn how to build your own [extension as an MCP server](https://modelcontextprotocol.io/quickstart/server).