Getting Started
@cf-agents is an open-source collection of packages built to extend the capabilities of Cloudflare Agents.
While Cloudflare provides the core AI agent platform, @cf-agents gives you the high-level tools you need to build real-world applications. Need to read emails, send Slack messages, or manage a Discord server? Just plug these packages directly into your agent’s toolset.
Pre-requisites
Section titled “Pre-requisites”- A Cloudflare Workers project (we recommend
npm create cloudflare@latest)
Installation
Section titled “Installation”Install the packages you need using your preferred package manager:
npm install @cf-agents/google @cf-agents/discord# orpnpm add @cf-agents/google @cf-agents/discordBasic Usage
Section titled “Basic Usage”All packages follow a similar pattern:
- Environment Variables: Configure your API keys and secrets.
- Tool Creation: Use the
createXToolshelper to generate AI SDK compatible tools. - Authentication: Some packages (like Google) require OAuth flows which are handled by helper methods.
Example
Section titled “Example”import { createDiscordTools } from "@cf-agents/discord";
// inside your Agent's onChatMessageconst discordTools = createDiscordTools({ getToken: async () => ({ token: this.env.DISCORD_TOKEN }),});
const result = streamText({ tools: { ...discordTools, // ... other tools } // ...})