> For the complete documentation index, see [llms.txt](https://vibemx.gitbook.io/neuronai-studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vibemx.gitbook.io/neuronai-studio/tools/builder-tools.md).

# Builder Tools

Builder tools let you prototype custom tool logic with a PHP invoke body and JSON input schema in the Studio UI — then export to a typed Neuron `Tool` class for execution.

> **Security:** Builder tools are for **local prototyping**. On export, Studio writes executable PHP under `export_path`. Keep `allow_builder_tools` and CodeGen export **off** outside `local`, and prefer [Make Tool CLI](/neuronai-studio/tools/make-tool-cli.md) / scanned classes or [Webhook Tools](/neuronai-studio/tools/webhook-tools.md) in production. See [Security & Access](/neuronai-studio/workflows/security-and-access.md#builder-tools).

## Create a builder tool

Requires `allow_builder_tools` (defaults to `true` only when `APP_ENV=local`).

1. Navigate to **Tools** → **Create Tool**
2. Define name, description, and input schema (JSON Schema)
3. Write the PHP invoke body
4. Save — with CodeGen export enabled, Studio also writes the class and sets `class_path`
5. Test by binding to an agent

> **Screenshot pending:** Tool builder with PHP invoke preview.
>
> Asset path: `docs/assets/screenshots/tools-builder.png` Capture: Tool edit page with builder form — dark theme, 1440×900

## How it works

```mermaid
flowchart LR
    Agent[Agent calls tool] --> Runtime[ToolResolver]
    Runtime --> Class[Instantiate exported class_path]
    Class --> Result[Return structured result]
```

1. The invoke body is stored in `tool_definitions.config.invoke_body` (prefixed table, e.g. `neuronai_studio_tool_definitions`) for editing and preview.
2. **Export** (CodeGen) generates a PHP class under `export_path/Tools/` and stores `config.class_path`.
3. At runtime, `ToolResolver` instantiates that class — it does **not** `eval()` the database body.

Without a `class_path` (export never ran or CodeGen export is off), the tool **cannot** execute. Export before binding the tool in production-like environments.

## Input schema

Define parameters as JSON Schema. Example:

```json
{
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "City name for weather lookup"
    }
  },
  "required": ["city"]
}
```

The LLM uses this schema to construct valid tool call arguments.

## Invoke body

The invoke body receives `$input` (decoded arguments) and should return a string or array:

```php
$city = $input['city'] ?? 'unknown';
return "Weather in {$city}: sunny, 22°C";
```

A live PHP preview in the editor helps validate syntax before saving (requires CodeGen preview).

## Production path

For production deployments:

1. Keep `NEURONAI_STUDIO_ALLOW_BUILDER_TOOLS=false` (default outside `local`)
2. Export the tool to a typed PHP class (**Export PHP** / Save & Export), or create classes with [Make Tool CLI](/neuronai-studio/tools/make-tool-cli.md)
3. Prefer webhook tools when the logic lives in an external HTTP API

See [Registry & Codegen](/neuronai-studio/tools/registry-and-codegen.md), [Export & Production](/neuronai-studio/workflows/export-and-production.md), and [Security & Access](/neuronai-studio/workflows/security-and-access.md#builder-tools).

## Next steps

* [Webhook Tools](/neuronai-studio/tools/webhook-tools.md) — HTTP-based alternatives
* [Creating Agents](/neuronai-studio/agents/creating-agents.md) — bind tools to agents


---

# 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://vibemx.gitbook.io/neuronai-studio/tools/builder-tools.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.
