FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
#pragma once
#include "mcp/McpClient.h"
#include "screens/common/IStatefulScreen.h"
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QSet>
#include <QStackedWidget>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QWidget>
namespace fincept::screens {
class McpServersScreen : public QWidget, public IStatefulScreen {
Q_OBJECT
public:
explicit McpServersScreen(QWidget* parent = nullptr);
void restore_state(const QVariantMap& state) override;
QVariantMap save_state() const override;
QString state_key() const override { return "mcp_servers"; }
int state_version() const override { return 1; }
protected:
void showEvent(QShowEvent* e) override;
void hideEvent(QHideEvent* e) override;
void changeEvent(QEvent* event) override;
private slots:
void on_view_changed(int view);
void on_install_server(int index); // from marketplace catalog
void on_refresh();
void on_search_changed(const QString& text);
void on_add_server();
void on_tool_enabled_changed(int row, int col);
private:
void setup_ui();
QWidget* create_header();
QWidget* create_marketplace_view();
QWidget* create_installed_view();
QWidget* create_tools_view();
QWidget* create_status_bar();
void populate_marketplace();
void refresh_installed();
void refresh_tools();
void update_status_bar();
/// Re-apply translated text to cached static-chrome widgets, then trigger
/// the active view's refresh helper so dynamically-built cards/rows pick
/// up the new language too. Called from the constructor and on every
/// QEvent::LanguageChange.
void retranslateUi();
/// Builds a self-contained server card for the Installed view.
QWidget* build_server_card(const fincept::mcp::McpServerConfig& s);
/// Show the exact command line a server will execute and ask for consent.
/// Returns true if the launch may proceed. Asked once per server per
/// session — an MCP server is an arbitrary local process that the AI can
/// then call, so the first launch is an explicit decision, not a side
/// effect of clicking a toggle.
bool confirm_server_launch(const fincept::mcp::McpServerConfig& s);
// State
int active_view_ = 0;
bool loaded_ = false;
/// Server ids whose command line the user has already approved this session.
QSet<QString> launch_approved_;
// Header
QLabel* header_title_ = nullptr;
QList<QPushButton*> view_btns_;
QLineEdit* search_input_ = nullptr;
QPushButton* refresh_btn_ = nullptr;
// View stack
QStackedWidget* view_stack_ = nullptr;
// Marketplace
QLabel* cat_header_lbl_ = nullptr; // "CATEGORY" sidebar header
QListWidget* mkt_cat_list_ =
nullptr; // category sidebar (display text re-set in retranslateUi, API key in UserRole)
QWidget* mkt_cards_widget_ = nullptr;
QVBoxLayout* mkt_cards_layout_ = nullptr;
// Installed
QWidget* inst_cards_widget_ = nullptr;
QVBoxLayout* inst_cards_layout_ = nullptr;
QPushButton* add_server_btn_ = nullptr;
// Tools
QLabel* tools_toolbar_lbl_ = nullptr;
QTableWidget* tools_table_ = nullptr;
QLabel* tools_count_ = nullptr;
// Status bar
QLabel* status_screen_lbl_ = nullptr;
QLabel* status_view_ = nullptr;
QLabel* status_count_ = nullptr;
QLabel* status_running_ = nullptr;
};
} // namespace fincept::screens