@pipeworx/mcp-leadconnector 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-leadconnector
2
+
3
+ LeadConnector / GoHighLevel MCP Pack — wraps the GoHighLevel CRM for AI agents.
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
+ "leadconnector": {
20
+ "url": "https://gateway.pipeworx.io/leadconnector/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 Leadconnector 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-leadconnector",
3
+ "version": "0.1.0",
4
+ "description": "LeadConnector / GoHighLevel MCP Pack — wraps the GoHighLevel CRM for AI agents.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "leadconnector"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-leadconnector"
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/leadconnector",
4
+ "title": "Leadconnector",
5
+ "description": "LeadConnector / GoHighLevel MCP Pack — wraps the GoHighLevel CRM for AI agents.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/leadconnector",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-leadconnector",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/leadconnector/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,163 @@
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
+ * LeadConnector / GoHighLevel MCP Pack — wraps the GoHighLevel CRM for AI agents.
21
+ *
22
+ * BYO key: pass _apiKey on every call. This is a GoHighLevel/LeadConnector
23
+ * **Location API key** (in the dashboard: Settings → Business Profile → API Key).
24
+ * It is a single static bearer token scoped to one Location (sub-account).
25
+ *
26
+ * API: GoHighLevel v1 REST API — base https://rest.gohighlevel.com/v1
27
+ * Auth: `Authorization: Bearer ${apiKey}`.
28
+ * Quirks:
29
+ * - Collection responses are wrapped, e.g. {contacts:[...], meta:{...}},
30
+ * {pipelines:[...]}, {campaigns:[...]}.
31
+ * - Opportunities are nested under a pipeline: /pipelines/{pipelineId}/opportunities/
32
+ * (there is no top-level /opportunities/ in v1 — it 404s), so list_opportunities
33
+ * requires a pipelineId (fetch one first via list_pipelines).
34
+ * - A missing/invalid key returns HTTP 401 {"msg":"Api key is invalid."}.
35
+ * - v1 /users/ is deprecated for Location keys (401 "Switch to the new API token"),
36
+ * so no users tool is exposed.
37
+ */
38
+
39
+
40
+ const API = 'https://rest.gohighlevel.com/v1';
41
+
42
+ function headers(apiKey: string): Record<string, string> {
43
+ return {
44
+ Authorization: `Bearer ${apiKey}`,
45
+ Accept: 'application/json',
46
+ 'User-Agent': 'pipeworx-mcp-leadconnector/1.0 (+https://pipeworx.io)',
47
+ };
48
+ }
49
+
50
+ async function lcGet(apiKey: string, path: string, params?: URLSearchParams): Promise<unknown> {
51
+ const qs = params?.toString();
52
+ const url = `${API}${path}${qs ? `?${qs}` : ''}`;
53
+ const res = await fetch(url, { headers: headers(apiKey) });
54
+ if (!res.ok) {
55
+ const body = await res.text();
56
+ throw new Error(`LeadConnector: ${res.status} ${body.slice(0, 200)}`);
57
+ }
58
+ return res.json();
59
+ }
60
+
61
+ // -- Tool definitions --------------------------------------------------------
62
+
63
+ const tools: McpToolExport['tools'] = [
64
+ {
65
+ name: 'leadconnector_list_contacts',
66
+ description:
67
+ 'Search or list CRM contacts in a GoHighLevel/LeadConnector account. Free-text query matches name, email, or phone. Returns a {contacts:[...], meta} envelope with contact IDs, names, emails, phones, tags, and custom fields.',
68
+ inputSchema: {
69
+ type: 'object' as const,
70
+ properties: {
71
+ _apiKey: { type: 'string', description: 'GoHighLevel/LeadConnector Location API key (Settings → Business Profile → API Key)' },
72
+ query: { type: 'string', description: 'Free-text search across contact name, email, and phone' },
73
+ limit: { type: 'number', description: 'Max contacts to return (default 20, max 100)' },
74
+ },
75
+ required: ['_apiKey'],
76
+ },
77
+ },
78
+ {
79
+ name: 'leadconnector_get_contact',
80
+ description:
81
+ 'Fetch a single CRM contact by its contact ID. Returns full detail: name, email, phone, tags, source, custom fields, and timestamps.',
82
+ inputSchema: {
83
+ type: 'object' as const,
84
+ properties: {
85
+ _apiKey: { type: 'string', description: 'GoHighLevel/LeadConnector Location API key' },
86
+ contactId: { type: 'string', description: 'GoHighLevel contact ID' },
87
+ },
88
+ required: ['_apiKey', 'contactId'],
89
+ },
90
+ },
91
+ {
92
+ name: 'leadconnector_list_pipelines',
93
+ description:
94
+ 'List all sales pipelines and their stages in the account. Returns a {pipelines:[...]} envelope with pipeline IDs, names, and ordered stages. Use the returned pipeline ID with leadconnector_list_opportunities.',
95
+ inputSchema: {
96
+ type: 'object' as const,
97
+ properties: {
98
+ _apiKey: { type: 'string', description: 'GoHighLevel/LeadConnector Location API key' },
99
+ },
100
+ required: ['_apiKey'],
101
+ },
102
+ },
103
+ {
104
+ name: 'leadconnector_list_opportunities',
105
+ description:
106
+ 'List opportunities (pipeline deals) for a given pipeline. Requires a pipelineId (get one from leadconnector_list_pipelines). Returns deals with monetary value, stage, status, and the associated contact.',
107
+ inputSchema: {
108
+ type: 'object' as const,
109
+ properties: {
110
+ _apiKey: { type: 'string', description: 'GoHighLevel/LeadConnector Location API key' },
111
+ pipelineId: { type: 'string', description: 'Pipeline ID to list opportunities for (from leadconnector_list_pipelines)' },
112
+ limit: { type: 'number', description: 'Max opportunities to return (default 20, max 100)' },
113
+ },
114
+ required: ['_apiKey', 'pipelineId'],
115
+ },
116
+ },
117
+ {
118
+ name: 'leadconnector_list_campaigns',
119
+ description:
120
+ 'List marketing/automation campaigns in the account. Returns a {campaigns:[...]} envelope with campaign IDs, names, and status. Useful for finding a campaign to attribute or enroll contacts.',
121
+ inputSchema: {
122
+ type: 'object' as const,
123
+ properties: {
124
+ _apiKey: { type: 'string', description: 'GoHighLevel/LeadConnector Location API key' },
125
+ },
126
+ required: ['_apiKey'],
127
+ },
128
+ },
129
+ ];
130
+
131
+ // -- callTool dispatcher -----------------------------------------------------
132
+
133
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
134
+ const apiKey = args._apiKey as string | undefined;
135
+ delete args._context;
136
+ delete args._apiKey;
137
+
138
+ if (!apiKey) throw new Error('_apiKey is required for LeadConnector/GoHighLevel API access');
139
+
140
+ switch (name) {
141
+ case 'leadconnector_list_contacts': {
142
+ const params = new URLSearchParams();
143
+ if (args.query) params.set('query', String(args.query));
144
+ if (args.limit) params.set('limit', String(Math.min(100, Number(args.limit))));
145
+ return lcGet(apiKey, '/contacts/', params);
146
+ }
147
+ case 'leadconnector_get_contact':
148
+ return lcGet(apiKey, `/contacts/${encodeURIComponent(String(args.contactId))}`);
149
+ case 'leadconnector_list_pipelines':
150
+ return lcGet(apiKey, '/pipelines/');
151
+ case 'leadconnector_list_opportunities': {
152
+ const params = new URLSearchParams();
153
+ if (args.limit) params.set('limit', String(Math.min(100, Number(args.limit))));
154
+ return lcGet(apiKey, `/pipelines/${encodeURIComponent(String(args.pipelineId))}/opportunities/`, params);
155
+ }
156
+ case 'leadconnector_list_campaigns':
157
+ return lcGet(apiKey, '/campaigns/');
158
+ default:
159
+ throw new Error(`Unknown tool: ${name}`);
160
+ }
161
+ }
162
+
163
+ 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
+ }