Tools
ToolRegistry for managing and executing tools via local functions or transport connectors.
Interactive Demo
Register and call tools
Code Example
tools-demo.ts
import { ToolRegistry, LocalToolConnector, TransportToolConnector, HttpTransport } from "@shivamsharma11/agent-sdk";
const registry = new ToolRegistry();
// Register a local tool
registry.register(
new LocalToolConnector(
"greet",
async (input: { name: string }) => `Hello, ${input.name}!`,
"Greet a person by name",
{ type: "object", properties: { name: { type: "string" } } }
)
);
// Register a transport-based tool
registry.register(
new TransportToolConnector(
"http",
"fetch-data",
new HttpTransport({ baseUrl: "https://api.example.com" }),
"Fetch data from API"
)
);
// List and call tools
const tools = registry.list();
const result = await registry.call("greet", { name: "SDK" });