@pipeworx/mcp-activecampaign 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # mcp-activecampaign
2
+
3
+ ActiveCampaign MCP Pack — email marketing + CRM (API v3).
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "activecampaign": {
20
+ "url": "https://gateway.pipeworx.io/activecampaign/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Activecampaign data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-activecampaign",
3
+ "version": "0.1.0",
4
+ "description": "ActiveCampaign MCP Pack — email marketing + CRM (API v3).",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "activecampaign"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-activecampaign"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/activecampaign",
4
+ "title": "Activecampaign",
5
+ "description": "ActiveCampaign MCP Pack — email marketing + CRM (API v3).",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/activecampaign",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-activecampaign",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/activecampaign/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,212 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * ActiveCampaign MCP Pack — email marketing + CRM (API v3).
21
+ *
22
+ * BYO SaaS connector: every tool requires TWO credentials.
23
+ * - _apiKey: the account's API key (ActiveCampaign UI: Settings → Developer).
24
+ * Sent as the `Api-Token` header.
25
+ * - account: the user's ActiveCampaign account URL or subdomain, e.g.
26
+ * "https://youraccount.api-us1.com" or just "youraccount".
27
+ * Normalized to https://{account}.api-us1.com if no scheme given.
28
+ *
29
+ * Stateless — no auth/rate-limit logic here (the gateway handles that).
30
+ * Tools: list_contacts, get_contact, list_deals, list_campaigns,
31
+ * list_lists, list_automations.
32
+ */
33
+
34
+
35
+ const UA = 'pipeworx-mcp-activecampaign/1.0 (+https://pipeworx.io)';
36
+
37
+ /** Build the API v3 base URL from a raw account URL or bare subdomain. */
38
+ function baseUrl(account: string): string {
39
+ let a = account.trim();
40
+ if (!/^https?:\/\//i.test(a)) a = `https://${a}.api-us1.com`;
41
+ a = a.replace(/\/+$/, ''); // strip trailing slash(es)
42
+ return `${a}/api/3`;
43
+ }
44
+
45
+ async function acGet(
46
+ apiKey: string,
47
+ account: string,
48
+ path: string,
49
+ params?: URLSearchParams,
50
+ ): Promise<unknown> {
51
+ const qs = params?.toString();
52
+ const url = `${baseUrl(account)}${path}${qs ? `?${qs}` : ''}`;
53
+ const res = await fetch(url, {
54
+ headers: {
55
+ 'Api-Token': apiKey,
56
+ Accept: 'application/json',
57
+ 'User-Agent': UA,
58
+ },
59
+ });
60
+ if (!res.ok) {
61
+ const body = await res.text();
62
+ throw new Error(`ActiveCampaign: ${res.status} ${body.slice(0, 200)}`);
63
+ }
64
+ return res.json();
65
+ }
66
+
67
+ /** Shared credential properties — present (and required) on every tool. */
68
+ const CREDS = {
69
+ _apiKey: {
70
+ type: 'string',
71
+ description: 'ActiveCampaign API key (UI: Settings → Developer).',
72
+ },
73
+ account: {
74
+ type: 'string',
75
+ description:
76
+ 'Your ActiveCampaign account URL or subdomain, e.g. "https://youraccount.api-us1.com" or just "youraccount".',
77
+ },
78
+ } as const;
79
+
80
+ const tools: McpToolExport['tools'] = [
81
+ {
82
+ name: 'list_contacts',
83
+ description:
84
+ 'List/search contacts (subscribers) in an ActiveCampaign account. Filter by exact email or a free-text search across name/email. Returns contacts with IDs, emails, names, and meta.total.',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {
88
+ ...CREDS,
89
+ email: { type: 'string', description: 'Filter to an exact email address.' },
90
+ search: { type: 'string', description: 'Free-text search across name and email.' },
91
+ limit: { type: 'number', description: 'Max results (default 20, max 100).' },
92
+ },
93
+ required: ['_apiKey', 'account'],
94
+ },
95
+ },
96
+ {
97
+ name: 'get_contact',
98
+ description:
99
+ 'Get a single contact by ID. Returns email, name, phone, custom field values, and engagement details.',
100
+ inputSchema: {
101
+ type: 'object',
102
+ properties: {
103
+ ...CREDS,
104
+ id: { type: 'string', description: 'ActiveCampaign contact ID.' },
105
+ },
106
+ required: ['_apiKey', 'account', 'id'],
107
+ },
108
+ },
109
+ {
110
+ name: 'list_deals',
111
+ description:
112
+ 'List CRM deals (sales pipeline opportunities). Returns deal IDs, titles, values, stages, and owners with meta.total.',
113
+ inputSchema: {
114
+ type: 'object',
115
+ properties: {
116
+ ...CREDS,
117
+ limit: { type: 'number', description: 'Max results (default 20, max 100).' },
118
+ },
119
+ required: ['_apiKey', 'account'],
120
+ },
121
+ },
122
+ {
123
+ name: 'list_campaigns',
124
+ description:
125
+ 'List email campaigns with send/open/click metrics. Returns campaign IDs, names, status, send dates, and aggregate stats.',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ ...CREDS,
130
+ limit: { type: 'number', description: 'Max results (default 20, max 100).' },
131
+ },
132
+ required: ['_apiKey', 'account'],
133
+ },
134
+ },
135
+ {
136
+ name: 'list_lists',
137
+ description:
138
+ 'List contact lists. Returns list IDs, names, subscriber counts, and creation dates.',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ ...CREDS,
143
+ limit: { type: 'number', description: 'Max results (default 20, max 100).' },
144
+ },
145
+ required: ['_apiKey', 'account'],
146
+ },
147
+ },
148
+ {
149
+ name: 'list_automations',
150
+ description:
151
+ 'List marketing automations (workflows). Returns automation IDs, names, status, and enrolled-contact counts.',
152
+ inputSchema: {
153
+ type: 'object',
154
+ properties: {
155
+ ...CREDS,
156
+ limit: { type: 'number', description: 'Max results (default 20, max 100).' },
157
+ },
158
+ required: ['_apiKey', 'account'],
159
+ },
160
+ },
161
+ ];
162
+
163
+ function clampLimit(args: Record<string, unknown>, params: URLSearchParams): void {
164
+ if (args.limit != null) params.set('limit', String(Math.min(100, Math.max(1, Number(args.limit)))));
165
+ }
166
+
167
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
168
+ const apiKey = args._apiKey as string | undefined;
169
+ const account = args.account as string | undefined;
170
+ delete args._context;
171
+ delete args._apiKey;
172
+ delete args.account;
173
+
174
+ if (!apiKey) throw new Error('_apiKey is required: your ActiveCampaign API key (Settings → Developer).');
175
+ if (!account) throw new Error('account is required: your ActiveCampaign account URL or subdomain (e.g. "youraccount" or "https://youraccount.api-us1.com").');
176
+
177
+ switch (name) {
178
+ case 'list_contacts': {
179
+ const params = new URLSearchParams();
180
+ if (args.email) params.set('email', args.email as string);
181
+ if (args.search) params.set('search', args.search as string);
182
+ clampLimit(args, params);
183
+ return acGet(apiKey, account, '/contacts', params);
184
+ }
185
+ case 'get_contact':
186
+ return acGet(apiKey, account, `/contacts/${encodeURIComponent(args.id as string)}`);
187
+ case 'list_deals': {
188
+ const params = new URLSearchParams();
189
+ clampLimit(args, params);
190
+ return acGet(apiKey, account, '/deals', params);
191
+ }
192
+ case 'list_campaigns': {
193
+ const params = new URLSearchParams();
194
+ clampLimit(args, params);
195
+ return acGet(apiKey, account, '/campaigns', params);
196
+ }
197
+ case 'list_lists': {
198
+ const params = new URLSearchParams();
199
+ clampLimit(args, params);
200
+ return acGet(apiKey, account, '/lists', params);
201
+ }
202
+ case 'list_automations': {
203
+ const params = new URLSearchParams();
204
+ clampLimit(args, params);
205
+ return acGet(apiKey, account, '/automations', params);
206
+ }
207
+ default:
208
+ throw new Error(`Unknown tool: ${name}`);
209
+ }
210
+ }
211
+
212
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }