# Class BaseToolset`Abstract`

Base class for toolset.

A toolset is a collection of tools that can be used by an agent.

#### Hierarchy (View Summary)

- BaseToolset
  - MCPToolset

- Defined in tools/base_toolset.ts:43

## Constructors

### constructor

- new BaseToolset(
  toolFilter: string[] | ToolPredicate,
  prefix?: string,
  ): BaseToolset

  #### Parameters

  - toolFilter: string[] | ToolPredicate
  - `Optional` prefix: string

  #### Returns BaseToolset

  - Defined in tools/base_toolset.ts:46

## Properties

### `Readonly`[BASE_TOOLSET_SIGNATURE_SYMBOL]

"[BASE_TOOLSET_SIGNATURE_SYMBOL]": true

- Defined in tools/base_toolset.ts:44

### `Optional` `Readonly` prefix

prefix?: string

- Defined in tools/base_toolset.ts:48

### `Readonly` toolFilter

toolFilter: string[] | ToolPredicate

- Defined in tools/base_toolset.ts:47

## Methods

### `Abstract` close

- close(): Promise<void>

  Closes the toolset.

  NOTE: This method is invoked, for example, at the end of an agent server's lifecycle or when the toolset is no longer needed. Implementations should ensure that any open connections, files, or other managed resources are properly released to prevent leaks.

  #### Returns Promise<void>

  A Promise that resolves when the toolset is closed.

  - Defined in tools/base_toolset.ts:70

### `Abstract` getTools

- getTools(context?: ReadonlyContext): Promise<BaseTool[]>

  Returns the tools that should be exposed to LLM.

  #### Parameters

  - `Optional` context: ReadonlyContext

    Context used to filter tools available to the agent. If not defined, all tools in the toolset are returned.

  #### Returns Promise<BaseTool[]>

  A Promise that resolves to the list of tools.

  - Defined in tools/base_toolset.ts:58

### `Protected` isToolSelected

- isToolSelected(tool: BaseTool, context: ReadonlyContext): boolean

  Returns whether the tool should be exposed to LLM.

  #### Parameters

  - tool: BaseTool

    The tool to check.

  - context: ReadonlyContext

    Context used to filter tools available to the agent.

  #### Returns boolean

  Whether the tool should be exposed to LLM.

  - Defined in tools/base_toolset.ts:79

### processLlmRequest

- processLlmRequest(toolContext: Context, llmRequest: LlmRequest): Promise<void>

  Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.

  Use cases:

  - Instead of let each tool process the llm request, we can let the toolset process the llm request. e.g. ComputerUseToolset can add computer use tool to the llm request.

  #### Parameters

  - toolContext: Context

    The context of the tool.

  - llmRequest: LlmRequest

    The outgoing LLM request, mutable this method.

  #### Returns Promise<void>

  - Defined in tools/base_toolset.ts:107