MCP Tools
Learn how to create and configure multi-step API tools in the MCP Kit.
MCP Tools enable Large Language Models (LLMs) to interact with external APIs. You define the API calls, and the LLM decides when and how to use them based on your instructions and the user’s request.
Creating a Tool
- Open the Create Modal: Click the “Create” button in the app sidebar or press ‘C’.
- Select “Tool”: In the modal, choose the “Tool” option.
- Name Your Tool: Enter a descriptive name (e.g., “Get Weather Forecast”, “Search Products”) and click “Create”.
This takes you to the Tool Editor page.
Configuring Tool Basics
First, define the essential information about your tool:
- Name: The display name shown in the UI.
- Slug: A unique identifier used internally (auto-generated from the name).
- Description: Clearly explain what the tool does. This helps the LLM understand its purpose (e.g., “Fetches the current weather for a given city”).
Defining Tool Inputs (Parameters)
Parameters are the specific pieces of information the LLM needs to gather from the conversation before it can run your tool.
- Example: A weather tool needs a
location
parameter. A product search tool might need aquery
parameter.
- Navigate to the “Parameters” section.
- Click “Add Parameter”.
- Configure each parameter:
- Name: Give it a short, descriptive name using only letters, numbers, and underscores (e.g.,
location
,search_query
,user_id
). - Type: Choose the data type the LLM should provide:
string
: For text (e.g., a city name, a search term).number
: For numerical values (e.g., an item ID, a quantity).boolean
: For true/false values.
- Required: Check this box if the LLM must have this information to run the tool.
- Description: Explain what this specific piece of information is for (e.g., “The city and state for the weather forecast”). This helps the LLM ask the right clarifying questions if needed.
- Name: Give it a short, descriptive name using only letters, numbers, and underscores (e.g.,
Defining Tool Steps (API Requests)
Most tools involve making at least one API call. Each API call is defined as a “Step”.
-
Add a Step: In the flow builder area, click the “Add Step” button (look for the
+
icon). -
Configure the Step: Select the step to open its configuration panel.
-
Step Name: A label for the step (e.g., “Fetch Forecast Data”).
-
Method: Choose the HTTP method required by the API (e.g.,
GET
,POST
). -
URL: Enter the API endpoint URL.
- Using Parameters in URLs: To insert a parameter value into the URL, use double curly braces and the
param.
prefix:https://api.weather.com/forecast?city={{param.location}}
. - Using Environment Variables: You can also securely insert sensitive values (like API keys stored elsewhere) using the
env.
prefix:https://api.service.com/data?apiKey={{env.SERVICE_API_KEY}}
. (Environment variables are configured on the tools page).
- Using Parameters in URLs: To insert a parameter value into the URL, use double curly braces and the
-
Configuring Step Details (Auth, Headers, Body)
APIs often require more than just a URL.
- Authentication:
- Select the authentication method the API uses (e.g.,
Bearer Token
,Basic Auth
). - Enter the required credentials. You can use
{{param...}}
and{{env...}}
placeholders here (e.g.,{{env.MY_API_KEY}}
for a Bearer Token).
- Select the authentication method the API uses (e.g.,
- Headers & Query Parameters:
- Add any required HTTP headers (e.g.,
Content-Type
,Accept
) or additional URL query parameters. - Values can use
{{param...}}
and{{env...}}
placeholders.
- Add any required HTTP headers (e.g.,
- Request Body (for POST, PUT, etc.):
- Body Type: Choose the format the API expects (e.g.,
JSON
,Form Data
). - JSON Body Configuration:
- Write the JSON structure the API needs.
- Use
{{param...}}
and{{env...}}
placeholders for dynamic values. - Placeholder Quoting is Crucial:
- If inserting a
string
parameter, wrap the placeholder in double quotes:"message": "{{param.user_message}}"
- If inserting a
number
orboolean
parameter, do not use quotes:"itemId": {{param.product_id}}, "notify": {{param.send_notification}}
- If inserting a
- Complex JSON: If the API needs nested objects or arrays, build the structure directly in the JSON editor. Use placeholders only for the individual primitive values (
string
,number
,boolean
) provided by your parameters.- Example: Sending a structured message
(Here,
message_title
andrecipient_id
would be defined asstring
parameters).
- Example: Sending a structured message
- Body Type: Choose the format the API expects (e.g.,
Conditional Logic in JSON Bodies (Advanced)
Sometimes, you only want to include a field in a JSON request body if a specific optional input parameter (or multiple parameters) was actually provided by the LLM.
You can achieve this using a special _if
structure within the value of the field you want to make conditional.
- Use Case: Include an optional
discountCode
field only if thediscount_code
parameter was supplied, and anoptionalNumber
field only ifoptional_number
was supplied.
How it works:
- The entire field (e.g.,
discountCode
,optionalNumber
) will only be included in the final JSON sent to the API if the conditions within its_if
block are met. _if
: This special key indicates conditional logic for the parent field.present
: An array containing one or more strings. Each string must be the name of a tool input parameter (prefixed withtoolInput.
) that must be present (i.e., provided by the LLM) for the condition to be true. All parameters listed must be present.then
: Specifies the value to assign to the parent field (e.g.,discountCode
) if thepresent
condition is met. Remember to use the correct placeholder syntax ({{param...}}
) and quoting: Wrap string placeholders in double quotes ("{{param...}}"
) and leave number/boolean placeholders unquoted ({{param...}}
).
If any parameter listed in the present
array is not provided during the tool call, the entire parent field (e.g., "discountCode": { ... }
) will be omitted from the request body.
Working with Multiple Steps (Advanced)
Tools can perform sequences of API calls.
- Adding More Steps: Simply add more steps to the flow builder.
- Using Previous Step Data: In a later step’s configuration (URL, Headers, Body, etc.), you can reference data from a previous step’s output using
{{steps[INDEX].body.fieldName}}
or{{steps[INDEX].headers.headerName}}
.INDEX
is the 0-based number of the previous step (e.g.,{{steps[0].body.userId}}
uses theuserId
field from the body of the first step (index 0)). The last step’s output is automatically considered the final result of the tool.
Saving Changes
Click the “Save” button to save your tool configuration. Make sure all required fields are filled correctly.