* @brief Generate MCP tools from CommandRegistry */
| 637 | * @brief Generate MCP tools from CommandRegistry |
| 638 | */ |
| 639 | QVector<API::MCP::Tool> API::MCPHandler::generateToolsFromRegistry() const |
| 640 | { |
| 641 | QVector<MCP::Tool> tools; |
| 642 | |
| 643 | const auto& commands = CommandRegistry::instance().commands(); |
| 644 | for (auto it = commands.constBegin(); it != commands.constEnd(); ++it) { |
| 645 | const auto& name = it.key(); |
| 646 | MCP::Tool tool; |
| 647 | tool.name = name; |
| 648 | tool.description = it.value().description; |
| 649 | tool.inputSchema = it.value().inputSchema.isEmpty() |
| 650 | ? QJsonObject{{QStringLiteral("type"), QStringLiteral("object")}} |
| 651 | : it.value().inputSchema; |
| 652 | |
| 653 | const auto parts = name.split(QLatin1Char('.')); |
| 654 | if (parts.size() >= 2) |
| 655 | tagToolFromCommandName(tool, parts); |
| 656 | |
| 657 | tools.append(tool); |
| 658 | } |
| 659 | |
| 660 | return tools; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * @brief Generate MCP resources |