Custom Tools
Need your agents to reach an internal API or a service that has no ready-made connector? A custom tool turns any HTTP endpoint, or a small piece of JavaScript, into an action your agents can call during a conversation, under the same access rules and audit trail as every other tool.
What a custom tool is
You define three things:
- What it does: a name and a description. The agent reads the description to decide when to use the tool, so write it for the agent.
- What it needs: an input schema listing the parameters, their types and which are required.
- How it runs: one of three execution types.
| Type | Best for | How it works |
|---|---|---|
| HTTP request | REST APIs | MeetLoyd calls the endpoint server-side with the method, headers, query parameters and body you configured. |
| JavaScript | Calculations, validation, reshaping data | Your code runs in an isolated sandbox with no file system and no access to the platform. |
| Webhook | Logic that lives on your own server | MeetLoyd POSTs (or PUTs) the tool input to your endpoint and passes your JSON response back to the agent. |
How agents use custom tools
Once an agent may use the tool, it calls it naturally. Create a weather_lookup tool, and when someone asks "What is the weather in Paris?" the agent calls it and answers with the result. You do not teach the agent any syntax: the name, description and input schema are enough.
Creating a tool
The quickest way is to ask Loyd. Describe the endpoint, the parameters and the secret it needs, for example: "Create a custom tool called weather_lookup that calls GET https://api.weather.example/v1/current with a city and units, using my WEATHER_API_KEY secret." Loyd creates the tool with its input schema and execution settings, and you can then ask it to adjust them.
You can also create one yourself under Capabilities › Tools › Connections, in the Custom Tools tab, with Create Tool. Give it a name, a slug (lowercase letters, digits, _ and -), a description of at least 10 characters, a category and a type, then:
- for an HTTP request or Webhook tool, the method and the full
https://URL of the endpoint; - for a JavaScript tool, the code.
The tool is created only once these are filled in. Headers, query parameters, the input schema and allowed agents are set afterwards, by asking Loyd or through the API, which also lets you create and update tools directly.
HTTP request tools
| Setting | Description |
|---|---|
| Method | GET, POST, PUT, PATCH or DELETE |
| URL | The endpoint. Insert parameters with {{name}}, e.g. https://api.example.com/users/{{userId}} |
| Headers | Request headers. Insert a vault secret with {{SECRET_NAME}}, e.g. Authorization: Bearer {{WEATHER_API_KEY}} |
| Query parameters | Name/value pairs, with the same {{…}} placeholders |
| Body | Request body for POST, PUT and PATCH |
| Response mapping | A path to the part of the response the agent needs |
Example: weather lookup
- Name:
weather_lookup - Description: "Get the current weather for a city"
- Type: HTTP request, method GET
- URL:
https://api.weather.example/v1/current?q={{city}}&units={{units}} - Headers:
Authorization: Bearer {{WEATHER_API_KEY}} - Inputs:
city(string, required),units(metricorimperial)
Requests to private or internal network addresses are refused.
JavaScript tools
Your code receives:
| Name | Contents |
|---|---|
input | The parameters the agent passed |
secrets | The vault secrets the tool declares, read-only |
context | Who is calling: the agent, the user and your organisation |
The sandbox has no file system, no process access and no network access. Execution time is capped at 5 seconds by default (configurable up to 30 seconds), and memory is capped as well. Return a JSON-serialisable value; that value is what the agent receives.
Webhook tools
| Setting | Description |
|---|---|
| URL | Your endpoint |
| Method | POST or PUT |
| Headers | Custom headers, for example a shared secret your server checks, inserted from the vault with {{SECRET_NAME}} |
| Include context | Also send who is calling (agent, user, organisation, run) along with the input |
Your server receives a JSON body with the tool input and returns a JSON response. Protect the endpoint with a secret header that only MeetLoyd knows.
Secrets
Secrets live in Capabilities › Tools › Secrets. Names are uppercase with underscores (WEATHER_API_KEY). They are encrypted at rest (AES-256), never shown in logs or API responses, and inserted only when the tool runs.
Who may use a tool
- A tool can be restricted to a list of allowed agents.
- Capabilities › Tools › Policy can block whole categories of tools for the organisation.
- To require a human approval before sensitive actions, use your approval and governance policies. See Approvals.
Testing a tool
Before an agent relies on a tool, run it once with sample inputs (ask Loyd, or use the tool's test endpoint in the API) and check the output, the duration and any error.
Best practices
Write descriptions for the agent. "Look up a customer by email and return their profile and order history" works. "Get customer" does not.
Validate inputs. Use required, enum and types in the input schema so the agent cannot send malformed data.
Return only what is needed. Use response mapping so the agent gets the relevant fields, not the whole API response. It keeps answers accurate and costs down.
Start narrow. Allow a new tool for one agent, watch its calls in the audit trail, then widen.
Next: Explore Security Features for authentication and access control.