@x0333/bitrix24-mcp-server 1.0.1 → 2.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/README.md +24 -302
- package/index.js +197 -0
- package/package.json +8 -29
- package/build/bitrix24/client.d.ts +0 -224
- package/build/bitrix24/client.d.ts.map +0 -1
- package/build/bitrix24/client.js +0 -1100
- 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/README.md
CHANGED
|
@@ -1,330 +1,52 @@
|
|
|
1
1
|
# Bitrix24 MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a Model Context Protocol (MCP) server that provides tools for interacting with Bitrix24 via incoming webhooks. It allows AI agents (like Manus, Claude Desktop, etc.) to manage tasks, search for groups, and view user profiles.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **Easy Integration**: Simple setup with Claude Desktop and other MCP-compatible clients
|
|
7
|
+
- **get_profile**: Fetch current user profile information.
|
|
8
|
+
- **get_task**: Retrieve detailed information about a specific task by ID.
|
|
9
|
+
- **search_tasks**: Search for tasks by title with sorting and pagination.
|
|
10
|
+
- **get_group**: Get detailed information about a workgroup or project.
|
|
11
|
+
- **search_groups**: Search for workgroups or projects by name.
|
|
13
12
|
|
|
14
|
-
##
|
|
13
|
+
## Installation
|
|
15
14
|
|
|
16
|
-
|
|
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
|
|
15
|
+
You can run this server directly using `npx`:
|
|
21
16
|
|
|
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
17
|
```bash
|
|
115
|
-
|
|
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
|
|
18
|
+
npx -y @x0333/bitrix24-mcp-server
|
|
128
19
|
```
|
|
129
20
|
|
|
130
|
-
|
|
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
|
|
21
|
+
## Configuration
|
|
137
22
|
|
|
138
|
-
|
|
23
|
+
The server requires a Bitrix24 incoming webhook URL. You must set the `B24_BASE` environment variable.
|
|
139
24
|
|
|
140
|
-
|
|
25
|
+
### Example for Manus / Claude Desktop
|
|
141
26
|
|
|
142
|
-
|
|
143
|
-
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
27
|
+
Add this to your configuration:
|
|
144
28
|
|
|
145
29
|
```json
|
|
146
30
|
{
|
|
147
31
|
"mcpServers": {
|
|
148
32
|
"bitrix24": {
|
|
149
|
-
"command": "
|
|
150
|
-
"args": ["/
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@x0333/bitrix24-mcp-server"],
|
|
151
35
|
"env": {
|
|
152
|
-
"
|
|
36
|
+
"B24_BASE": "https://your-domain.bitrix24.ru/rest/USER_ID/WEBHOOK_CODE/"
|
|
153
37
|
}
|
|
154
38
|
}
|
|
155
39
|
}
|
|
156
40
|
}
|
|
157
41
|
```
|
|
158
42
|
|
|
159
|
-
##
|
|
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
|
|
43
|
+
## How to get Webhook URL
|
|
322
44
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
45
|
+
1. Go to your Bitrix24 portal.
|
|
46
|
+
2. Navigate to **Developer Resources** -> **Other** -> **Inbound Webhook**.
|
|
47
|
+
3. Select the required permissions (Tasks, Social Network, User).
|
|
48
|
+
4. Copy the **URL for REST API call** (it should look like `https://domain.bitrix24.ru/rest/1/abcdef12345/`).
|
|
327
49
|
|
|
328
|
-
|
|
50
|
+
## License
|
|
329
51
|
|
|
330
|
-
|
|
52
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const {
|
|
7
|
+
CallToolRequestSchema,
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
|
+
} = require("@modelcontextprotocol/sdk/types.js");
|
|
10
|
+
const axios = require("axios");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Bitrix24 MCP Server
|
|
14
|
+
*
|
|
15
|
+
* This server implements the Model Context Protocol (MCP) to provide
|
|
16
|
+
* Bitrix24 integration for AI agents.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const B24_BASE = process.env.B24_BASE;
|
|
20
|
+
|
|
21
|
+
if (!B24_BASE) {
|
|
22
|
+
console.error("Error: B24_BASE environment variable is not set.");
|
|
23
|
+
console.error("Please set it to your Bitrix24 webhook URL (e.g., https://domain.bitrix24.ru/rest/1/abcde/).");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const server = new Server(
|
|
28
|
+
{
|
|
29
|
+
name: "bitrix24-mcp-server",
|
|
30
|
+
version: "2.1.0",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
capabilities: {
|
|
34
|
+
tools: {},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Helper to call Bitrix24 REST API
|
|
41
|
+
*/
|
|
42
|
+
async function callBitrix(method, body) {
|
|
43
|
+
const url = `${B24_BASE.replace(/\/$/, "")}/${method}`;
|
|
44
|
+
try {
|
|
45
|
+
const response = await axios.post(url, body, {
|
|
46
|
+
headers: { "Content-Type": "application/json" },
|
|
47
|
+
});
|
|
48
|
+
return response.data;
|
|
49
|
+
} catch (err) {
|
|
50
|
+
const msg = err.response
|
|
51
|
+
? `HTTP ${err.response.status}: ${JSON.stringify(err.response.data)}`
|
|
52
|
+
: err.message;
|
|
53
|
+
throw new Error(msg);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Define available tools
|
|
59
|
+
*/
|
|
60
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
61
|
+
return {
|
|
62
|
+
tools: [
|
|
63
|
+
{
|
|
64
|
+
name: "get_profile",
|
|
65
|
+
description: "Fetch current user profile information from Bitrix24",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "get_task",
|
|
73
|
+
description: "Retrieve task details by ID from Bitrix24",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
id: { type: "number", description: "The unique ID of the task" },
|
|
78
|
+
select: {
|
|
79
|
+
type: "array",
|
|
80
|
+
items: { type: "string" },
|
|
81
|
+
description: "Fields to return (default: ['*'])"
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ["id"],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "search_tasks",
|
|
89
|
+
description: "Search for tasks by title in Bitrix24",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: "object",
|
|
92
|
+
properties: {
|
|
93
|
+
title: { type: "string", description: "Substring of the task title to search for" },
|
|
94
|
+
order: { type: "string", description: "Field to sort by (default: 'ID')" },
|
|
95
|
+
dir: { type: "string", enum: ["asc", "desc"], description: "Sort direction (default: 'desc')" },
|
|
96
|
+
start: { type: "number", description: "Pagination offset (default: 0)" },
|
|
97
|
+
},
|
|
98
|
+
required: ["title"],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "search_groups",
|
|
103
|
+
description: "Search for workgroups or projects by name in Bitrix24",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
type: "object",
|
|
106
|
+
properties: {
|
|
107
|
+
name: { type: "string", description: "Substring of the group name to search for" },
|
|
108
|
+
start: { type: "number", description: "Pagination offset (default: 0)" },
|
|
109
|
+
},
|
|
110
|
+
required: ["name"],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "get_group",
|
|
115
|
+
description: "Retrieve detailed information about a workgroup or project by ID",
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {
|
|
119
|
+
id: { type: "number", description: "The unique ID of the group" },
|
|
120
|
+
},
|
|
121
|
+
required: ["id"],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Handle tool calls
|
|
130
|
+
*/
|
|
131
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
132
|
+
const { name, arguments: args } = request.params;
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
switch (name) {
|
|
136
|
+
case "get_profile": {
|
|
137
|
+
const data = await callBitrix("profile", {});
|
|
138
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case "get_task": {
|
|
142
|
+
const body = { taskId: args.id, select: args.select || ["*"] };
|
|
143
|
+
const data = await callBitrix("tasks.task.get", body);
|
|
144
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
case "search_tasks": {
|
|
148
|
+
const body = {
|
|
149
|
+
order: { [args.order || "ID"]: (args.dir || "desc").toUpperCase() },
|
|
150
|
+
filter: { "%TITLE": args.title },
|
|
151
|
+
select: ["ID", "TITLE", "STATUS", "RESPONSIBLE_ID", "GROUP_ID"],
|
|
152
|
+
start: args.start || 0,
|
|
153
|
+
};
|
|
154
|
+
const data = await callBitrix("tasks.task.list", body);
|
|
155
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
case "search_groups": {
|
|
159
|
+
const body = {
|
|
160
|
+
filter: { "%NAME": args.name },
|
|
161
|
+
order: { ID: "DESC" },
|
|
162
|
+
start: args.start || 0,
|
|
163
|
+
};
|
|
164
|
+
const data = await callBitrix("socialnetwork.api.workgroup.list", body);
|
|
165
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
case "get_group": {
|
|
169
|
+
const body = { params: { groupId: args.id } };
|
|
170
|
+
const data = await callBitrix("socialnetwork.api.workgroup.get", body);
|
|
171
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
default:
|
|
175
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return {
|
|
179
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
180
|
+
isError: true,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Start the server
|
|
187
|
+
*/
|
|
188
|
+
async function main() {
|
|
189
|
+
const transport = new StdioServerTransport();
|
|
190
|
+
await server.connect(transport);
|
|
191
|
+
console.error("Bitrix24 MCP Server running on stdio");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
main().catch((error) => {
|
|
195
|
+
console.error("Fatal error in main():", error);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
});
|
package/package.json
CHANGED
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x0333/bitrix24-mcp-server",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"main": "build/index.js",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Bitrix24 MCP Server for AI Agent Integration.",
|
|
5
|
+
"main": "index.js",
|
|
7
6
|
"bin": {
|
|
8
|
-
"bitrix24-mcp
|
|
9
|
-
"bitrix24-mcp": "./build/index.js"
|
|
7
|
+
"bitrix24-mcp": "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
|
-
"@modelcontextprotocol/sdk": "^
|
|
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
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13
|
+
"axios": "^1.5.0"
|
|
34
14
|
},
|
|
35
15
|
"keywords": [
|
|
36
16
|
"mcp",
|
|
@@ -40,7 +20,6 @@
|
|
|
40
20
|
"automation"
|
|
41
21
|
],
|
|
42
22
|
"author": "Lukentui",
|
|
43
|
-
"license": "MIT",
|
|
44
23
|
"publishConfig": {
|
|
45
24
|
"access": "public"
|
|
46
25
|
}
|