Tools give agents the ability to perform actions beyond text generation. Each tool has a name, description, parameter schema, and handler function.
import { Tool } from "@microsoft/agents";
const calculatorTool = new Tool({
name: "calculator",
description: "Perform basic arithmetic operations",
parameters: {
operation: { type: "string", enum: ["add", "subtract", "multiply", "divide"] },
a: { type: "number" },
b: { type: "number" }
},
handler: async ({ operation, a, b }) => {
switch (operation) {
case "add": return a + b;
case "subtract": return a - b;
case "multiply": return a * b;
case "divide": return a / b;
}
}
});
Agents can call external REST APIs through tools.
const jiraTool = new Tool({
name: "create_jira_ticket",
description: "Create a Jira ticket",
parameters: {
summary: { type: "string" },
description: { type: "string" },
priority: { type: "string", enum: ["Low", "Medium", "High", "Critical"] }
},
handler: async (args) => {
const token = await getAuthToken();
const res = await fetch("https://your-domain.atlassian.net/rest/api/2/issue", {
method: "POST",
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify({
fields: {
project: { key: "PROJ" },
summary: args.summary,
description: args.description,
priority: { name: args.priority }
}
})
});
return res.json();
}
});
MAF supports out-of-the-box connectors for common data sources: