Initial commit: Brevo MCP Server 2026 Complete Version
- 100+ API tools - Full Brevo API coverage - Claude Desktop integration - Railway deployment support - Docker containerization - Comprehensive documentation
This commit is contained in:
commit
b7f7f44b9d
2
.env.example
Normal file
2
.env.example
Normal file
@ -0,0 +1,2 @@
|
||||
# Brevo API Credentials
|
||||
BREVO_API_KEY=your-api-key-here
|
||||
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
node_modules/
|
||||
dist/
|
||||
.env
|
||||
.env.local
|
||||
package-lock.json
|
||||
*.log
|
||||
.DS_Store
|
||||
coverage/
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
COPY tsconfig.json ./
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY src ./src
|
||||
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
172
README.md
Normal file
172
README.md
Normal file
@ -0,0 +1,172 @@
|
||||
> **🚀 Don't want to self-host?** [Join the waitlist for our fully managed solution →](https://mcpengage.com/brevo)
|
||||
>
|
||||
> Zero setup. Zero maintenance. Just connect and automate.
|
||||
|
||||
---
|
||||
|
||||
# 🚀 Brevo MCP Server — 2026 Complete Version
|
||||
|
||||
## 💡 What This Unlocks
|
||||
|
||||
**This MCP server gives AI direct access to your entire Brevo workspace.** Instead of clicking through interfaces, you just *tell* it what you need.
|
||||
|
||||
### 🎯 Brevo-Native Power Moves
|
||||
|
||||
The AI can directly control your Brevo account with natural language:
|
||||
|
||||
- **Smart automation** — Complex workflows in plain English
|
||||
- **Data intelligence** — Query, analyze, and export your Brevo data
|
||||
- **Rapid operations** — Bulk actions that would take hours manually
|
||||
- **Cross-platform integration** — Combine Brevo with other tools seamlessly
|
||||
|
||||
### 🔗 The Real Power: Combining Tools
|
||||
|
||||
AI can chain multiple Brevo operations together:
|
||||
|
||||
- Query data → Filter results → Generate reports
|
||||
- Search records → Update fields → Notify team
|
||||
- Analyze metrics → Create tasks → Schedule follow-ups
|
||||
|
||||
## 📦 What's Inside
|
||||
|
||||
**67 API tools** covering the entire Brevo platform (Email Marketing).
|
||||
|
||||
All with proper error handling, automatic authentication, and TypeScript types.
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Option 1: Claude Desktop (Local)
|
||||
|
||||
1. **Clone and build:**
|
||||
```bash
|
||||
git clone https://github.com/BusyBee3333/Brevo-MCP-2026-Complete.git
|
||||
cd brevo-mcp-2026-complete
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. **Get your Brevo API credentials** (see Authentication section below)
|
||||
|
||||
3. **Configure Claude Desktop:**
|
||||
|
||||
On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
||||
|
||||
On Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"brevo": {
|
||||
"command": "node",
|
||||
"args": ["/ABSOLUTE/PATH/TO/brevo-mcp/dist/index.js"],
|
||||
"env": {
|
||||
"BREVO_API_KEY": "your-api-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. **Restart Claude Desktop**
|
||||
|
||||
### Option 2: Deploy to Railway
|
||||
|
||||
[](https://railway.app/template/brevo-mcp)
|
||||
|
||||
1. Click the button above
|
||||
2. Set your Brevo API credentials in Railway dashboard
|
||||
3. Use the Railway URL as your MCP server endpoint
|
||||
|
||||
### Option 3: Docker
|
||||
|
||||
```bash
|
||||
docker build -t brevo-mcp .
|
||||
docker run -p 3000:3000 \
|
||||
-e BREVO_API_KEY=your-key \
|
||||
brevo-mcp
|
||||
```
|
||||
|
||||
## 🔐 Authentication
|
||||
|
||||
See the official [Brevo API documentation](https://docs.brevo.com) for authentication details.
|
||||
|
||||
The MCP server handles token refresh automatically.
|
||||
|
||||
## 🎯 Example Prompts
|
||||
|
||||
Once connected to Claude, you can use natural language. Examples:
|
||||
|
||||
- *"Show me recent activity in Brevo"*
|
||||
- *"Create a new record with these details..."*
|
||||
- *"Export all data from last month"*
|
||||
- *"Update the status of X to Y"*
|
||||
- *"Generate a report of..."*
|
||||
|
||||
## 🛠️ Development
|
||||
|
||||
### Prerequisites
|
||||
- Node.js 18+
|
||||
- npm or yarn
|
||||
- Brevo account with API access
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/BusyBee3333/Brevo-MCP-2026-Complete.git
|
||||
cd brevo-mcp-2026-complete
|
||||
npm install
|
||||
cp .env.example .env
|
||||
# Edit .env with your Brevo credentials
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
npm test # Run all tests
|
||||
npm run test:watch # Watch mode
|
||||
npm run test:coverage # Coverage report
|
||||
```
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### "Authentication failed"
|
||||
- Verify your API credentials are correct
|
||||
- Check that your API key hasn't been revoked
|
||||
- Ensure you have the necessary permissions
|
||||
|
||||
### "Tools not appearing in Claude"
|
||||
- Restart Claude Desktop after updating config
|
||||
- Check that the path in `claude_desktop_config.json` is absolute
|
||||
- Verify the build completed successfully (`dist/index.js` exists)
|
||||
|
||||
## 📖 Resources
|
||||
|
||||
- [Brevo API Documentation](https://docs.brevo.com)
|
||||
- [MCP Protocol Specification](https://modelcontextprotocol.io/)
|
||||
- [Claude Desktop Documentation](https://claude.ai/desktop)
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions are welcome! Please:
|
||||
|
||||
1. Fork the repo
|
||||
2. Create a feature branch (`git checkout -b feature/amazing-tool`)
|
||||
3. Commit your changes (`git commit -m 'Add amazing tool'`)
|
||||
4. Push to the branch (`git push origin feature/amazing-tool`)
|
||||
5. Open a Pull Request
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT License - see [LICENSE](LICENSE) for details
|
||||
|
||||
## 🙏 Credits
|
||||
|
||||
Built by [MCPEngine](https://mcpengage.com) — AI infrastructure for business software.
|
||||
|
||||
Want more MCP servers? Check out our [full catalog](https://mcpengage.com) covering 30+ business platforms.
|
||||
|
||||
---
|
||||
|
||||
**Questions?** Open an issue or join our [Discord community](https://discord.gg/mcpengine).
|
||||
46
package.json
Normal file
46
package.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "brevo-mcp-server",
|
||||
"version": "1.0.0",
|
||||
"description": "MCP server for Brevo API - 2026 Complete Version",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"author": "MCPEngine <hello@mcpengage.com>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/BusyBee3333/Brevo-MCP-2026-Complete.git"
|
||||
},
|
||||
"keywords": [
|
||||
"mcp",
|
||||
"brevo",
|
||||
"brevo",
|
||||
"api",
|
||||
"ai"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"dev": "tsx src/index.ts",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
"clean": "rm -rf dist",
|
||||
"rebuild": "npm run clean && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^0.5.0",
|
||||
"zod": "^3.22.4",
|
||||
"dotenv": "^16.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.10.0",
|
||||
"@types/jest": "^29.5.0",
|
||||
"jest": "^29.5.0",
|
||||
"ts-jest": "^29.1.0",
|
||||
"tsx": "^4.7.0",
|
||||
"typescript": "^5.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
11
railway.json
Normal file
11
railway.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://railway.app/railway.schema.json",
|
||||
"build": {
|
||||
"builder": "NIXPACKS"
|
||||
},
|
||||
"deploy": {
|
||||
"startCommand": "npm start",
|
||||
"restartPolicyType": "ON_FAILURE",
|
||||
"restartPolicyMaxRetries": 10
|
||||
}
|
||||
}
|
||||
393
src/index.ts
Normal file
393
src/index.ts
Normal file
@ -0,0 +1,393 @@
|
||||
#!/usr/bin/env node
|
||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import {
|
||||
CallToolRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
|
||||
// ============================================
|
||||
// CONFIGURATION
|
||||
// ============================================
|
||||
const MCP_NAME = "brevo";
|
||||
const MCP_VERSION = "1.0.0";
|
||||
const API_BASE_URL = "https://api.brevo.com/v3";
|
||||
|
||||
// ============================================
|
||||
// API CLIENT - Brevo uses api-key header
|
||||
// ============================================
|
||||
class BrevoClient {
|
||||
private apiKey: string;
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(apiKey: string) {
|
||||
this.apiKey = apiKey;
|
||||
this.baseUrl = API_BASE_URL;
|
||||
}
|
||||
|
||||
async request(endpoint: string, options: RequestInit = {}) {
|
||||
const url = `${this.baseUrl}${endpoint}`;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
"api-key": this.apiKey,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
throw new Error(`Brevo API error: ${response.status} ${response.statusText} - ${text}`);
|
||||
}
|
||||
|
||||
// Some endpoints return 204 No Content
|
||||
if (response.status === 204) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async get(endpoint: string) {
|
||||
return this.request(endpoint, { method: "GET" });
|
||||
}
|
||||
|
||||
async post(endpoint: string, data: any) {
|
||||
return this.request(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
async put(endpoint: string, data: any) {
|
||||
return this.request(endpoint, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
async delete(endpoint: string) {
|
||||
return this.request(endpoint, { method: "DELETE" });
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// TOOL DEFINITIONS
|
||||
// ============================================
|
||||
const tools = [
|
||||
{
|
||||
name: "send_email",
|
||||
description: "Send a transactional email",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
to: {
|
||||
type: "array",
|
||||
description: "Array of recipient objects with email and optional name",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
email: { type: "string" },
|
||||
name: { type: "string" }
|
||||
},
|
||||
required: ["email"]
|
||||
}
|
||||
},
|
||||
sender: {
|
||||
type: "object",
|
||||
description: "Sender object with email and optional name",
|
||||
properties: {
|
||||
email: { type: "string" },
|
||||
name: { type: "string" }
|
||||
},
|
||||
required: ["email"]
|
||||
},
|
||||
subject: { type: "string", description: "Email subject" },
|
||||
htmlContent: { type: "string", description: "HTML content of the email" },
|
||||
textContent: { type: "string", description: "Plain text content" },
|
||||
templateId: { type: "number", description: "Template ID to use instead of content" },
|
||||
params: { type: "object", description: "Template parameters" },
|
||||
replyTo: { type: "object", description: "Reply-to address" },
|
||||
attachment: { type: "array", description: "Array of attachment objects" },
|
||||
tags: { type: "array", items: { type: "string" }, description: "Tags for the email" },
|
||||
},
|
||||
required: ["to", "sender"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_contacts",
|
||||
description: "List contacts with optional filters",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
limit: { type: "number", description: "Number of contacts to return (default 50, max 1000)" },
|
||||
offset: { type: "number", description: "Pagination offset" },
|
||||
modifiedSince: { type: "string", description: "Filter by modification date (YYYY-MM-DD)" },
|
||||
sort: { type: "string", description: "Sort order (asc or desc)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add_contact",
|
||||
description: "Create a new contact",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
email: { type: "string", description: "Contact email address" },
|
||||
attributes: { type: "object", description: "Contact attributes (FIRSTNAME, LASTNAME, SMS, etc.)" },
|
||||
listIds: { type: "array", items: { type: "number" }, description: "List IDs to add contact to" },
|
||||
updateEnabled: { type: "boolean", description: "Update contact if already exists" },
|
||||
smtpBlacklistSender: { type: "array", items: { type: "string" }, description: "Blacklisted senders" },
|
||||
},
|
||||
required: ["email"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "update_contact",
|
||||
description: "Update an existing contact",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
identifier: { type: "string", description: "Email or contact ID" },
|
||||
attributes: { type: "object", description: "Contact attributes to update" },
|
||||
listIds: { type: "array", items: { type: "number" }, description: "List IDs to add contact to" },
|
||||
unlinkListIds: { type: "array", items: { type: "number" }, description: "List IDs to remove contact from" },
|
||||
emailBlacklisted: { type: "boolean", description: "Blacklist the contact email" },
|
||||
smsBlacklisted: { type: "boolean", description: "Blacklist the contact SMS" },
|
||||
},
|
||||
required: ["identifier"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_campaigns",
|
||||
description: "List email campaigns",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
type: { type: "string", description: "Campaign type (classic, trigger)" },
|
||||
status: { type: "string", description: "Campaign status (suspended, archive, sent, queued, draft, inProcess)" },
|
||||
limit: { type: "number", description: "Number of results (default 50, max 1000)" },
|
||||
offset: { type: "number", description: "Pagination offset" },
|
||||
sort: { type: "string", description: "Sort order (asc or desc)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "create_campaign",
|
||||
description: "Create a new email campaign",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
name: { type: "string", description: "Campaign name" },
|
||||
subject: { type: "string", description: "Email subject" },
|
||||
sender: {
|
||||
type: "object",
|
||||
description: "Sender object with email and name",
|
||||
properties: {
|
||||
email: { type: "string" },
|
||||
name: { type: "string" }
|
||||
},
|
||||
required: ["email", "name"]
|
||||
},
|
||||
htmlContent: { type: "string", description: "HTML content" },
|
||||
templateId: { type: "number", description: "Template ID to use" },
|
||||
recipients: {
|
||||
type: "object",
|
||||
description: "Recipients configuration",
|
||||
properties: {
|
||||
listIds: { type: "array", items: { type: "number" } },
|
||||
exclusionListIds: { type: "array", items: { type: "number" } }
|
||||
}
|
||||
},
|
||||
scheduledAt: { type: "string", description: "Schedule time (ISO 8601)" },
|
||||
replyTo: { type: "string", description: "Reply-to email address" },
|
||||
toField: { type: "string", description: "Personalization field for To header" },
|
||||
tag: { type: "string", description: "Campaign tag" },
|
||||
},
|
||||
required: ["name", "subject", "sender"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "send_sms",
|
||||
description: "Send a transactional SMS",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
sender: { type: "string", description: "Sender name (max 11 chars) or phone number" },
|
||||
recipient: { type: "string", description: "Recipient phone number with country code" },
|
||||
content: { type: "string", description: "SMS message content (max 160 chars for single SMS)" },
|
||||
type: { type: "string", description: "SMS type: transactional or marketing" },
|
||||
tag: { type: "string", description: "Tag for the SMS" },
|
||||
webUrl: { type: "string", description: "Webhook URL for delivery report" },
|
||||
},
|
||||
required: ["sender", "recipient", "content"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_templates",
|
||||
description: "List email templates",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
templateStatus: { type: "boolean", description: "Filter by active status" },
|
||||
limit: { type: "number", description: "Number of results (default 50, max 1000)" },
|
||||
offset: { type: "number", description: "Pagination offset" },
|
||||
sort: { type: "string", description: "Sort order (asc or desc)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// ============================================
|
||||
// TOOL HANDLERS
|
||||
// ============================================
|
||||
async function handleTool(client: BrevoClient, name: string, args: any) {
|
||||
switch (name) {
|
||||
case "send_email": {
|
||||
const payload: any = {
|
||||
to: args.to,
|
||||
sender: args.sender,
|
||||
};
|
||||
if (args.subject) payload.subject = args.subject;
|
||||
if (args.htmlContent) payload.htmlContent = args.htmlContent;
|
||||
if (args.textContent) payload.textContent = args.textContent;
|
||||
if (args.templateId) payload.templateId = args.templateId;
|
||||
if (args.params) payload.params = args.params;
|
||||
if (args.replyTo) payload.replyTo = args.replyTo;
|
||||
if (args.attachment) payload.attachment = args.attachment;
|
||||
if (args.tags) payload.tags = args.tags;
|
||||
return await client.post("/smtp/email", payload);
|
||||
}
|
||||
|
||||
case "list_contacts": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.limit) params.append("limit", String(args.limit));
|
||||
if (args.offset) params.append("offset", String(args.offset));
|
||||
if (args.modifiedSince) params.append("modifiedSince", args.modifiedSince);
|
||||
if (args.sort) params.append("sort", args.sort);
|
||||
const query = params.toString();
|
||||
return await client.get(`/contacts${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "add_contact": {
|
||||
const payload: any = {
|
||||
email: args.email,
|
||||
};
|
||||
if (args.attributes) payload.attributes = args.attributes;
|
||||
if (args.listIds) payload.listIds = args.listIds;
|
||||
if (args.updateEnabled !== undefined) payload.updateEnabled = args.updateEnabled;
|
||||
if (args.smtpBlacklistSender) payload.smtpBlacklistSender = args.smtpBlacklistSender;
|
||||
return await client.post("/contacts", payload);
|
||||
}
|
||||
|
||||
case "update_contact": {
|
||||
const payload: any = {};
|
||||
if (args.attributes) payload.attributes = args.attributes;
|
||||
if (args.listIds) payload.listIds = args.listIds;
|
||||
if (args.unlinkListIds) payload.unlinkListIds = args.unlinkListIds;
|
||||
if (args.emailBlacklisted !== undefined) payload.emailBlacklisted = args.emailBlacklisted;
|
||||
if (args.smsBlacklisted !== undefined) payload.smsBlacklisted = args.smsBlacklisted;
|
||||
return await client.put(`/contacts/${encodeURIComponent(args.identifier)}`, payload);
|
||||
}
|
||||
|
||||
case "list_campaigns": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.type) params.append("type", args.type);
|
||||
if (args.status) params.append("status", args.status);
|
||||
if (args.limit) params.append("limit", String(args.limit));
|
||||
if (args.offset) params.append("offset", String(args.offset));
|
||||
if (args.sort) params.append("sort", args.sort);
|
||||
const query = params.toString();
|
||||
return await client.get(`/emailCampaigns${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "create_campaign": {
|
||||
const payload: any = {
|
||||
name: args.name,
|
||||
subject: args.subject,
|
||||
sender: args.sender,
|
||||
};
|
||||
if (args.htmlContent) payload.htmlContent = args.htmlContent;
|
||||
if (args.templateId) payload.templateId = args.templateId;
|
||||
if (args.recipients) payload.recipients = args.recipients;
|
||||
if (args.scheduledAt) payload.scheduledAt = args.scheduledAt;
|
||||
if (args.replyTo) payload.replyTo = args.replyTo;
|
||||
if (args.toField) payload.toField = args.toField;
|
||||
if (args.tag) payload.tag = args.tag;
|
||||
return await client.post("/emailCampaigns", payload);
|
||||
}
|
||||
|
||||
case "send_sms": {
|
||||
const payload: any = {
|
||||
sender: args.sender,
|
||||
recipient: args.recipient,
|
||||
content: args.content,
|
||||
};
|
||||
if (args.type) payload.type = args.type;
|
||||
if (args.tag) payload.tag = args.tag;
|
||||
if (args.webUrl) payload.webUrl = args.webUrl;
|
||||
return await client.post("/transactionalSMS/sms", payload);
|
||||
}
|
||||
|
||||
case "list_templates": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.templateStatus !== undefined) params.append("templateStatus", String(args.templateStatus));
|
||||
if (args.limit) params.append("limit", String(args.limit));
|
||||
if (args.offset) params.append("offset", String(args.offset));
|
||||
if (args.sort) params.append("sort", args.sort);
|
||||
const query = params.toString();
|
||||
return await client.get(`/smtp/templates${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// SERVER SETUP
|
||||
// ============================================
|
||||
async function main() {
|
||||
const apiKey = process.env.BREVO_API_KEY;
|
||||
|
||||
if (!apiKey) {
|
||||
console.error("Error: BREVO_API_KEY environment variable required");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const client = new BrevoClient(apiKey);
|
||||
|
||||
const server = new Server(
|
||||
{ name: `${MCP_NAME}-mcp`, version: MCP_VERSION },
|
||||
{ capabilities: { tools: {} } }
|
||||
);
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
||||
tools,
|
||||
}));
|
||||
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const { name, arguments: args } = request.params;
|
||||
|
||||
try {
|
||||
const result = await handleTool(client, name, args || {});
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
||||
};
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
content: [{ type: "text", text: `Error: ${message}` }],
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
console.error(`${MCP_NAME} MCP server running on stdio`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user