---
schema_version: "1"
id: 50403e1045305c4112e63cde4b0c56d462d413258c7a7f359d259fd73e73595f
title: Configuring Tools Operations
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mulesoft-ai-chain-connector/latest/configuring-tools-operations.md
canonical_url: https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/configuring-tools-operations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: dec38d1292ff87c0a51548fdcee4aa68ea522d0984d6ad7529c6ff460a13c687
description: MuleSoft Documentation Site
release: "2.0"
latest: true
---
---
product: MuleSoft AI Chain Connector
version: 2.0
is-latest-version: true
---

# Configuring Tools Operations

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## Before You Begin

To use Tools operations, you must create a `tools.config.json` file that includes all the necessary
API information for the operation to execute APIs successfully, for example:

```json
[
  {
    "action": "Execute POST requests for API endpoints.",
    "url": "http://check-inventory-material.cloudhub.io/mmbe",
    "name": "Check Inventory",
    "method": "POST",
    "headers": "Basic XXX",
    "example-payload": "{\n \"materialNo\": \"paramValue\"}",
    "query": [
      "Check inventory in SAP",
      "Check Stock Overview",
      "Show product availability for MULETEST0",
      "Check the inventory for MULETEST0",
      "Check Stock for 400-110"
    ],
    "description": "Check inventory details for material in SAP by providing the materialNo as input for paramValue. Please use the materialNo and not materialNumber. This action applies whenever users' intent is 'Stock overview', 'product availability', 'Inventory', 'available stock'. Use the headers to perform the request."
  },
  {
    "action": "Execute GET requests for API endpoints.",
    "url": "https://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/612eb739-4266-4f4c-bf2f-29953c153d80/accounts-api/1.0.1/m/accounts",
    "name": "Show Accounts",
    "method": "GET",
    "headers": "",
    "example-payload": "{}",
    "query": ["Get all accounts", "Show all accounts from CRM"],
    "description": "Get all accounts from a CRM. This action applies whenever users' intent is 'CRM accounts', 'customers', 'customer accounts', 'accounts'."
  },
  {
    "action": "Execute GET requests for API endpoints.",
    "url": "https://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/7b99cead-a984-497b-9e6c-c16a3b4dcb76/employee-api/1.0.1/m/employees",
    "name": "Show Employees",
    "method": "GET",
    "headers": "",
    "example-payload": "{}",
    "query": [
      "Get all employee information",
      "Show employees for the country Switzerland",
      "How many employees do we have",
      "Show a list of all employees"
    ],
    "description": "Get all information about employees. This action applies whenever users' intent is 'employees', 'workforce'."
  }
]
```

Each object in the tools array represents a tool that the autonomous agent can use, so it is
important to describe each field as accurately as possible.

- `action`

  This field supports the following options:

  - `Execute GET` requests for API endpoints.

  - `Execute POST` requests for API endpoints.

- `url`

  The complete URL to the endpoint, including the resource path.

- `name`

  The name of the action in natural language.

- `method`

  The HTTP method for the endpoint. Only POST and GET are supported.

- `headers`

  The HTTP headers required for authorization to the endpoint. Only Basic Auth is supported.

- `example-payload`

  The example payload in JSON format.

- `query`

  Example queries a user might use to invoke this action.

- `description`

  A detailed description of how to use the tool. The description should be comprehensive enough for
  the LLM to understand its purpose and usage.

Ensure that the file path to the `tools.config.json` is accessible to the application at runtime.

## Configure the Tools Use AI Service Operation

The **Tools use AI service** operation is useful if you want to create autonomous agents that can
use external tools whenever a prompt can’t be answered directly by the AI model. This operation
supports tool use with Ollama chat models.

To configure the **Tools use AI service** operation:

1.  Select the operation on the Anypoint Code Builder or Studio canvas.

2.  In the **General** properties tab for the operation, enter these values:

    - **Data**

      The prompt to send to the LLM.

    - **Tool Config**

      The full file path to the `tools.config.json` file. Ensure the file path is accessible.

You can also use a DataWeave expression for this field, for example:

```dataweave
mule.home ++ "/apps/" ++ app.name ++ "/tools.config.json"
```

This is the XML configuration for this operation:

```xml
<ms-aichain:tools-use-ai-service
  doc:name="Tools use AI service"
  doc:id="910f744f-e359-4e39-afd1-3fb932c5fc53"
  config-ref="MAC_AI_Llm_configuration"
  data="#[payload.prompt]"
  toolConfig='#[mule.home ++ "/apps/" ++ app.name ++ "/tools.config.json"]'
/>
```

### Output Configuration

This operation responds with a JSON payload that contains the main LLM response. Additionally,
attributes such as token usage and tool usage (boolean value) are included as part of the
attributes, but not within the main payload.

This is an example response of the JSON payload if the prompt is "What is the capital of
Switzerland?":

```json
{
  "response": "The capital of Switzerland is Bern."
}
```

If the prompt requires accessing external data through a tool, for example, "Show me the latest
account created in Salesforce", the AI model uses the configured tool to fetch the information,
resulting in:

```json
{
  "response": "The latest account created in Salesforce is:\n\n- **Name:** MuleTalks\n- **Id:** 0010600002JKf42AAD\n- **Created Date:** 2024-07-10T20:21:36.000Z\n\nIf you have any further questions or need additional assistance, feel free to ask!"
}
```

Along with the JSON payload, the operation returns attributes, which include information about token
and tool usage, for example:

```json
{
    "tokenUsage": { (1)
        "outputCount": 9,
        "totalCount": 18,
        "inputCount": 9
    },
    "additionalAttributes": { (2)
        "toolsUsed": "true"
    }
}
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>tokenUsage: Provides information on the token usage for the operation:<div><ul><li><p><code>outputCount</code></p><div><p>Number of tokens generated in the response</p></div></li><li><p><code>totalCount</code></p><div><p>Total number of tokens processed for the entire operation, including input and output</p></div></li><li><p><code>inputCount</code></p><div><p>Number of tokens processed from the input query or document</p></div></li></ul></div></td></tr><tr><td><i data-value="2"></i><b>2</b></td><td><code>additionalAttributes</code> includes the boolean value for <code>toolsUsed</code>:<div><ul><li><p><code>true</code></p><div><p>External tools, such as APIs or integrations, were used to gather or generate the response.</p></div></li><li><p><code>false</code></p><div><p>No external tools were used, and the response was based on internal knowledge only.</p></div></li></ul></div></td></tr></tbody></table>

## See Also

- [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb)

- [Using Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio)

- [MuleSoft AI Chain Connector Overview](https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/)

- [MuleSoft AI Chain Connector Reference](https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/mulesoft-ai-chain-connector-reference)

- [Salesforce Help](https://help.salesforce.com)
