@x0333/bitrix24-mcp-server 1.0.0 → 2.0.1
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/index.js +265 -0
- package/package.json +8 -28
- package/README.md +0 -330
- package/build/bitrix24/client.d.ts +0 -224
- package/build/bitrix24/client.d.ts.map +0 -1
- package/build/bitrix24/client.js +0 -1098
- package/build/bitrix24/client.js.map +0 -1
- package/build/config/index.d.ts +0 -6
- package/build/config/index.d.ts.map +0 -1
- package/build/config/index.js +0 -8
- package/build/config/index.js.map +0 -1
- package/build/index.d.ts +0 -3
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -56
- package/build/index.js.map +0 -1
- package/build/tools/index.d.ts +0 -67
- package/build/tools/index.d.ts.map +0 -1
- package/build/tools/index.js +0 -1377
- package/build/tools/index.js.map +0 -1
- package/build/utils/logger.d.ts +0 -7
- package/build/utils/logger.d.ts.map +0 -1
- package/build/utils/logger.js +0 -17
- package/build/utils/logger.js.map +0 -1
package/index.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* CLI entry point for the Bitrix24 skill.
|
|
6
|
+
*
|
|
7
|
+
* This version uses axios for HTTP requests and commander for argument parsing.
|
|
8
|
+
* Users can call this binary via `npx bitrix24-skill` once published.
|
|
9
|
+
*
|
|
10
|
+
* Each command prints the JSON response from Bitrix24 to stdout so it can be
|
|
11
|
+
* consumed by downstream tools (including AI models) without additional
|
|
12
|
+
* formatting. If the base URL is not provided via the --base option, the
|
|
13
|
+
* environment variable B24_BASE will be used as a fallback. See README for
|
|
14
|
+
* usage examples.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const axios = require("axios");
|
|
18
|
+
const { Command } = require("commander");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Helper to send a POST request to a Bitrix24 REST method.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} method The name of the method (e.g. "profile", "tasks.task.get").
|
|
24
|
+
* @param {object} body The request payload, encoded as JSON.
|
|
25
|
+
* @param {string} base The base URL of the Bitrix24 webhook (no trailing slash).
|
|
26
|
+
* @returns {Promise<any>} Resolves with the parsed JSON data from the response.
|
|
27
|
+
*/
|
|
28
|
+
async function callBitrix(method, body, base) {
|
|
29
|
+
const baseUrl = (base || process.env.B24_BASE || "").replace(/\/$/, "");
|
|
30
|
+
if (!baseUrl) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"Base URL for Bitrix24 webhook is not set. Use --base option or set B24_BASE environment variable."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const url = `${baseUrl}/${method}`;
|
|
36
|
+
try {
|
|
37
|
+
const response = await axios.post(url, body, {
|
|
38
|
+
headers: { "Content-Type": "application/json" },
|
|
39
|
+
});
|
|
40
|
+
return response.data;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// Rethrow with a human‑readable message
|
|
43
|
+
const msg = err.response
|
|
44
|
+
? `HTTP ${err.response.status}: ${JSON.stringify(err.response.data)}`
|
|
45
|
+
: err.message;
|
|
46
|
+
throw new Error(msg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parse a comma‑separated list into an array. Returns undefined if the input
|
|
52
|
+
* is falsy.
|
|
53
|
+
*
|
|
54
|
+
* @param {string|undefined} value The comma‑separated string.
|
|
55
|
+
*/
|
|
56
|
+
function parseList(value) {
|
|
57
|
+
if (!value) return undefined;
|
|
58
|
+
return value
|
|
59
|
+
.split(/,/) // split on commas
|
|
60
|
+
.map((s) => s.trim())
|
|
61
|
+
.filter((s) => s.length > 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function main() {
|
|
65
|
+
const program = new Command();
|
|
66
|
+
program
|
|
67
|
+
.name("bitrix24-skill")
|
|
68
|
+
.description(
|
|
69
|
+
"CLI for interacting with Bitrix24 via incoming webhook. Provides commands to query profile, tasks, and workgroups."
|
|
70
|
+
)
|
|
71
|
+
.option(
|
|
72
|
+
"--base <base>",
|
|
73
|
+
"Base URL for Bitrix24 webhook (e.g. https://domain.bitrix24.ru/rest/USER_ID/WEBHOOK_CODE). Defaults to environment variable B24_BASE.",
|
|
74
|
+
undefined
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Profile command
|
|
78
|
+
program
|
|
79
|
+
.command("profile")
|
|
80
|
+
.description("Fetch current user profile information")
|
|
81
|
+
.action(async (cmdOptions) => {
|
|
82
|
+
const opts = program.opts();
|
|
83
|
+
const data = await callBitrix("profile", {}, opts.base);
|
|
84
|
+
console.log(JSON.stringify(data, null, 2));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Get task by ID
|
|
88
|
+
program
|
|
89
|
+
.command("get-task")
|
|
90
|
+
.description("Retrieve task details by ID")
|
|
91
|
+
.requiredOption("--id <id>", "Task identifier")
|
|
92
|
+
.option(
|
|
93
|
+
"--select <fields>",
|
|
94
|
+
"Comma‑separated list of fields to select (default '*')",
|
|
95
|
+
undefined
|
|
96
|
+
)
|
|
97
|
+
.action(async (options) => {
|
|
98
|
+
const opts = program.opts();
|
|
99
|
+
const taskId = Number(options.id);
|
|
100
|
+
if (isNaN(taskId)) {
|
|
101
|
+
throw new Error("The --id option must be a number");
|
|
102
|
+
}
|
|
103
|
+
const select = parseList(options.select) || ["*"];
|
|
104
|
+
const body = { taskId, select };
|
|
105
|
+
const data = await callBitrix("tasks.task.get", body, opts.base);
|
|
106
|
+
console.log(JSON.stringify(data, null, 2));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Search tasks by title
|
|
110
|
+
program
|
|
111
|
+
.command("search-task")
|
|
112
|
+
.description("Search tasks by part of the title")
|
|
113
|
+
.requiredOption("--title <title>", "Substring of the task title to search for")
|
|
114
|
+
.option(
|
|
115
|
+
"--select <fields>",
|
|
116
|
+
"Comma‑separated list of fields to select (default ID,TITLE,STATUS,RESPONSIBLE_ID,GROUP_ID,CREATED_DATE,CHANGED_DATE)",
|
|
117
|
+
undefined
|
|
118
|
+
)
|
|
119
|
+
.option(
|
|
120
|
+
"--order <field>",
|
|
121
|
+
"Field to sort by (default: ID)",
|
|
122
|
+
"ID"
|
|
123
|
+
)
|
|
124
|
+
.option(
|
|
125
|
+
"--dir <direction>",
|
|
126
|
+
"Sort direction: asc or desc (default: desc)",
|
|
127
|
+
"desc"
|
|
128
|
+
)
|
|
129
|
+
.option(
|
|
130
|
+
"--start <offset>",
|
|
131
|
+
"Pagination offset (multiple of 50; default 0)",
|
|
132
|
+
(value) => Number(value),
|
|
133
|
+
0
|
|
134
|
+
)
|
|
135
|
+
.action(async (options) => {
|
|
136
|
+
const opts = program.opts();
|
|
137
|
+
const select =
|
|
138
|
+
parseList(options.select) || [
|
|
139
|
+
"ID",
|
|
140
|
+
"TITLE",
|
|
141
|
+
"STATUS",
|
|
142
|
+
"RESPONSIBLE_ID",
|
|
143
|
+
"GROUP_ID",
|
|
144
|
+
"CREATED_DATE",
|
|
145
|
+
"CHANGED_DATE",
|
|
146
|
+
];
|
|
147
|
+
const order = { [options.order]: options.dir.toUpperCase() };
|
|
148
|
+
const body = {
|
|
149
|
+
order,
|
|
150
|
+
filter: { "%TITLE": options.title },
|
|
151
|
+
select,
|
|
152
|
+
start: options.start,
|
|
153
|
+
};
|
|
154
|
+
const data = await callBitrix("tasks.task.list", body, opts.base);
|
|
155
|
+
console.log(JSON.stringify(data, null, 2));
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Search workgroup by name
|
|
159
|
+
program
|
|
160
|
+
.command("search-group")
|
|
161
|
+
.description("Search workgroups/projects by part of the name")
|
|
162
|
+
.requiredOption("--name <name>", "Substring of the group name to search for")
|
|
163
|
+
.option(
|
|
164
|
+
"--select <fields>",
|
|
165
|
+
"Comma‑separated list of fields to select (default ID,NAME,PROJECT,ACTIVE,VISIBLE,CLOSED)",
|
|
166
|
+
undefined
|
|
167
|
+
)
|
|
168
|
+
.option(
|
|
169
|
+
"--order <field>",
|
|
170
|
+
"Field to sort by (default: ID)",
|
|
171
|
+
"ID"
|
|
172
|
+
)
|
|
173
|
+
.option(
|
|
174
|
+
"--dir <direction>",
|
|
175
|
+
"Sort direction: ASC or DESC (default: DESC)",
|
|
176
|
+
"DESC"
|
|
177
|
+
)
|
|
178
|
+
.option(
|
|
179
|
+
"--start <offset>",
|
|
180
|
+
"Pagination offset (multiple of 50; default 0)",
|
|
181
|
+
(value) => Number(value),
|
|
182
|
+
0
|
|
183
|
+
)
|
|
184
|
+
.action(async (options) => {
|
|
185
|
+
const opts = program.opts();
|
|
186
|
+
const select =
|
|
187
|
+
parseList(options.select) || [
|
|
188
|
+
"ID",
|
|
189
|
+
"NAME",
|
|
190
|
+
"PROJECT",
|
|
191
|
+
"ACTIVE",
|
|
192
|
+
"VISIBLE",
|
|
193
|
+
"CLOSED",
|
|
194
|
+
];
|
|
195
|
+
const order = { [options.order]: options.dir.toUpperCase() };
|
|
196
|
+
const body = {
|
|
197
|
+
filter: { "%NAME": options.name },
|
|
198
|
+
select,
|
|
199
|
+
order,
|
|
200
|
+
start: options.start,
|
|
201
|
+
};
|
|
202
|
+
const data = await callBitrix(
|
|
203
|
+
"socialnetwork.api.workgroup.list",
|
|
204
|
+
body,
|
|
205
|
+
opts.base
|
|
206
|
+
);
|
|
207
|
+
console.log(JSON.stringify(data, null, 2));
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Get workgroup by ID
|
|
211
|
+
program
|
|
212
|
+
.command("get-group")
|
|
213
|
+
.description("Retrieve detailed information about a workgroup/project by ID")
|
|
214
|
+
.requiredOption("--id <id>", "Workgroup identifier")
|
|
215
|
+
.option(
|
|
216
|
+
"--select <fields>",
|
|
217
|
+
"Comma‑separated list of fields to select (default includes common fields)",
|
|
218
|
+
undefined
|
|
219
|
+
)
|
|
220
|
+
.action(async (options) => {
|
|
221
|
+
const opts = program.opts();
|
|
222
|
+
const groupId = Number(options.id);
|
|
223
|
+
if (isNaN(groupId)) {
|
|
224
|
+
throw new Error("The --id option must be a number");
|
|
225
|
+
}
|
|
226
|
+
const select =
|
|
227
|
+
parseList(options.select) || [
|
|
228
|
+
"ACTIONS",
|
|
229
|
+
"AVATAR",
|
|
230
|
+
"AVATAR_DATA",
|
|
231
|
+
"COUNTERS",
|
|
232
|
+
"DATE_CREATE",
|
|
233
|
+
"DEPARTMENTS",
|
|
234
|
+
"EFFICIENCY",
|
|
235
|
+
"FEATURES",
|
|
236
|
+
"GROUP_MEMBERS_LIST",
|
|
237
|
+
"LIST_OF_MEMBERS",
|
|
238
|
+
"OWNER_DATA",
|
|
239
|
+
"PRIVACY_TYPE",
|
|
240
|
+
"SUBJECT_DATA",
|
|
241
|
+
"TAGS",
|
|
242
|
+
"USER_DATA",
|
|
243
|
+
];
|
|
244
|
+
const body = { params: { groupId, select } };
|
|
245
|
+
const data = await callBitrix(
|
|
246
|
+
"socialnetwork.api.workgroup.get",
|
|
247
|
+
body,
|
|
248
|
+
opts.base
|
|
249
|
+
);
|
|
250
|
+
console.log(JSON.stringify(data, null, 2));
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// Parse command line arguments. Use async to allow await inside actions.
|
|
254
|
+
try {
|
|
255
|
+
await program.parseAsync(process.argv);
|
|
256
|
+
} catch (err) {
|
|
257
|
+
console.error(err.message || err);
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
main().catch((err) => {
|
|
263
|
+
console.error(err.message || err);
|
|
264
|
+
process.exit(1);
|
|
265
|
+
});
|
package/package.json
CHANGED
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x0333/bitrix24-mcp-server",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"main": "build/index.js",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Bitrix24 MCP Server for AI Agent Integration.",
|
|
5
|
+
"main": "index.js",
|
|
7
6
|
"bin": {
|
|
8
|
-
"bitrix24-
|
|
9
|
-
"bitrix24-mcp": "./build/index.js"
|
|
7
|
+
"bitrix24-skill": "index.js"
|
|
10
8
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"dev": "tsc --watch",
|
|
14
|
-
"start": "node build/index.js",
|
|
15
|
-
"test": "node test/integration.test.js"
|
|
16
|
-
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=18.0.0",
|
|
19
|
-
"npm": ">=8.0.0"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"build",
|
|
23
|
-
"README.md"
|
|
24
|
-
],
|
|
9
|
+
"type": "commonjs",
|
|
10
|
+
"license": "MIT",
|
|
25
11
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"typescript": "^5.3.0",
|
|
29
|
-
"zod": "^3.22.4"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^20.10.0",
|
|
33
|
-
"@types/node-fetch": "^2.6.9"
|
|
12
|
+
"axios": "^1.5.0",
|
|
13
|
+
"commander": "^11.0.0"
|
|
34
14
|
},
|
|
35
15
|
"keywords": [
|
|
36
16
|
"mcp",
|
package/README.md
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
# Bitrix24 MCP Server
|
|
2
|
-
|
|
3
|
-
A comprehensive Model Context Protocol (MCP) server for Bitrix24 CRM integration, enabling AI agents to seamlessly interact with your Bitrix24 instance through a powerful set of tools.
|
|
4
|
-
|
|
5
|
-
## 🚀 Features
|
|
6
|
-
|
|
7
|
-
- **Complete CRM Management**: Create, read, update, and list contacts, deals, and tasks
|
|
8
|
-
- **Advanced Search**: Search across all CRM entities with flexible filtering
|
|
9
|
-
- **Rate Limiting**: Built-in rate limiting to respect Bitrix24 API limits
|
|
10
|
-
- **Type Safety**: Full TypeScript implementation with comprehensive type definitions
|
|
11
|
-
- **Error Handling**: Robust error handling and validation
|
|
12
|
-
- **Easy Integration**: Simple setup with Claude Desktop and other MCP-compatible clients
|
|
13
|
-
|
|
14
|
-
## 📋 Available Tools
|
|
15
|
-
|
|
16
|
-
### Contact Management
|
|
17
|
-
- `bitrix24_create_contact` - Create new contacts
|
|
18
|
-
- `bitrix24_get_contact` - Retrieve contact by ID
|
|
19
|
-
- `bitrix24_list_contacts` - List contacts with filtering
|
|
20
|
-
- `bitrix24_update_contact` - Update existing contacts
|
|
21
|
-
|
|
22
|
-
### Deal Management
|
|
23
|
-
- `bitrix24_create_deal` - Create new deals
|
|
24
|
-
- `bitrix24_get_deal` - Retrieve deal by ID
|
|
25
|
-
- `bitrix24_list_deals` - List deals with filtering
|
|
26
|
-
- `bitrix24_update_deal` - Update existing deals
|
|
27
|
-
|
|
28
|
-
### Task Management
|
|
29
|
-
- `bitrix24_create_task` - Create new tasks
|
|
30
|
-
- `bitrix24_get_task` - Retrieve task by ID
|
|
31
|
-
- `bitrix24_list_tasks` - List tasks with filtering
|
|
32
|
-
- `bitrix24_update_task` - Update existing tasks
|
|
33
|
-
|
|
34
|
-
### User Management
|
|
35
|
-
- `bitrix24_get_user` - Get user information by ID
|
|
36
|
-
- `bitrix24_get_all_users` - Get all users in the system with names and details
|
|
37
|
-
- `bitrix24_resolve_user_names` - Resolve user IDs to user names
|
|
38
|
-
- `bitrix24_get_contacts_with_user_names` - Get contacts with user names resolved
|
|
39
|
-
- `bitrix24_get_deals_with_user_names` - Get deals with user names resolved
|
|
40
|
-
- `bitrix24_get_leads_with_user_names` - Get leads with user names resolved
|
|
41
|
-
- `bitrix24_get_companies_with_user_names` - Get companies with user names resolved
|
|
42
|
-
|
|
43
|
-
### Lead Management
|
|
44
|
-
- `bitrix24_create_lead` - Create new leads
|
|
45
|
-
- `bitrix24_get_lead` - Retrieve lead by ID
|
|
46
|
-
- `bitrix24_list_leads` - List leads with filtering
|
|
47
|
-
- `bitrix24_get_latest_leads` - Get most recent leads
|
|
48
|
-
- `bitrix24_get_leads_from_date_range` - Get leads from specific date range
|
|
49
|
-
- `bitrix24_update_lead` - Update existing leads
|
|
50
|
-
|
|
51
|
-
### Company Management
|
|
52
|
-
- `bitrix24_create_company` - Create new companies
|
|
53
|
-
- `bitrix24_get_company` - Retrieve company by ID
|
|
54
|
-
- `bitrix24_list_companies` - List companies with filtering
|
|
55
|
-
- `bitrix24_get_latest_companies` - Get most recent companies
|
|
56
|
-
- `bitrix24_get_companies_from_date_range` - Get companies from specific date range
|
|
57
|
-
- `bitrix24_update_company` - Update existing companies
|
|
58
|
-
|
|
59
|
-
### Enhanced Deal Filtering
|
|
60
|
-
- `bitrix24_get_deal_pipelines` - Get all deal pipelines/categories
|
|
61
|
-
- `bitrix24_get_deal_stages` - Get deal stages for pipelines
|
|
62
|
-
- `bitrix24_filter_deals_by_pipeline` - Filter deals by pipeline
|
|
63
|
-
- `bitrix24_filter_deals_by_budget` - Filter deals by budget range
|
|
64
|
-
- `bitrix24_filter_deals_by_status` - Filter deals by stage/status
|
|
65
|
-
|
|
66
|
-
### Utilities
|
|
67
|
-
- `bitrix24_search_crm` - Search across CRM entities
|
|
68
|
-
- `bitrix24_get_current_user` - Get current user info
|
|
69
|
-
- `bitrix24_validate_webhook` - Validate webhook connection
|
|
70
|
-
- `bitrix24_diagnose_permissions` - Diagnose webhook permissions
|
|
71
|
-
- `bitrix24_check_crm_settings` - Check CRM settings and configuration
|
|
72
|
-
- `bitrix24_test_leads_api` - Test leads API endpoints
|
|
73
|
-
|
|
74
|
-
### Sales Team Monitoring
|
|
75
|
-
- `bitrix24_monitor_user_activities` - Monitor user activities (calls, emails, timeline interactions, response times)
|
|
76
|
-
- `bitrix24_get_user_performance_summary` - Get comprehensive performance summary with deal metrics and conversion rates
|
|
77
|
-
- `bitrix24_analyze_account_performance` - Analyze performance for specific accounts (companies/contacts)
|
|
78
|
-
- `bitrix24_compare_user_performance` - Compare performance metrics between multiple users
|
|
79
|
-
- `bitrix24_track_deal_progression` - Track deal progression through pipeline stages with timing analysis
|
|
80
|
-
- `bitrix24_monitor_sales_activities` - Monitor sales-related activities (tasks, follow-ups, meetings)
|
|
81
|
-
- `bitrix24_generate_sales_report` - Generate comprehensive sales reports with customizable metrics
|
|
82
|
-
- `bitrix24_get_team_dashboard` - Get real-time team performance dashboard
|
|
83
|
-
- `bitrix24_analyze_customer_engagement` - Analyze customer engagement patterns and relationship health
|
|
84
|
-
- `bitrix24_forecast_performance` - Generate performance forecasts and predictive analytics
|
|
85
|
-
|
|
86
|
-
## 🛠️ Installation
|
|
87
|
-
|
|
88
|
-
### Prerequisites
|
|
89
|
-
- Node.js 18+
|
|
90
|
-
- npm or yarn
|
|
91
|
-
- Bitrix24 webhook URL
|
|
92
|
-
|
|
93
|
-
### Setup
|
|
94
|
-
|
|
95
|
-
1. **Clone and install dependencies:**
|
|
96
|
-
```bash
|
|
97
|
-
git clone <repository-url>
|
|
98
|
-
cd bitrix24-mcp-server
|
|
99
|
-
npm install
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
2. **Configure environment:**
|
|
103
|
-
```bash
|
|
104
|
-
cp .env.example .env
|
|
105
|
-
# Edit .env with your Bitrix24 webhook URL
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
3. **Build the project:**
|
|
109
|
-
```bash
|
|
110
|
-
npm run build
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
4. **Test the connection:**
|
|
114
|
-
```bash
|
|
115
|
-
npm test
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## ⚙️ Configuration
|
|
119
|
-
|
|
120
|
-
### Environment Variables
|
|
121
|
-
|
|
122
|
-
Create a `.env` file with the following variables:
|
|
123
|
-
|
|
124
|
-
```env
|
|
125
|
-
BITRIX24_WEBHOOK_URL=https://your-domain.bitrix24.com/rest/USER_ID/WEBHOOK_CODE/
|
|
126
|
-
NODE_ENV=development
|
|
127
|
-
LOG_LEVEL=info
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Bitrix24 Webhook Setup
|
|
131
|
-
|
|
132
|
-
1. Go to your Bitrix24 instance
|
|
133
|
-
2. Navigate to **Applications** → **Webhooks**
|
|
134
|
-
3. Create an **Incoming webhook**
|
|
135
|
-
4. Copy the webhook URL (format: `https://domain.bitrix24.com/rest/USER_ID/WEBHOOK_CODE/`)
|
|
136
|
-
5. Set appropriate permissions for CRM and Tasks
|
|
137
|
-
|
|
138
|
-
## 🔧 Claude Desktop Integration
|
|
139
|
-
|
|
140
|
-
Add the following to your Claude Desktop configuration file:
|
|
141
|
-
|
|
142
|
-
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
143
|
-
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
144
|
-
|
|
145
|
-
```json
|
|
146
|
-
{
|
|
147
|
-
"mcpServers": {
|
|
148
|
-
"bitrix24": {
|
|
149
|
-
"command": "node",
|
|
150
|
-
"args": ["/path/to/your/bitrix24-mcp-server/build/index.js"],
|
|
151
|
-
"env": {
|
|
152
|
-
"BITRIX24_WEBHOOK_URL": "https://your-domain.bitrix24.com/rest/USER_ID/WEBHOOK_CODE/"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## 📖 Usage Examples
|
|
160
|
-
|
|
161
|
-
### Creating a Contact
|
|
162
|
-
```
|
|
163
|
-
Create a new contact named John Smith with email john@example.com and phone +39 123 456 789
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Creating a Deal with Contact
|
|
167
|
-
```
|
|
168
|
-
Create a new contact for Maria Rossi with email maria@company.com, then create a deal titled "Website Development Project" for €5000 and link it to this contact
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Managing Tasks
|
|
172
|
-
```
|
|
173
|
-
Create a task titled "Follow up with client" with high priority, deadline tomorrow, and link it to contact ID 123
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Searching CRM
|
|
177
|
-
```
|
|
178
|
-
Search for all contacts and deals related to "example.com"
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## 🏗️ Development
|
|
182
|
-
|
|
183
|
-
### Project Structure
|
|
184
|
-
```
|
|
185
|
-
bitrix24-mcp-server/
|
|
186
|
-
├── src/
|
|
187
|
-
│ ├── bitrix24/
|
|
188
|
-
│ │ └── client.ts # Bitrix24 API client
|
|
189
|
-
│ ├── tools/
|
|
190
|
-
│ │ └── index.ts # MCP tools definitions
|
|
191
|
-
│ ├── utils/
|
|
192
|
-
│ │ └── logger.ts # Logging utilities
|
|
193
|
-
│ ├── config/
|
|
194
|
-
│ │ └── index.ts # Configuration management
|
|
195
|
-
│ └── index.ts # Main MCP server
|
|
196
|
-
├── test/
|
|
197
|
-
│ └── integration.test.js # Integration tests
|
|
198
|
-
├── build/ # Compiled JavaScript
|
|
199
|
-
├── package.json
|
|
200
|
-
├── tsconfig.json
|
|
201
|
-
└── README.md
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Development Commands
|
|
205
|
-
```bash
|
|
206
|
-
# Install dependencies
|
|
207
|
-
npm install
|
|
208
|
-
|
|
209
|
-
# Build the project
|
|
210
|
-
npm run build
|
|
211
|
-
|
|
212
|
-
# Watch mode for development
|
|
213
|
-
npm run dev
|
|
214
|
-
|
|
215
|
-
# Run tests
|
|
216
|
-
npm test
|
|
217
|
-
|
|
218
|
-
# Start the server
|
|
219
|
-
npm start
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Adding New Tools
|
|
223
|
-
|
|
224
|
-
1. Define the tool in `src/tools/index.ts`:
|
|
225
|
-
```typescript
|
|
226
|
-
export const newTool: Tool = {
|
|
227
|
-
name: 'bitrix24_new_action',
|
|
228
|
-
description: 'Description of the new action',
|
|
229
|
-
inputSchema: {
|
|
230
|
-
type: 'object',
|
|
231
|
-
properties: {
|
|
232
|
-
// Define parameters
|
|
233
|
-
},
|
|
234
|
-
required: ['requiredParam']
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
2. Add the execution handler:
|
|
240
|
-
```typescript
|
|
241
|
-
case 'bitrix24_new_action':
|
|
242
|
-
// Implementation
|
|
243
|
-
return { success: true, result: 'Action completed' };
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
3. Add to `allTools` array and rebuild.
|
|
247
|
-
|
|
248
|
-
## 🔒 Security Considerations
|
|
249
|
-
|
|
250
|
-
- **Webhook Security**: Keep your webhook URL secret and rotate it regularly
|
|
251
|
-
- **Environment Variables**: Never commit `.env` files to version control
|
|
252
|
-
- **Rate Limiting**: The client includes built-in rate limiting (2 requests/second)
|
|
253
|
-
- **Error Handling**: Sensitive information is not exposed in error messages
|
|
254
|
-
|
|
255
|
-
## 🐛 Troubleshooting
|
|
256
|
-
|
|
257
|
-
### Common Issues
|
|
258
|
-
|
|
259
|
-
**"Webhook validation failed"**
|
|
260
|
-
- Verify your webhook URL is correct
|
|
261
|
-
- Check that the webhook has appropriate permissions
|
|
262
|
-
- Ensure your Bitrix24 instance is accessible
|
|
263
|
-
|
|
264
|
-
**"Cannot find module" errors**
|
|
265
|
-
- Run `npm install` to install dependencies
|
|
266
|
-
- Ensure you've built the project with `npm run build`
|
|
267
|
-
|
|
268
|
-
**Rate limiting errors**
|
|
269
|
-
- The client automatically handles rate limiting
|
|
270
|
-
- If you see persistent rate limit errors, consider reducing request frequency
|
|
271
|
-
|
|
272
|
-
### Debug Mode
|
|
273
|
-
Set `NODE_ENV=development` and `LOG_LEVEL=debug` in your `.env` file for detailed logging.
|
|
274
|
-
|
|
275
|
-
## 📝 API Reference
|
|
276
|
-
|
|
277
|
-
### Bitrix24Client Methods
|
|
278
|
-
|
|
279
|
-
#### Contacts
|
|
280
|
-
- `createContact(contact: BitrixContact): Promise<string>`
|
|
281
|
-
- `getContact(id: string): Promise<BitrixContact>`
|
|
282
|
-
- `updateContact(id: string, contact: Partial<BitrixContact>): Promise<boolean>`
|
|
283
|
-
- `listContacts(params?: ListParams): Promise<BitrixContact[]>`
|
|
284
|
-
|
|
285
|
-
#### Deals
|
|
286
|
-
- `createDeal(deal: BitrixDeal): Promise<string>`
|
|
287
|
-
- `getDeal(id: string): Promise<BitrixDeal>`
|
|
288
|
-
- `updateDeal(id: string, deal: Partial<BitrixDeal>): Promise<boolean>`
|
|
289
|
-
- `listDeals(params?: ListParams): Promise<BitrixDeal[]>`
|
|
290
|
-
|
|
291
|
-
#### Tasks
|
|
292
|
-
- `createTask(task: BitrixTask): Promise<string>`
|
|
293
|
-
- `getTask(id: string): Promise<BitrixTask>`
|
|
294
|
-
- `updateTask(id: string, task: Partial<BitrixTask>): Promise<boolean>`
|
|
295
|
-
- `listTasks(params?: TaskListParams): Promise<BitrixTask[]>`
|
|
296
|
-
|
|
297
|
-
#### Users
|
|
298
|
-
- `getUser(userId: string): Promise<any>`
|
|
299
|
-
- `getAllUsers(): Promise<any[]>`
|
|
300
|
-
- `getUsersByIds(userIds: string[]): Promise<any[]>`
|
|
301
|
-
- `resolveUserNames(userIds: string[]): Promise<Record<string, string>>`
|
|
302
|
-
- `enhanceWithUserNames<T>(items: T[], userIdFields?: string[]): Promise<T[]>`
|
|
303
|
-
|
|
304
|
-
#### Utilities
|
|
305
|
-
- `getCurrentUser(): Promise<any>`
|
|
306
|
-
- `searchCRM(query: string, entityTypes?: string[]): Promise<any>`
|
|
307
|
-
- `validateWebhook(): Promise<boolean>`
|
|
308
|
-
|
|
309
|
-
## 🤝 Contributing
|
|
310
|
-
|
|
311
|
-
1. Fork the repository
|
|
312
|
-
2. Create a feature branch
|
|
313
|
-
3. Make your changes
|
|
314
|
-
4. Add tests if applicable
|
|
315
|
-
5. Submit a pull request
|
|
316
|
-
|
|
317
|
-
## 📄 License
|
|
318
|
-
|
|
319
|
-
MIT License - see LICENSE file for details.
|
|
320
|
-
|
|
321
|
-
## 🆘 Support
|
|
322
|
-
|
|
323
|
-
For issues and questions:
|
|
324
|
-
1. Check the troubleshooting section
|
|
325
|
-
2. Review Bitrix24 API documentation
|
|
326
|
-
3. Open an issue on GitHub
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
**Built with ❤️ for the AI automation community**
|