odant-work 1.0.75 → 1.0.78
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/#system/package-manifest.json +22 -14
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent.js +106 -145
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff.js +603 -514
- package/SERVICES/$service/class.js +24 -5
- package/SERVICES/Marketplaces/$service/class.js +9 -0
- package/SERVICES/Marketplaces/Ozon/$service/class.js +19 -0
- package/SERVICES/Marketplaces/Wildberries/$service/class.js +18 -0
- package/SERVICES/Marketplaces/YandexMarket/$service/class.js +19 -0
- package/SERVICES/readme.md +5 -0
- package/package.json +1 -1
- package/sources/client/folder.js +2 -0
- package/sources/modules/agent/extensions.js +129 -79
- package/sources/modules/agent/node-rules.js +37 -1
- package/sources/modules/mcp-marketplaces/mcp-stdio.js +114 -0
- package/sources/modules/mcp-marketplaces/ozon.js +287 -0
- package/sources/modules/mcp-marketplaces/wildberries.js +241 -0
- package/sources/modules/mcp-marketplaces/yandex-market.js +225 -0
- package/sources/server/access/gateway.js +2 -0
- package/sources/server/class/feed.js +6 -0
- package/sources/server/folder.js +1 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Встроенный MCP-сервер для Ozon Seller API (https://api-seller.ozon.ru).
|
|
3
|
+
* Ключи берутся из переменных окружения `OZON_CLIENT_ID` и `OZON_API_KEY` (в WORK — через #secret).
|
|
4
|
+
*/
|
|
5
|
+
import { startMcpStdioServer } from './mcp-stdio.js';
|
|
6
|
+
|
|
7
|
+
const OZON_BASE = 'https://api-seller.ozon.ru';
|
|
8
|
+
|
|
9
|
+
function getOzonCreds() {
|
|
10
|
+
const clientId = String(process.env.OZON_CLIENT_ID || '').trim();
|
|
11
|
+
const apiKey = String(process.env.OZON_API_KEY || '').trim();
|
|
12
|
+
if (!clientId || !apiKey) {
|
|
13
|
+
return {
|
|
14
|
+
notConfigured: true,
|
|
15
|
+
hint: 'Укажите Client-Id и Api-Key кабинета Ozon Seller в секретах сервиса /SERVICES/Marketplaces/Ozon: #secret/ozon_client_id и #secret/ozon_api_key.',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return { clientId, apiKey };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function ozonRequest(relPath, { method = 'POST', body = {} } = {}) {
|
|
22
|
+
const creds = getOzonCreds();
|
|
23
|
+
if (creds.notConfigured)
|
|
24
|
+
return creds;
|
|
25
|
+
const cleanPath = '/' + String(relPath || '').replace(/^\/+/, '');
|
|
26
|
+
if (cleanPath.includes('..') || /^https?:/i.test(String(relPath || '')))
|
|
27
|
+
return { error: 'Недопустимый путь эндпоинта Ozon API' };
|
|
28
|
+
const url = OZON_BASE + cleanPath;
|
|
29
|
+
const res = await fetch(url, {
|
|
30
|
+
method,
|
|
31
|
+
headers: {
|
|
32
|
+
'Client-Id': creds.clientId,
|
|
33
|
+
'Api-Key': creds.apiKey,
|
|
34
|
+
'Content-Type': 'application/json',
|
|
35
|
+
Accept: 'application/json',
|
|
36
|
+
},
|
|
37
|
+
body: method === 'GET' ? undefined : JSON.stringify(body ?? {}),
|
|
38
|
+
signal: AbortSignal.timeout(25000),
|
|
39
|
+
});
|
|
40
|
+
const text = await res.text();
|
|
41
|
+
let parsed = null;
|
|
42
|
+
try { parsed = JSON.parse(text); } catch { /* raw */ }
|
|
43
|
+
if (!res.ok)
|
|
44
|
+
return { error: `Ozon API HTTP ${res.status}`, details: parsed || text.slice(0, 1000) };
|
|
45
|
+
return parsed ?? { raw: text.slice(0, 4000) };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const tools = [
|
|
49
|
+
{
|
|
50
|
+
name: 'products_list',
|
|
51
|
+
description: 'Получить список товаров продавца на Ozon (/v3/product/list).',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
visibility: { type: 'string', description: 'ALL, VISIBLE, INVISIBLE, ARCHIVED (по умолчанию ALL)' },
|
|
56
|
+
last_id: { type: 'string', description: 'Курсор пагинации' },
|
|
57
|
+
limit: { type: 'number', description: 'Количество (1–1000, по умолчанию 50)' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
handler: (a) => ozonRequest('/v3/product/list', {
|
|
61
|
+
body: {
|
|
62
|
+
filter: { visibility: a.visibility || 'ALL' },
|
|
63
|
+
last_id: a.last_id || '',
|
|
64
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 50)),
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'products_info',
|
|
70
|
+
description: 'Подробная информация о товарах Ozon по product_id, offer_id или sku (/v3/product/info/list).',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
product_id: { type: 'array', items: { type: 'number' }, description: 'Массив product_id' },
|
|
75
|
+
offer_id: { type: 'array', items: { type: 'string' }, description: 'Массив артикулов продавца (offer_id)' },
|
|
76
|
+
sku: { type: 'array', items: { type: 'number' }, description: 'Массив SKU Ozon' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
handler: (a) => ozonRequest('/v3/product/info/list', {
|
|
80
|
+
body: {
|
|
81
|
+
...(Array.isArray(a.product_id) && a.product_id.length ? { product_id: a.product_id } : {}),
|
|
82
|
+
...(Array.isArray(a.offer_id) && a.offer_id.length ? { offer_id: a.offer_id } : {}),
|
|
83
|
+
...(Array.isArray(a.sku) && a.sku.length ? { sku: a.sku } : {}),
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'stocks_list',
|
|
89
|
+
description: 'Остатки товаров на складах Ozon FBO и FBS (/v4/product/info/stocks).',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
visibility: { type: 'string', description: 'ALL, VISIBLE, INVISIBLE' },
|
|
94
|
+
offer_id: { type: 'array', items: { type: 'string' } },
|
|
95
|
+
cursor: { type: 'string' },
|
|
96
|
+
limit: { type: 'number', description: 'По умолчанию 100' },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
handler: (a) => ozonRequest('/v4/product/info/stocks', {
|
|
100
|
+
body: {
|
|
101
|
+
filter: {
|
|
102
|
+
visibility: a.visibility || 'ALL',
|
|
103
|
+
...(Array.isArray(a.offer_id) && a.offer_id.length ? { offer_id: a.offer_id } : {}),
|
|
104
|
+
},
|
|
105
|
+
cursor: a.cursor || '',
|
|
106
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 100)),
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'prices_list',
|
|
112
|
+
description: 'Цены, скидки и комиссии товаров на Ozon (/v5/product/info/prices).',
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
visibility: { type: 'string', description: 'ALL, VISIBLE, INVISIBLE' },
|
|
117
|
+
offer_id: { type: 'array', items: { type: 'string' } },
|
|
118
|
+
cursor: { type: 'string' },
|
|
119
|
+
limit: { type: 'number', description: 'По умолчанию 100' },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
handler: (a) => ozonRequest('/v5/product/info/prices', {
|
|
123
|
+
body: {
|
|
124
|
+
filter: {
|
|
125
|
+
visibility: a.visibility || 'ALL',
|
|
126
|
+
...(Array.isArray(a.offer_id) && a.offer_id.length ? { offer_id: a.offer_id } : {}),
|
|
127
|
+
},
|
|
128
|
+
cursor: a.cursor || '',
|
|
129
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 100)),
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'orders_fbs_list',
|
|
135
|
+
description: 'Список отправлений (заказов) FBS на Ozon за период (/v3/posting/fbs/list).',
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
since: { type: 'string', description: 'Начало периода ISO 8601 (по умолчанию последние 7 дней)' },
|
|
140
|
+
to: { type: 'string', description: 'Конец периода ISO 8601' },
|
|
141
|
+
status: { type: 'string', description: 'awaiting_packaging, awaiting_deliver, delivering, delivered, cancelled' },
|
|
142
|
+
limit: { type: 'number', description: 'По умолчанию 50' },
|
|
143
|
+
offset: { type: 'number', description: 'Смещение' },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
handler: (a) => {
|
|
147
|
+
const now = new Date();
|
|
148
|
+
const weekAgo = new Date(now.getTime() - 7 * 86400_000);
|
|
149
|
+
return ozonRequest('/v3/posting/fbs/list', {
|
|
150
|
+
body: {
|
|
151
|
+
dir: 'DESC',
|
|
152
|
+
filter: {
|
|
153
|
+
since: a.since || weekAgo.toISOString(),
|
|
154
|
+
to: a.to || now.toISOString(),
|
|
155
|
+
...(a.status ? { status: a.status } : {}),
|
|
156
|
+
},
|
|
157
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 50)),
|
|
158
|
+
offset: Math.max(0, Number(a.offset) || 0),
|
|
159
|
+
with: { analytics_data: true, financial_data: true },
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'orders_fbo_list',
|
|
166
|
+
description: 'Список отправлений (заказов) FBO со складов Ozon за период (/v2/posting/fbo/list).',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
since: { type: 'string', description: 'Начало периода ISO 8601' },
|
|
171
|
+
to: { type: 'string', description: 'Конец периода ISO 8601' },
|
|
172
|
+
status: { type: 'string' },
|
|
173
|
+
limit: { type: 'number' },
|
|
174
|
+
offset: { type: 'number' },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
handler: (a) => {
|
|
178
|
+
const now = new Date();
|
|
179
|
+
const weekAgo = new Date(now.getTime() - 7 * 86400_000);
|
|
180
|
+
return ozonRequest('/v2/posting/fbo/list', {
|
|
181
|
+
body: {
|
|
182
|
+
dir: 'DESC',
|
|
183
|
+
filter: {
|
|
184
|
+
since: a.since || weekAgo.toISOString(),
|
|
185
|
+
to: a.to || now.toISOString(),
|
|
186
|
+
...(a.status ? { status: a.status } : {}),
|
|
187
|
+
},
|
|
188
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 50)),
|
|
189
|
+
offset: Math.max(0, Number(a.offset) || 0),
|
|
190
|
+
with: { analytics_data: true, financial_data: true },
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'analytics_data',
|
|
197
|
+
description: 'Аналитика продаж, выручки и показов Ozon за период (/v1/analytics/data).',
|
|
198
|
+
inputSchema: {
|
|
199
|
+
type: 'object',
|
|
200
|
+
properties: {
|
|
201
|
+
date_from: { type: 'string', description: 'YYYY-MM-DD' },
|
|
202
|
+
date_to: { type: 'string', description: 'YYYY-MM-DD' },
|
|
203
|
+
metrics: { type: 'array', items: { type: 'string' }, description: 'Например: ["revenue", "ordered_units"]' },
|
|
204
|
+
dimension: { type: 'array', items: { type: 'string' }, description: 'Например: ["sku", "day"]' },
|
|
205
|
+
limit: { type: 'number' },
|
|
206
|
+
},
|
|
207
|
+
required: ['date_from', 'date_to'],
|
|
208
|
+
},
|
|
209
|
+
handler: (a) => ozonRequest('/v1/analytics/data', {
|
|
210
|
+
body: {
|
|
211
|
+
date_from: a.date_from,
|
|
212
|
+
date_to: a.date_to,
|
|
213
|
+
metrics: Array.isArray(a.metrics) && a.metrics.length ? a.metrics : ['revenue', 'ordered_units'],
|
|
214
|
+
dimension: Array.isArray(a.dimension) && a.dimension.length ? a.dimension : ['day'],
|
|
215
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 100)),
|
|
216
|
+
offset: 0,
|
|
217
|
+
},
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'finance_transactions',
|
|
222
|
+
description: 'Финансовые транзакции и начисления Ozon за период (/v3/finance/transaction/list).',
|
|
223
|
+
inputSchema: {
|
|
224
|
+
type: 'object',
|
|
225
|
+
properties: {
|
|
226
|
+
from: { type: 'string', description: 'ISO 8601' },
|
|
227
|
+
to: { type: 'string', description: 'ISO 8601' },
|
|
228
|
+
page: { type: 'number' },
|
|
229
|
+
page_size: { type: 'number' },
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
handler: (a) => {
|
|
233
|
+
const now = new Date();
|
|
234
|
+
const weekAgo = new Date(now.getTime() - 7 * 86400_000);
|
|
235
|
+
return ozonRequest('/v3/finance/transaction/list', {
|
|
236
|
+
body: {
|
|
237
|
+
filter: {
|
|
238
|
+
date: { from: a.from || weekAgo.toISOString(), to: a.to || now.toISOString() },
|
|
239
|
+
transaction_type: 'all',
|
|
240
|
+
},
|
|
241
|
+
page: Math.max(1, Number(a.page) || 1),
|
|
242
|
+
page_size: Math.min(1000, Math.max(1, Number(a.page_size) || 100)),
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'prices_update',
|
|
249
|
+
description: '[ЗАПИСЬ] Обновить цены товаров на Ozon (/v1/product/import/prices).',
|
|
250
|
+
inputSchema: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
properties: {
|
|
253
|
+
prices: { type: 'array', items: { type: 'object' }, description: 'Массив { offer_id/product_id, price, old_price?, min_price?, currency_code? }' },
|
|
254
|
+
},
|
|
255
|
+
required: ['prices'],
|
|
256
|
+
},
|
|
257
|
+
handler: (a) => ozonRequest('/v1/product/import/prices', { body: { prices: a.prices } }),
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'stocks_update',
|
|
261
|
+
description: '[ЗАПИСЬ] Обновить остатки товаров на складах FBS Ozon (/v2/products/stocks).',
|
|
262
|
+
inputSchema: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
properties: {
|
|
265
|
+
stocks: { type: 'array', items: { type: 'object' }, description: 'Массив { offer_id/product_id, stock, warehouse_id }' },
|
|
266
|
+
},
|
|
267
|
+
required: ['stocks'],
|
|
268
|
+
},
|
|
269
|
+
handler: (a) => ozonRequest('/v2/products/stocks', { body: { stocks: a.stocks } }),
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: 'api_call',
|
|
273
|
+
description: 'Универсальный запрос к любому методу Ozon Seller API (https://api-seller.ozon.ru).',
|
|
274
|
+
inputSchema: {
|
|
275
|
+
type: 'object',
|
|
276
|
+
properties: {
|
|
277
|
+
endpoint: { type: 'string', description: 'Путь эндпоинта, например /v2/warehouse/list' },
|
|
278
|
+
method: { type: 'string', description: 'POST или GET (по умолчанию POST)' },
|
|
279
|
+
body: { type: 'object', description: 'JSON-тело запроса' },
|
|
280
|
+
},
|
|
281
|
+
required: ['endpoint'],
|
|
282
|
+
},
|
|
283
|
+
handler: (a) => ozonRequest(a.endpoint, { method: String(a.method || 'POST').toUpperCase(), body: a.body }),
|
|
284
|
+
},
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
startMcpStdioServer({ name: 'ozon-seller-mcp', version: '1.0.0', tools });
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Встроенный MCP-сервер для Wildberries Seller API.
|
|
3
|
+
* Ключ берётся из переменной окружения `WB_API_TOKEN` (в WORK — через #secret).
|
|
4
|
+
*/
|
|
5
|
+
import { startMcpStdioServer } from './mcp-stdio.js';
|
|
6
|
+
|
|
7
|
+
const WB_ALLOWED_HOSTS = new Set([
|
|
8
|
+
'content-api.wildberries.ru',
|
|
9
|
+
'discounts-prices-api.wildberries.ru',
|
|
10
|
+
'marketplace-api.wildberries.ru',
|
|
11
|
+
'statistics-api.wildberries.ru',
|
|
12
|
+
'seller-analytics-api.wildberries.ru',
|
|
13
|
+
'feedbacks-api.wildberries.ru',
|
|
14
|
+
'advert-api.wildberries.ru',
|
|
15
|
+
'supplies-api.wildberries.ru',
|
|
16
|
+
'common-api.wildberries.ru',
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
function getWbToken() {
|
|
20
|
+
const token = String(process.env.WB_API_TOKEN || '').trim();
|
|
21
|
+
if (!token) {
|
|
22
|
+
return {
|
|
23
|
+
notConfigured: true,
|
|
24
|
+
hint: 'Укажите API-токен Wildberries Seller в секрете сервиса /SERVICES/Marketplaces/Wildberries: #secret/wb_api_token.',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { token };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function wbRequest(fullUrl, { method = 'GET', query = null, body = undefined } = {}) {
|
|
31
|
+
const creds = getWbToken();
|
|
32
|
+
if (creds.notConfigured)
|
|
33
|
+
return creds;
|
|
34
|
+
let urlObj;
|
|
35
|
+
try {
|
|
36
|
+
urlObj = new URL(fullUrl);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return { error: 'Некорректный URL Wildberries API' };
|
|
40
|
+
}
|
|
41
|
+
if (urlObj.protocol !== 'https:' || !WB_ALLOWED_HOSTS.has(urlObj.hostname))
|
|
42
|
+
return { error: `Домен ${urlObj.hostname} не входит в разрешённые хосты Wildberries API` };
|
|
43
|
+
if (query && typeof query === 'object') {
|
|
44
|
+
for (const [k, v] of Object.entries(query)) {
|
|
45
|
+
if (v != null && v !== '')
|
|
46
|
+
urlObj.searchParams.set(k, String(v));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const res = await fetch(urlObj.toString(), {
|
|
50
|
+
method,
|
|
51
|
+
headers: {
|
|
52
|
+
Authorization: creds.token,
|
|
53
|
+
Accept: 'application/json',
|
|
54
|
+
...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
55
|
+
},
|
|
56
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
57
|
+
signal: AbortSignal.timeout(25000),
|
|
58
|
+
});
|
|
59
|
+
const text = await res.text();
|
|
60
|
+
let parsed = null;
|
|
61
|
+
try { parsed = JSON.parse(text); } catch { /* raw */ }
|
|
62
|
+
if (!res.ok)
|
|
63
|
+
return { error: `Wildberries API HTTP ${res.status}`, details: parsed || text.slice(0, 1000) };
|
|
64
|
+
return parsed ?? { raw: text.slice(0, 4000) };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const tools = [
|
|
68
|
+
{
|
|
69
|
+
name: 'cards_list',
|
|
70
|
+
description: 'Получить список карточек товаров Wildberries (content-api).',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
textSearch: { type: 'string', description: 'Поиск по артикулу или названию' },
|
|
75
|
+
limit: { type: 'number', description: 'Количество карточек (по умолчанию 50)' },
|
|
76
|
+
updatedAt: { type: 'string' },
|
|
77
|
+
nmID: { type: 'number' },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
handler: (a) => wbRequest('https://content-api.wildberries.ru/content/v2/get/cards/list', {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
body: {
|
|
83
|
+
settings: {
|
|
84
|
+
cursor: {
|
|
85
|
+
limit: Math.min(100, Math.max(1, Number(a.limit) || 50)),
|
|
86
|
+
...(a.updatedAt ? { updatedAt: a.updatedAt } : {}),
|
|
87
|
+
...(a.nmID ? { nmID: Number(a.nmID) } : {}),
|
|
88
|
+
},
|
|
89
|
+
filter: {
|
|
90
|
+
withPhoto: -1,
|
|
91
|
+
...(a.textSearch ? { textSearch: a.textSearch } : {}),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'prices_list',
|
|
99
|
+
description: 'Получить текущие цены и скидки товаров на Wildberries (discounts-prices-api).',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
limit: { type: 'number', description: 'По умолчанию 50 (до 1000)' },
|
|
104
|
+
offset: { type: 'number', description: 'Смещение' },
|
|
105
|
+
filterNmID: { type: 'number', description: 'Фильтр по артикулу WB (nmID)' },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
handler: (a) => wbRequest('https://discounts-prices-api.wildberries.ru/api/v2/list/goods/filter', {
|
|
109
|
+
query: {
|
|
110
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 50)),
|
|
111
|
+
offset: Math.max(0, Number(a.offset) || 0),
|
|
112
|
+
...(a.filterNmID ? { filterNmID: a.filterNmID } : {}),
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'warehouses_list',
|
|
118
|
+
description: 'Список складов продавца Wildberries (FBS).',
|
|
119
|
+
inputSchema: { type: 'object', properties: {} },
|
|
120
|
+
handler: () => wbRequest('https://marketplace-api.wildberries.ru/api/v3/warehouses'),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'stocks_get',
|
|
124
|
+
description: 'Остатки товаров на складе продавца WB по списку баркодов skus.',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
warehouseId: { type: 'number', description: 'ID склада продавца' },
|
|
129
|
+
skus: { type: 'array', items: { type: 'string' }, description: 'Массив баркодов (skus)' },
|
|
130
|
+
},
|
|
131
|
+
required: ['warehouseId', 'skus'],
|
|
132
|
+
},
|
|
133
|
+
handler: (a) => wbRequest(`https://marketplace-api.wildberries.ru/api/v3/stocks/${encodeURIComponent(a.warehouseId)}`, {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
body: { skus: a.skus },
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'orders_fbs_list',
|
|
140
|
+
description: 'Список сборочных заданий FBS на Wildberries.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
limit: { type: 'number', description: 'По умолчанию 100 (до 1000)' },
|
|
145
|
+
next: { type: 'number', description: 'Курсор next (по умолчанию 0)' },
|
|
146
|
+
dateFrom: { type: 'number', description: 'Unix timestamp (сек)' },
|
|
147
|
+
dateTo: { type: 'number', description: 'Unix timestamp (сек)' },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
handler: (a) => wbRequest('https://marketplace-api.wildberries.ru/api/v3/orders', {
|
|
151
|
+
query: {
|
|
152
|
+
limit: Math.min(1000, Math.max(1, Number(a.limit) || 100)),
|
|
153
|
+
next: Number(a.next) || 0,
|
|
154
|
+
...(a.dateFrom ? { dateFrom: a.dateFrom } : {}),
|
|
155
|
+
...(a.dateTo ? { dateTo: a.dateTo } : {}),
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'stat_orders',
|
|
161
|
+
description: 'Статистика заказов Wildberries (FBO/FBS) с указанной даты (statistics-api).',
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
dateFrom: { type: 'string', description: 'Дата/время в формате RFC3339 или YYYY-MM-DD (по умолчанию 7 дней назад)' },
|
|
166
|
+
flag: { type: 'number', description: '0 — с даты, 1 — за конкретный день' },
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
handler: (a) => {
|
|
170
|
+
const defDate = new Date(Date.now() - 7 * 86400_000).toISOString().slice(0, 10);
|
|
171
|
+
return wbRequest('https://statistics-api.wildberries.ru/api/v1/supplier/orders', {
|
|
172
|
+
query: { dateFrom: a.dateFrom || defDate, flag: a.flag ?? 0 },
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'stat_sales',
|
|
178
|
+
description: 'Статистика продаж и возвратов Wildberries с указанной даты (statistics-api).',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: {
|
|
182
|
+
dateFrom: { type: 'string', description: 'YYYY-MM-DD (по умолчанию 7 дней назад)' },
|
|
183
|
+
flag: { type: 'number' },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
handler: (a) => {
|
|
187
|
+
const defDate = new Date(Date.now() - 7 * 86400_000).toISOString().slice(0, 10);
|
|
188
|
+
return wbRequest('https://statistics-api.wildberries.ru/api/v1/supplier/sales', {
|
|
189
|
+
query: { dateFrom: a.dateFrom || defDate, flag: a.flag ?? 0 },
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'prices_update',
|
|
195
|
+
description: '[ЗАПИСЬ] Загрузить новые цены и скидки на Wildberries (/api/v2/upload/task).',
|
|
196
|
+
inputSchema: {
|
|
197
|
+
type: 'object',
|
|
198
|
+
properties: {
|
|
199
|
+
data: { type: 'array', items: { type: 'object' }, description: 'Массив { nmID, price, discount }' },
|
|
200
|
+
},
|
|
201
|
+
required: ['data'],
|
|
202
|
+
},
|
|
203
|
+
handler: (a) => wbRequest('https://discounts-prices-api.wildberries.ru/api/v2/upload/task', {
|
|
204
|
+
method: 'POST',
|
|
205
|
+
body: { data: a.data },
|
|
206
|
+
}),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'stocks_update',
|
|
210
|
+
description: '[ЗАПИСЬ] Обновить остатки на складе продавца WB FBS.',
|
|
211
|
+
inputSchema: {
|
|
212
|
+
type: 'object',
|
|
213
|
+
properties: {
|
|
214
|
+
warehouseId: { type: 'number', description: 'ID склада продавца' },
|
|
215
|
+
stocks: { type: 'array', items: { type: 'object' }, description: 'Массив { sku, amount }' },
|
|
216
|
+
},
|
|
217
|
+
required: ['warehouseId', 'stocks'],
|
|
218
|
+
},
|
|
219
|
+
handler: (a) => wbRequest(`https://marketplace-api.wildberries.ru/api/v3/stocks/${encodeURIComponent(a.warehouseId)}`, {
|
|
220
|
+
method: 'PUT',
|
|
221
|
+
body: { stocks: a.stocks },
|
|
222
|
+
}),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'api_call',
|
|
226
|
+
description: 'Универсальный запрос к официальным доменам Wildberries Seller API (*.wildberries.ru).',
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
properties: {
|
|
230
|
+
url: { type: 'string', description: 'Полный HTTPS URL эндпоинта WB (например https://marketplace-api.wildberries.ru/api/v3/orders/new)' },
|
|
231
|
+
method: { type: 'string', description: 'GET, POST, PUT или PATCH' },
|
|
232
|
+
query: { type: 'object' },
|
|
233
|
+
body: { type: 'object' },
|
|
234
|
+
},
|
|
235
|
+
required: ['url'],
|
|
236
|
+
},
|
|
237
|
+
handler: (a) => wbRequest(a.url, { method: String(a.method || 'GET').toUpperCase(), query: a.query, body: a.body }),
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
startMcpStdioServer({ name: 'wildberries-seller-mcp', version: '1.0.0', tools });
|