Custom Tools
Tool Parameters
Define inputs and outputs for your custom tools
1 min read
Documentation
Parameters define what information your tool needs and what it returns. Well-defined parameters help the AI use your tools correctly.
Defining Parameters
Each parameter has:
| Property | Description |
|---|---|
| Name | Parameter identifier (no spaces) |
| Type | Data type (string, number, boolean, etc.) |
| Required | Whether it must be provided |
| Description | What the parameter is for |
| Default | Default value if not provided |
Parameter Types
String
Text values:
Name: city
Type: string
Required: true
Description: "City name to look up"Number
Numeric values:
Name: limit
Type: number
Required: false
Default: 10
Description: "Maximum results to return"Boolean
True/false:
Name: include_details
Type: boolean
Required: false
Default: false
Description: "Include extra details in response"Array
List of values:
Name: tags
Type: array
Items: string
Description: "List of tags to filter by"Object
Structured data:
Name: filters
Type: object
Properties:
status: string
priority: number
Description: "Filter criteria"Writing Good Descriptions
Descriptions help the AI understand when and how to use parameters.
Good descriptions:
- "City name to check weather for (e.g., 'New York', 'London')"
- "Maximum number of results, between 1 and 100"
- "Date in YYYY-MM-DD format"
Bad descriptions:
- "The city"
- "Number"
- "Input value"
Validation
Required vs Optional
Mark parameters required only if the tool cannot function without them.
# Required - tool can't work without this
city (string, required): "City name"
# Optional - has sensible default
units (string, optional, default: "metric"): "Temperature units"Value Constraints
Document constraints in the description:
limit (number, required): "Results to return, 1-100"
status (string, required): "Order status: pending, shipped, or delivered"Example: Search Tool
Tool: Search Products
Parameters:
query (string, required):
"Search query - product name, category, or keywords"
category (string, optional):
"Filter by category: electronics, clothing, home, or all"
Default: "all"
min_price (number, optional):
"Minimum price in dollars"
max_price (number, optional):
"Maximum price in dollars"
sort_by (string, optional):
"Sort results: relevance, price_low, price_high, newest"
Default: "relevance"
limit (number, optional):
"Maximum results, 1-50"
Default: 10Using Parameters in Tools
In API Tools
Reference in URL or body:
Endpoint: https://api.example.com/search?q={{query}}&limit={{limit}}
Body:
{
"search": "{{query}}",
"filters": {
"category": "{{category}}",
"min_price": {{min_price}},
"max_price": {{max_price}}
}
}In Code Tools
Access via params object:
const query = params.query;
const limit = params.limit || 10;
const minPrice = params.min_price || 0;
// Use parameters in logic...Output Definition
Define what your tool returns:
Returns:
results (array): List of matching products
total_count (number): Total matches found
query_time_ms (number): Search durationClear output definitions help the AI present results to users.
Common Questions
Next Steps
Was this page helpful? Let us know!
Report an issue