Development
Оценивает цикломатическую и когнитивную сложность, вложенность и дубли
Вызовите этот инструмент из своего кода на трёх языках.
curl -X POST 'https://api.elysiatools.com/ru/api/tools/code-complexity-analyzer' \
-H 'Content-Type: application/json' \
-d '{"sourceCode":"function score(order) {\n if (!order) return 0;\n let total = 0;\n for (const item of order.items) {\n if (item.discount) {\n total += item.price * 0.8;\n } else if (item.vip) {\n total += item.price * 0.9;\n } else {\n total += item.price;\n }\n }\n return total;\n}","language":"javascript","longFunctionThreshold":8,"nestingThreshold":2,"duplicateWindow":4}'Отправьте POST-запрос с входными данными в JSON. Параметры типа «файл» требуют предварительной загрузки.
POST https://api.elysiatools.com/ru/api/tools/code-complexity-analyzer| Имя | Тип | Обязательный | Описание |
|---|---|---|---|
| sourceCode | textarea | Да | — |
| language | select | Нет | — |
| longFunctionThreshold | number | Нет | — |
| nestingThreshold | number | Нет | — |
| duplicateWindow | number | Нет | — |
Добавьте этот инструмент на свой сервер Model Context Protocol, чтобы ИИ-агенты могли перечислять и вызывать его.
Добавьте этот блок в конфигурацию вашего MCP-клиента:
{
"mcpServers": {
"elysiatools-code-complexity-analyzer": {
"name": "code-complexity-analyzer",
"description": "Оценивает цикломатическую и когнитивную сложность, вложенность и дубли",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=code-complexity-analyzer",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}После подключения к SSE-endpoint выведите список доступных инструментов:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}Вызовите инструмент по его id; аргументы формируются из его параметров:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "code-complexity-analyzer",
"arguments": {
"sourceCode": "function score(order) {\n if (!order) return 0;\n let total = 0;\n for (const item of order.items) {\n if (item.discount) {\n total += item.price * 0.8;\n } else if (item.vip) {\n total += item.price * 0.9;\n } else {\n total += item.price;\n }\n }\n return total;\n}",
"language": "javascript",
"longFunctionThreshold": 8,
"nestingThreshold": 2,
"duplicateWindow": 4
}
}
}JSON-результат
{
"key": {...},
"metadata": {
"key": "value"
},
"error": "Error message (optional)",
"message": "Notification message (optional)"
}Вопросы или проблемы? Свяжитесь с [email protected]