@clicksend/langchain-clicksend-mcp
v0.1.0
Published
LangChain MCP integration for ClickSend
Keywords
Readme
@clicksend/langchain-clicksend-mcp
LangChain integration for ClickSend via Model Context Protocol (MCP).
This package provides LangChain tools that wrap the ClickSend MCP Server, enabling you to send SMS, MMS, and other ClickSend communications through LangChain agents.
Installation
npm install @clicksend/langchain-clicksend-mcpPrerequisites
You need a ClickSend account with API credentials:
- Username: Your ClickSend account username
- API Key: Your ClickSend API key
Get your credentials from the ClickSend Dashboard.
Usage
Basic Example
import { createClickSendTools } from "@langchain/clicksend-mcp";
import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
// Initialize ClickSend tools
const tools = await createClickSendTools({
username: process.env.CLICKSEND_USERNAME!,
apiKey: process.env.CLICKSEND_API_KEY!,
});
// Create an agent with the tools
const llm = new ChatOpenAI({
model: "gpt-4",
temperature: 0,
});
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a helpful assistant with access to ClickSend communication tools."],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
});
// Send an SMS
const result = await agentExecutor.invoke({
input: "Send an SMS to +1234567890 saying 'Hello from LangChain!'"
});
console.log(result.output);Available Tools
The integration automatically exposes all tools from the ClickSend MCP server, which typically include:
- send_sms: Send SMS messages
- send_mms: Send MMS messages
- get_sms_history: Retrieve SMS history
- get_account_balance: Check account balance
- And more...
The exact tools available depend on the ClickSend MCP server version.
Configuration
import { createClickSendTools } from "@clicksend/langchain-clicksend-mcp";
const tools = await createClickSendTools({
username: "your-clicksend-username",
apiKey: "your-clicksend-api-key",
});Options
username(required): Your ClickSend account usernameapiKey(required): Your ClickSend API key
Environment Variables
For security, use environment variables to store credentials:
export CLICKSEND_USERNAME="your-username"
export CLICKSEND_API_KEY="your-api-key"const tools = await createClickSendTools({
username: process.env.CLICKSEND_USERNAME!,
apiKey: process.env.CLICKSEND_API_KEY!,
});Advanced Usage
Direct MCP Client Access
If you need more control, you can access the underlying MCP client:
import { createClickSendMCPClient } from "@clicksend/langchain-clicksend-mcp";
const client = createClickSendMCPClient({
username: process.env.CLICKSEND_USERNAME!,
apiKey: process.env.CLICKSEND_API_KEY!,
});
// Get tools
const tools = await client.getTools();
// Access the raw MCP client
// ... additional MCP operationsTesting
npm testMake sure to set the required environment variables before running tests:
export CLICKSEND_USERNAME="your-test-username"
export CLICKSEND_API_KEY="your-test-api-key"
npm testBuilding
npm run buildLicense
MIT
