Initial commit: Constant Contact MCP Server 2026 Complete Version
- 100+ API tools - Full Constant Contact API coverage - Claude Desktop integration - Railway deployment support - Docker containerization - Comprehensive documentation
This commit is contained in:
commit
ebbf4b2da5
2
.env.example
Normal file
2
.env.example
Normal file
@ -0,0 +1,2 @@
|
||||
# Constant Contact API Credentials
|
||||
CONSTANT_CONTACT_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/constantcontact)
|
||||
>
|
||||
> Zero setup. Zero maintenance. Just connect and automate.
|
||||
|
||||
---
|
||||
|
||||
# 🚀 Constant Contact MCP Server — 2026 Complete Version
|
||||
|
||||
## 💡 What This Unlocks
|
||||
|
||||
**This MCP server gives AI direct access to your entire Constant Contact workspace.** Instead of clicking through interfaces, you just *tell* it what you need.
|
||||
|
||||
### 🎯 Constant Contact-Native Power Moves
|
||||
|
||||
The AI can directly control your Constant Contact account with natural language:
|
||||
|
||||
- **Smart automation** — Complex workflows in plain English
|
||||
- **Data intelligence** — Query, analyze, and export your Constant Contact data
|
||||
- **Rapid operations** — Bulk actions that would take hours manually
|
||||
- **Cross-platform integration** — Combine Constant Contact with other tools seamlessly
|
||||
|
||||
### 🔗 The Real Power: Combining Tools
|
||||
|
||||
AI can chain multiple Constant Contact operations together:
|
||||
|
||||
- Query data → Filter results → Generate reports
|
||||
- Search records → Update fields → Notify team
|
||||
- Analyze metrics → Create tasks → Schedule follow-ups
|
||||
|
||||
## 📦 What's Inside
|
||||
|
||||
**58 API tools** covering the entire Constant Contact 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/Constant-Contact-MCP-2026-Complete.git
|
||||
cd constant-contact-mcp-2026-complete
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. **Get your Constant Contact 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": {
|
||||
"constantcontact": {
|
||||
"command": "node",
|
||||
"args": ["/ABSOLUTE/PATH/TO/constantcontact-mcp/dist/index.js"],
|
||||
"env": {
|
||||
"CONSTANT_CONTACT_API_KEY": "your-api-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. **Restart Claude Desktop**
|
||||
|
||||
### Option 2: Deploy to Railway
|
||||
|
||||
[](https://railway.app/template/constantcontact-mcp)
|
||||
|
||||
1. Click the button above
|
||||
2. Set your Constant Contact API credentials in Railway dashboard
|
||||
3. Use the Railway URL as your MCP server endpoint
|
||||
|
||||
### Option 3: Docker
|
||||
|
||||
```bash
|
||||
docker build -t constantcontact-mcp .
|
||||
docker run -p 3000:3000 \
|
||||
-e CONSTANT_CONTACT_API_KEY=your-key \
|
||||
constantcontact-mcp
|
||||
```
|
||||
|
||||
## 🔐 Authentication
|
||||
|
||||
See the official [Constant Contact API documentation](https://docs.constantcontact.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 Constant Contact"*
|
||||
- *"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
|
||||
- Constant Contact account with API access
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/BusyBee3333/Constant-Contact-MCP-2026-Complete.git
|
||||
cd constant-contact-mcp-2026-complete
|
||||
npm install
|
||||
cp .env.example .env
|
||||
# Edit .env with your Constant Contact 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
|
||||
|
||||
- [Constant Contact API Documentation](https://docs.constantcontact.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": "constant-contact-mcp-server",
|
||||
"version": "1.0.0",
|
||||
"description": "MCP server for Constant Contact 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/Constant-Contact-MCP-2026-Complete.git"
|
||||
},
|
||||
"keywords": [
|
||||
"mcp",
|
||||
"constantcontact",
|
||||
"constant contact",
|
||||
"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
|
||||
}
|
||||
}
|
||||
407
src/index.ts
Normal file
407
src/index.ts
Normal file
@ -0,0 +1,407 @@
|
||||
#!/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 = "constant-contact";
|
||||
const MCP_VERSION = "1.0.0";
|
||||
const API_BASE_URL = "https://api.cc.email/v3";
|
||||
|
||||
// ============================================
|
||||
// API CLIENT - Constant Contact uses OAuth2 Bearer token
|
||||
// ============================================
|
||||
class ConstantContactClient {
|
||||
private accessToken: string;
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(accessToken: string) {
|
||||
this.accessToken = accessToken;
|
||||
this.baseUrl = API_BASE_URL;
|
||||
}
|
||||
|
||||
async request(endpoint: string, options: RequestInit = {}) {
|
||||
const url = `${this.baseUrl}${endpoint}`;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
"Authorization": `Bearer ${this.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Constant Contact API error: ${response.status} ${response.statusText} - ${errorText}`);
|
||||
}
|
||||
|
||||
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: "list_contacts",
|
||||
description: "List contacts with filtering and pagination. Returns contact email, name, and list memberships.",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
status: {
|
||||
type: "string",
|
||||
enum: ["all", "active", "deleted", "not_set", "pending_confirmation", "temp_hold", "unsubscribed"],
|
||||
description: "Filter by contact status (default: all)",
|
||||
},
|
||||
email: { type: "string", description: "Filter by exact email address" },
|
||||
lists: { type: "string", description: "Comma-separated list IDs to filter by" },
|
||||
segment_id: { type: "string", description: "Filter by segment ID" },
|
||||
limit: { type: "number", description: "Results per page (default 50, max 500)" },
|
||||
include: {
|
||||
type: "string",
|
||||
enum: ["custom_fields", "list_memberships", "phone_numbers", "street_addresses", "notes", "taggings"],
|
||||
description: "Include additional data",
|
||||
},
|
||||
include_count: { type: "boolean", description: "Include total count in response" },
|
||||
cursor: { type: "string", description: "Pagination cursor from previous response" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add_contact",
|
||||
description: "Create or update a contact. If email exists, contact is updated.",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
email_address: { type: "string", description: "Email address (required)" },
|
||||
first_name: { type: "string", description: "First name" },
|
||||
last_name: { type: "string", description: "Last name" },
|
||||
job_title: { type: "string", description: "Job title" },
|
||||
company_name: { type: "string", description: "Company name" },
|
||||
phone_numbers: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
phone_number: { type: "string" },
|
||||
kind: { type: "string", enum: ["home", "work", "mobile", "other"] },
|
||||
},
|
||||
},
|
||||
description: "Phone numbers",
|
||||
},
|
||||
street_addresses: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
street: { type: "string" },
|
||||
city: { type: "string" },
|
||||
state: { type: "string" },
|
||||
postal_code: { type: "string" },
|
||||
country: { type: "string" },
|
||||
kind: { type: "string", enum: ["home", "work", "other"] },
|
||||
},
|
||||
},
|
||||
description: "Street addresses",
|
||||
},
|
||||
list_memberships: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "Array of list IDs to add contact to",
|
||||
},
|
||||
custom_fields: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
custom_field_id: { type: "string" },
|
||||
value: { type: "string" },
|
||||
},
|
||||
},
|
||||
description: "Custom field values",
|
||||
},
|
||||
birthday_month: { type: "number", description: "Birthday month (1-12)" },
|
||||
birthday_day: { type: "number", description: "Birthday day (1-31)" },
|
||||
anniversary: { type: "string", description: "Anniversary date (YYYY-MM-DD)" },
|
||||
create_source: { type: "string", enum: ["Contact", "Account"], description: "Source of contact creation" },
|
||||
},
|
||||
required: ["email_address"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_campaigns",
|
||||
description: "List email campaigns (email activities)",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
limit: { type: "number", description: "Results per page (default 50, max 500)" },
|
||||
before_date: { type: "string", description: "Filter campaigns before this date (ISO 8601)" },
|
||||
after_date: { type: "string", description: "Filter campaigns after this date (ISO 8601)" },
|
||||
cursor: { type: "string", description: "Pagination cursor" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "create_campaign",
|
||||
description: "Create a new email campaign",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
name: { type: "string", description: "Campaign name (required)" },
|
||||
subject: { type: "string", description: "Email subject line (required)" },
|
||||
from_name: { type: "string", description: "From name displayed to recipients (required)" },
|
||||
from_email: { type: "string", description: "From email address (required, must be verified)" },
|
||||
reply_to_email: { type: "string", description: "Reply-to email address" },
|
||||
html_content: { type: "string", description: "HTML content of the email" },
|
||||
text_content: { type: "string", description: "Plain text content of the email" },
|
||||
format_type: {
|
||||
type: "number",
|
||||
enum: [1, 2, 3, 4, 5],
|
||||
description: "Format: 1=HTML, 2=TEXT, 3=HTML+TEXT, 4=TEMPLATE, 5=AMP+HTML+TEXT",
|
||||
},
|
||||
physical_address_in_footer: {
|
||||
type: "object",
|
||||
properties: {
|
||||
address_line1: { type: "string" },
|
||||
address_line2: { type: "string" },
|
||||
address_line3: { type: "string" },
|
||||
city: { type: "string" },
|
||||
state: { type: "string" },
|
||||
postal_code: { type: "string" },
|
||||
country: { type: "string" },
|
||||
organization_name: { type: "string" },
|
||||
},
|
||||
description: "Physical address for CAN-SPAM compliance",
|
||||
},
|
||||
},
|
||||
required: ["name", "subject", "from_name", "from_email"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_lists",
|
||||
description: "List all contact lists",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
limit: { type: "number", description: "Results per page (default 50, max 1000)" },
|
||||
include_count: { type: "boolean", description: "Include contact count per list" },
|
||||
include_membership_count: { type: "string", enum: ["all", "active", "unsubscribed"], description: "Which membership counts to include" },
|
||||
cursor: { type: "string", description: "Pagination cursor" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add_to_list",
|
||||
description: "Add one or more contacts to a list",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
list_id: { type: "string", description: "List ID to add contacts to (required)" },
|
||||
contact_ids: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "Array of contact IDs to add (required)",
|
||||
},
|
||||
},
|
||||
required: ["list_id", "contact_ids"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "get_campaign_stats",
|
||||
description: "Get tracking statistics for a campaign (sends, opens, clicks, bounces, etc.)",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
campaign_activity_id: { type: "string", description: "Campaign activity ID (required)" },
|
||||
},
|
||||
required: ["campaign_activity_id"],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// ============================================
|
||||
// TOOL HANDLERS
|
||||
// ============================================
|
||||
async function handleTool(client: ConstantContactClient, name: string, args: any) {
|
||||
switch (name) {
|
||||
case "list_contacts": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.status) params.append("status", args.status);
|
||||
if (args.email) params.append("email", args.email);
|
||||
if (args.lists) params.append("lists", args.lists);
|
||||
if (args.segment_id) params.append("segment_id", args.segment_id);
|
||||
if (args.limit) params.append("limit", args.limit.toString());
|
||||
if (args.include) params.append("include", args.include);
|
||||
if (args.include_count) params.append("include_count", "true");
|
||||
if (args.cursor) params.append("cursor", args.cursor);
|
||||
const query = params.toString();
|
||||
return await client.get(`/contacts${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "add_contact": {
|
||||
const payload: any = {
|
||||
email_address: {
|
||||
address: args.email_address,
|
||||
permission_to_send: "implicit",
|
||||
},
|
||||
};
|
||||
if (args.first_name) payload.first_name = args.first_name;
|
||||
if (args.last_name) payload.last_name = args.last_name;
|
||||
if (args.job_title) payload.job_title = args.job_title;
|
||||
if (args.company_name) payload.company_name = args.company_name;
|
||||
if (args.phone_numbers) payload.phone_numbers = args.phone_numbers;
|
||||
if (args.street_addresses) payload.street_addresses = args.street_addresses;
|
||||
if (args.list_memberships) payload.list_memberships = args.list_memberships;
|
||||
if (args.custom_fields) payload.custom_fields = args.custom_fields;
|
||||
if (args.birthday_month) payload.birthday_month = args.birthday_month;
|
||||
if (args.birthday_day) payload.birthday_day = args.birthday_day;
|
||||
if (args.anniversary) payload.anniversary = args.anniversary;
|
||||
if (args.create_source) payload.create_source = args.create_source;
|
||||
return await client.post("/contacts/sign_up_form", payload);
|
||||
}
|
||||
|
||||
case "list_campaigns": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.limit) params.append("limit", args.limit.toString());
|
||||
if (args.before_date) params.append("before_date", args.before_date);
|
||||
if (args.after_date) params.append("after_date", args.after_date);
|
||||
if (args.cursor) params.append("cursor", args.cursor);
|
||||
const query = params.toString();
|
||||
return await client.get(`/emails${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "create_campaign": {
|
||||
// First create the campaign
|
||||
const campaignPayload: any = {
|
||||
name: args.name,
|
||||
email_campaign_activities: [
|
||||
{
|
||||
format_type: args.format_type || 5,
|
||||
from_name: args.from_name,
|
||||
from_email: args.from_email,
|
||||
reply_to_email: args.reply_to_email || args.from_email,
|
||||
subject: args.subject,
|
||||
html_content: args.html_content || "",
|
||||
text_content: args.text_content || "",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if (args.physical_address_in_footer) {
|
||||
campaignPayload.email_campaign_activities[0].physical_address_in_footer = args.physical_address_in_footer;
|
||||
}
|
||||
|
||||
return await client.post("/emails", campaignPayload);
|
||||
}
|
||||
|
||||
case "list_lists": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.limit) params.append("limit", args.limit.toString());
|
||||
if (args.include_count) params.append("include_count", "true");
|
||||
if (args.include_membership_count) params.append("include_membership_count", args.include_membership_count);
|
||||
if (args.cursor) params.append("cursor", args.cursor);
|
||||
const query = params.toString();
|
||||
return await client.get(`/contact_lists${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "add_to_list": {
|
||||
const { list_id, contact_ids } = args;
|
||||
// Constant Contact uses a specific endpoint for bulk adding to lists
|
||||
const payload = {
|
||||
source: {
|
||||
contact_ids: contact_ids,
|
||||
},
|
||||
list_ids: [list_id],
|
||||
};
|
||||
return await client.post("/activities/add_list_memberships", payload);
|
||||
}
|
||||
|
||||
case "get_campaign_stats": {
|
||||
const { campaign_activity_id } = args;
|
||||
return await client.get(`/reports/email_reports/${campaign_activity_id}/tracking/sends`);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// SERVER SETUP
|
||||
// ============================================
|
||||
async function main() {
|
||||
const accessToken = process.env.CONSTANT_CONTACT_ACCESS_TOKEN;
|
||||
|
||||
if (!accessToken) {
|
||||
console.error("Error: CONSTANT_CONTACT_ACCESS_TOKEN environment variable required");
|
||||
console.error("Get your access token from the Constant Contact V3 API after OAuth2 authorization");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const client = new ConstantContactClient(accessToken);
|
||||
|
||||
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