The TypeScript SDK provides a simple way to register functions as tools for AI agents.
Installation
Basic Usage
import { AgentRPC } from 'agentrpc';
import { z } from 'zod';
const rpc = new AgentRPC({
apiSecret: process.env.AGENTRPC_API_SECRET!,
});
rpc.register({
name: 'getWeather',
description: 'Return weather information at a given location',
schema: z.object({ location: z.string() }),
handler: async ({ location }) => {
return {
location: location,
temperature: 'variable',
parcipitation: 'probably',
};
},
});
rpc.listen();
MCP Server
The TypeScript SDK includes an MCP (Model Context Protocol) server that can be started using:
AGENTRPC_API_SECRET <YOUR_API_SECRET> npx agentrpc mcp
For more details, visit the TypeScript SDK GitHub repository.