mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 10:59:30 -04:00
feat: Add qt-docs mcp server
This commit is contained in:
@@ -189,19 +189,42 @@ QList<PluginLLMCore::Provider *> McpClientsManager::toolsCapableProviders() cons
|
||||
return out;
|
||||
}
|
||||
|
||||
QJsonObject McpClientsManager::builtinServers()
|
||||
{
|
||||
static const QByteArray pseudoConfig(
|
||||
"{\n"
|
||||
" \"mcpServers\": {\n"
|
||||
" \"qt-docs\": {\n"
|
||||
" \"type\": \"sse\",\n"
|
||||
" \"url\": \"https://qt-docs-mcp.qt.io/mcp\",\n"
|
||||
" \"enable\": false\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(pseudoConfig);
|
||||
return doc.object().value(QLatin1String(kServersKey)).toObject();
|
||||
}
|
||||
|
||||
QJsonObject McpClientsManager::readRoot() const
|
||||
{
|
||||
QJsonObject root{{QLatin1String(kServersKey), QJsonObject{}}};
|
||||
|
||||
QFile f(configFilePath());
|
||||
if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return QJsonObject{{QLatin1String(kServersKey), QJsonObject{}}};
|
||||
QJsonParseError err;
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err);
|
||||
f.close();
|
||||
if (err.error != QJsonParseError::NoError || !doc.isObject())
|
||||
return QJsonObject{{QLatin1String(kServersKey), QJsonObject{}}};
|
||||
QJsonObject root = doc.object();
|
||||
if (!root.contains(QLatin1String(kServersKey)))
|
||||
root.insert(QLatin1String(kServersKey), QJsonObject{});
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QJsonParseError err;
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err);
|
||||
f.close();
|
||||
if (err.error == QJsonParseError::NoError && doc.isObject())
|
||||
root = doc.object();
|
||||
}
|
||||
|
||||
QJsonObject servers = root.value(QLatin1String(kServersKey)).toObject();
|
||||
const QJsonObject builtin = builtinServers();
|
||||
for (auto it = builtin.begin(); it != builtin.end(); ++it) {
|
||||
if (!servers.contains(it.key()))
|
||||
servers.insert(it.key(), it.value());
|
||||
}
|
||||
root.insert(QLatin1String(kServersKey), servers);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ private:
|
||||
void updateWatchedPaths();
|
||||
|
||||
QList<PluginLLMCore::Provider *> toolsCapableProviders() const;
|
||||
static QJsonObject builtinServers();
|
||||
QJsonObject readRoot() const;
|
||||
bool writeRoot(const QJsonObject &root);
|
||||
|
||||
|
||||
@@ -181,6 +181,14 @@ QList<ExamplePreset> buildExamplePresets()
|
||||
{"url", "http://127.0.0.1:3001/sse"},
|
||||
{"spec", "2024-11-05"}}});
|
||||
|
||||
out.append(
|
||||
{McpClientsListAspect::tr("qt-docs (Qt documentation)"),
|
||||
QStringLiteral("qt-docs"),
|
||||
QJsonObject{
|
||||
{"enable", true},
|
||||
{"type", "sse"},
|
||||
{"url", "https://qt-docs-mcp.qt.io/mcp"}}});
|
||||
|
||||
out.append(
|
||||
{McpClientsListAspect::tr("remote (SSE / HTTP)"),
|
||||
QStringLiteral("remote"),
|
||||
|
||||
Reference in New Issue
Block a user