Use Bavimail with LangChain, CrewAI, LlamaIndex, Vercel AI SDK, Claude Code, Cursor, Cline, and n8n
Bavimail ships @bavimail/toolkit (npm) and bavimail-toolkit (PyPI) with first-party framework adapters, plus a separate @bavimail/mcp-server for MCP-compatible hosts. Every common AI agent workflow integrates through one of these packages.
Last updated June 7, 2026
The shape of Bavimail AI framework integration
Bavimail covers AI framework workflows through three first-party packages. The @bavimail/toolkit npm package ships LangChain DynamicStructuredTool and Vercel AI SDK adapters. The bavimail-toolkit PyPI package ships LangChain StructuredTool, CrewAI BaseTool, and LlamaIndex FunctionTool adapters. The @bavimail/mcp-server npm package covers MCP-compatible hosts (Claude Desktop, Claude Code, Cursor, Cline) directly.
Three packages, one underlying API. All three wrap the same underlying Bavimail REST API and the official bavimail SDKs. Pick the package that matches the agent shape you are wiring: explicit agent loop with framework tools (toolkit), MCP-compatible host (mcp-server), or raw HTTP from a workflow tool like n8n (REST).
LangChain
Install @bavimail/toolkit (Node) or bavimail-toolkit[langchain] (Python). The package exposes five tools: send_email , get_email , list_inbound_emails , get_inbound_email , list_aliases .
npm install @bavimail/toolkit @langchain/openai @langchain/coreimport { createBavimailLangChainTools } from "@bavimail/toolkit/langchain";
import { ChatOpenAI } from "@langchain/openai";
const tools = createBavimailLangChainTools({ apiKey: process.env.BAVIMAIL_API_KEY });
const model = new ChatOpenAI({ model: "gpt-4o" }).bindTools(tools);
const result = await model.invoke(
"Send a welcome email to [email protected] from our default alias"
);pip install bavimail-toolkit[langchain] langchain-openaiVercel AI SDK
The Node toolkit also exposes a Vercel AI SDK adapter via the /ai-sdk subpath.
import { createBavimailAiSdkTools } from "@bavimail/toolkit/ai-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const tools = createBavimailAiSdkTools({ apiKey: process.env.BAVIMAIL_API_KEY });
const result = await generateText({
model: openai("gpt-4o"),
tools,
prompt: "Send a welcome email to [email protected] saying 'Glad you joined.'",
});CrewAI
CrewAI tools subclass BaseTool . The toolkit ships pre-built subclasses for the five email operations.
pip install bavimail-toolkit[crewai]from bavimail_toolkit.crewai import create_bavimail_crewai_tools
from crewai import Agent, Task, Crew
tools = create_bavimail_crewai_tools()
email_agent = Agent(
role="Email Assistant",
goal="Send transactional emails on behalf of the team.",
backstory="Specialized in clear, concise outbound email.",
tools=tools,
)LlamaIndex
LlamaIndex agents accept FunctionTool definitions. The toolkit builds them from the underlying Python SDK directly.
pip install bavimail-toolkit[llamaindex]from bavimail_toolkit.llamaindex import create_bavimail_llamaindex_tools
from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI
tools = create_bavimail_llamaindex_tools()
agent = ReActAgent.from_tools(tools, llm=OpenAI(model="gpt-4o"))
result = agent.chat("Send a welcome email to [email protected]")Core toolkit (framework-agnostic)
For frameworks not yet covered (LiveKit Agents, Mastra, OpenAI Agents SDK, custom agent loop), use the core BavimailToolkit class directly. The five methods (send_email , get_email , list_inbound_emails , get_inbound_email , list_aliases ) accept pydantic schemas or plain dicts.
pip install bavimail-toolkitfrom bavimail_toolkit import BavimailToolkit
toolkit = BavimailToolkit() # reads BAVIMAIL_API_KEY from env
aliases = toolkit.list_aliases()
result = toolkit.send_email({
"alias_id": aliases[0].id,
"to_email": "[email protected]",
"subject": "Hi",
"body": "Hello from Bavimail.",
})Claude Code, Cursor, Cline (MCP hosts)
For MCP-compatible hosts, use the separate @bavimail/mcp-server package directly without writing an explicit agent loop. 12 tools across send, inbound, identity, and domain management. Full setup at /docs/mcp.
{
"mcpServers": {
"bavimail": {
"command": "npx",
"args": ["-y", "@bavimail/mcp-server"],
"env": {
"BAVIMAIL_API_KEY": "<YOUR_KEY>"
}
}
}
}Once configured, prompt example: "Send a welcome email to [email protected] using our default alias, subject 'Welcome', body 'Glad you joined.'"
n8n
Use the n8n HTTP Request node pointed at api.bavimail.com with the x-api-key header. Every Bavimail endpoint is REST plus JSON.
# n8n HTTP Request node settings:
URL: https://api.bavimail.com/emails
Method: POST
Auth: Generic Credential Type -> Header Auth
Name: x-api-key
Value: <YOUR_BAVIMAIL_API_KEY>
Body Content-Type: JSON
Body:
{
"alias_id": "<YOUR_ALIAS_ID>",
"to_email": "{{$json.recipient}}",
"subject": "{{$json.subject}}",
"body": "{{$json.html}}"
}For inbound automations in n8n, wire your Bavimail inbound webhook to an n8n Webhook node and the trigger fires on every inbound message with the parsed payload available as standard n8n JSON.
Untrusted-input safety for inbound email
The MCP server (inbound_emails_get and inbound_emails_list tools) wraps every inbound payload in an explicit envelope on the MCP response:
{ "__untrusted_third_party_content": true, "content": { /* parsed inbound email */ } }The toolkit packages propagate the same envelope on their inbound tool responses (TypeScript: UntrustedEnvelope ; Python: UntrustedEnvelope ). This is the only documented structural prompt-injection safeguard at the email-API-tool-response layer across the category as of May 2026.
When you wrap Bavimail inbound inside any framework tool response, propagate the untrusted-content envelope so downstream agent steps continue to see the content as data, not as instructions.
Frequently asked questions
Does Bavimail ship a LangChain integration?
Yes. Install with npm install @bavimail/toolkit (Node) or pip install bavimail-toolkit[langchain] (Python). Then import createBavimailLangChainTools from @bavimail/toolkit/langchain or create_bavimail_langchain_tools from bavimail_toolkit.langchain. The package wraps the official bavimail SDK into LangChain DynamicStructuredTool (TS) or StructuredTool (Python) definitions for send_email, get_email, list_inbound_emails, get_inbound_email, and list_aliases.
Does Bavimail ship a CrewAI integration?
Yes, in the Python package. Install with pip install bavimail-toolkit[crewai]. Import create_bavimail_crewai_tools from bavimail_toolkit.crewai to get CrewAI BaseTool subclasses for the same five email operations.
Does Bavimail ship a LlamaIndex integration?
Yes. Install with pip install bavimail-toolkit[llamaindex]. Import create_bavimail_llamaindex_tools from bavimail_toolkit.llamaindex to get LlamaIndex FunctionTool definitions.
Does Bavimail work with Claude Code, Cursor, and Cline?
Yes through the separate @bavimail/mcp-server package (no toolkit dependency). Install with npx @bavimail/mcp-server and configure once in your MCP host. 12 tools across send, inbound, identity, and domain management. Full setup at /docs/mcp.
Does Bavimail have an n8n node?
Bavimail does not ship a dedicated n8n community node yet. Use the n8n HTTP Request node pointed at api.bavimail.com with the x-api-key header. Every Bavimail endpoint is REST + JSON; the HTTP Request node covers the full surface.
How is Bavimail different from AgentMail on AI framework integration?
Both vendors ship first-party MCP servers and dedicated toolkit packages. Bavimail ships @bavimail/toolkit (npm) with LangChain + Vercel AI SDK adapters and bavimail-toolkit (PyPI) with LangChain + CrewAI + LlamaIndex adapters. AgentMail ships agentmail-toolkit (npm + PyPI) with comparable framework coverage. The differentiation is on cost (Bavimail Pro $5/mo at 50K emails vs AgentMail Developer $20/mo at 10K), on consolidation (Bavimail bundles transactional + marketing send on the same plan), and on prompt-injection safety (Bavimail propagates an explicit untrusted-third-party-content envelope on inbound MCP and toolkit responses; AgentMail does not document an equivalent structural safeguard).
Related
-
MCP Server, full 12-tool reference and setup for Claude Desktop, Cursor, Cline, Claude Code.
-
Agent Onboarding, give your AI agent its own email identity with two-way email capability.
-
SDK Guides, official TypeScript and Python clients.
-
AgentMail vs Bavimail, full feature parity comparison.
-
github.com/Bavlio/bavimail-toolkit, monorepo source for both npm and PyPI packages.
Official SDKs with language-specific capability differences
The SDKs do not expose identical surfaces. This page shows the real package names, constructors, auth modes, webhook helpers, and resource coverage for each maintained client.
Drive Bavimail from your AI assistant
MCP server for Bavimail. Claude Desktop, Cursor, Cline, and any MCP-compatible host can send email, manage domains, and handle inbound, all from the conversation.