> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
