Skip to main content

SessionBuilder

Struct SessionBuilder 

Source
pub struct SessionBuilder<'a> { /* private fields */ }
Expand description

Builder for creating sessions with fluent API

§Example

use composio_sdk::ComposioClient;

let client = ComposioClient::builder()
    .api_key("your-api-key")
    .build()?;

let session = client
    .create_session("user_123")
    .toolkits(vec!["github", "gmail"])
    .manage_connections(true)
    .send()
    .await?;

Implementations§

Source§

impl<'a> SessionBuilder<'a>

Source

pub fn new(client: &'a ComposioClient, user_id: String) -> Self

Create a new session builder

The builder inherits the toolkit version configuration from the client. You can override this configuration using the .toolkit_versions() method.

§Arguments
  • client - Reference to the ComposioClient
  • user_id - User identifier for session isolation
Source

pub fn toolkits(self, toolkits: Vec<impl Into<String>>) -> Self

Enable specific toolkits for this session

By default, all toolkits are accessible via COMPOSIO_SEARCH_TOOLS. Use this method to restrict the session to specific toolkits.

§Arguments
  • toolkits - Vector of toolkit slugs to enable (e.g., “github”, “gmail”)
§Example
let session = client
    .create_session("user_123")
    .toolkits(vec!["github", "gmail", "slack"])
    .send()
    .await?;
Source

pub fn disable_toolkits(self, toolkits: Vec<impl Into<String>>) -> Self

Disable specific toolkits for this session

Use this to exclude certain toolkits while keeping all others accessible.

§Arguments
  • toolkits - Vector of toolkit slugs to disable
§Example
let session = client
    .create_session("user_123")
    .disable_toolkits(vec!["exa", "firecrawl"])
    .send()
    .await?;
Source

pub fn auth_config( self, toolkit: impl Into<String>, auth_config_id: impl Into<String>, ) -> Self

Override the default auth config for a specific toolkit

Use this to specify a custom auth configuration (e.g., your own OAuth app) instead of Composio’s managed authentication.

§Arguments
  • toolkit - Toolkit slug (e.g., “github”)
  • auth_config_id - Auth config ID (e.g., “ac_your_config”)
§Example
let session = client
    .create_session("user_123")
    .auth_config("github", "ac_custom_github_oauth")
    .send()
    .await?;
Source

pub fn connected_account( self, toolkit: impl Into<String>, connected_account_id: impl Into<String>, ) -> Self

Select a specific connected account for a toolkit

Use this when a user has multiple connected accounts for the same toolkit (e.g., work and personal email) and you want to specify which one to use.

§Arguments
  • toolkit - Toolkit slug (e.g., “gmail”)
  • connected_account_id - Connected account ID (e.g., “ca_work_gmail”)
§Example
let session = client
    .create_session("user_123")
    .connected_account("gmail", "ca_work_gmail")
    .send()
    .await?;
Source

pub fn manage_connections(self, enabled: bool) -> Self

Enable or disable automatic connection management

When enabled (default), the agent will automatically prompt users with Connect Links during chat when authentication is needed.

§Arguments
  • enabled - Whether to enable automatic connection management
§Example
// Disable in-chat authentication (use manual auth flow instead)
let session = client
    .create_session("user_123")
    .manage_connections(false)
    .send()
    .await?;
Source

pub fn tools( self, toolkit: impl Into<String>, tools: Vec<impl Into<String>>, ) -> Self

Configure per-toolkit tool filtering

Use this to enable or disable specific tools within a toolkit.

§Arguments
  • toolkit - Toolkit slug (e.g., “github”)
  • tools - Vector of tool slugs to enable
§Example
let session = client
    .create_session("user_123")
    .tools("github", vec!["GITHUB_CREATE_ISSUE", "GITHUB_GET_REPOS"])
    .send()
    .await?;
Source

pub fn tags( self, enabled: Option<Vec<TagType>>, disabled: Option<Vec<TagType>>, ) -> Self

Configure tag-based tool filtering

Tags are MCP annotation hints that categorize tools by behavior:

  • readOnlyHint: Read-only tools (safe, no modifications)
  • destructiveHint: Tools that modify or delete data
  • idempotentHint: Tools that can be safely retried
  • openWorldHint: Tools that interact with external world
§Arguments
  • enabled - Tags that tools must have (at least one)
  • disabled - Tags that tools must NOT have (any)
§Example
// Only allow read-only tools, exclude destructive ones
let session = client
    .create_session("user_123")
    .tags(
        Some(vec![TagType::ReadOnlyHint]),
        Some(vec![TagType::DestructiveHint])
    )
    .send()
    .await?;
Source

pub fn workbench( self, proxy_execution: Option<bool>, auto_offload_threshold: Option<u32>, ) -> Self

Configure workbench settings

The workbench is a persistent Python sandbox for complex operations.

§Arguments
  • proxy_execution - Whether to enable proxy execution
  • auto_offload_threshold - Threshold for automatic offloading
§Example
let session = client
    .create_session("user_123")
    .workbench(Some(true), Some(1000))
    .send()
    .await?;
Source

pub fn toolkit_versions(self, versions: ToolkitVersionParam) -> Self

Override toolkit version configuration for this session

By default, sessions inherit the toolkit version configuration from the client. Use this method to override the configuration for a specific session.

§Arguments
  • versions - Toolkit version configuration
§Example
// Override client config for this session
let mut versions = HashMap::new();
versions.insert("github".to_string(), ToolkitVersion::Specific("20250906_01".to_string()));

let session = client
    .create_session("user_123")
    .toolkit_versions(ToolkitVersionParam::Versions(versions))
    .send()
    .await?;
Source

pub fn experimental(self, user_timezone: Option<String>) -> Self

Configure experimental features for this session

Note: These features are experimental and may be modified or removed in future versions.

§Arguments
  • user_timezone - IANA timezone identifier (e.g., “America/New_York”, “Europe/London”) for timezone-aware assistive prompts
§Example
let session = client
    .create_session("user_123")
    .experimental(Some("America/New_York".to_string()))
    .send()
    .await?;
Source

pub async fn send(self) -> Result<Session, ComposioError>

Send the session creation request

This consumes the builder and creates the session on the Composio API.

§Errors

Returns an error if:

  • The API request fails
  • The response cannot be parsed
  • Authentication is invalid
§Example
let session = client
    .create_session("user_123")
    .toolkits(vec!["github"])
    .send()
    .await?;

println!("Session ID: {}", session.session_id());
println!("MCP URL: {}", session.mcp_url());

Auto Trait Implementations§

§

impl<'a> Freeze for SessionBuilder<'a>

§

impl<'a> !RefUnwindSafe for SessionBuilder<'a>

§

impl<'a> Send for SessionBuilder<'a>

§

impl<'a> Sync for SessionBuilder<'a>

§

impl<'a> Unpin for SessionBuilder<'a>

§

impl<'a> UnsafeUnpin for SessionBuilder<'a>

§

impl<'a> !UnwindSafe for SessionBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more