> For the complete documentation index, see [llms.txt](https://docs.servoy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.servoy.com/reference/servoyextensions/server-plugins/ai/toolbuilder.md).

# ToolBuilder

## Overview

ToolBuilder is a builder class for constructing AI tool specifications with parameter definitions.

This class allows dynamic creation of tool specifications for AI agents, supporting string, number, and boolean parameters. It is designed to be used in scripting environments and integrates with Servoy's documentation system.

Usage example:

```js
ToolBuilder builder = new ToolBuilder(chatBuilder, toolFunction, "toolName", "Tool description");
builder.addStringParameter("param1", "Description", true)
       .addNumberParameter("param2", "Description", false)
       .build();
```

## Methods Summarized

| Type                                                                        | Name                                                                                               | Summary                                                        |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) | [addBooleanParameter(name, description, required)](#addbooleanparameter-name-description-required) | Adds a boolean parameter to the tool specification.            |
| [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) | [addNumberParameter(name, description, required)](#addnumberparameter-name-description-required)   | Adds a number parameter to the tool specification.             |
| [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) | [addStringParameter(name, description, required)](#addstringparameter-name-description-required)   | Adds a string parameter to the tool specification.             |
| void                                                                        | [build()](#build)                                                                                  | Finalizes the tool specification and returns the chat builder. |

## Methods Detailed

### addBooleanParameter(name, description, required)

Adds a boolean parameter to the tool specification.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the parameter name
* [String](/reference/servoycore/dev-api/js-lib/string.md) **description** the parameter description
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **required** whether the parameter is required

**Returns:** [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) this ToolBuilder instance for chaining

### addNumberParameter(name, description, required)

Adds a number parameter to the tool specification.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the parameter name
* [String](/reference/servoycore/dev-api/js-lib/string.md) **description** the parameter description
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **required** whether the parameter is required

**Returns:** [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) this ToolBuilder instance for chaining

### addStringParameter(name, description, required)

Adds a string parameter to the tool specification.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the parameter name
* [String](/reference/servoycore/dev-api/js-lib/string.md) **description** the parameter description
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **required** whether the parameter is required

**Returns:** [ToolBuilder](/reference/servoyextensions/server-plugins/ai/toolbuilder.md) this ToolBuilder instance for chaining

### build()

Finalizes the tool specification and returns the chat builder.

**Returns:** voidthe chat builder instance

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/ai/toolbuilder.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
