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;
|
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 McpClientsManager::readRoot() const
|
||||||
{
|
{
|
||||||
|
QJsonObject root{{QLatin1String(kServersKey), QJsonObject{}}};
|
||||||
|
|
||||||
QFile f(configFilePath());
|
QFile f(configFilePath());
|
||||||
if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return QJsonObject{{QLatin1String(kServersKey), QJsonObject{}}};
|
QJsonParseError err;
|
||||||
QJsonParseError err;
|
const QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err);
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err);
|
f.close();
|
||||||
f.close();
|
if (err.error == QJsonParseError::NoError && doc.isObject())
|
||||||
if (err.error != QJsonParseError::NoError || !doc.isObject())
|
root = doc.object();
|
||||||
return QJsonObject{{QLatin1String(kServersKey), QJsonObject{}}};
|
}
|
||||||
QJsonObject root = doc.object();
|
|
||||||
if (!root.contains(QLatin1String(kServersKey)))
|
QJsonObject servers = root.value(QLatin1String(kServersKey)).toObject();
|
||||||
root.insert(QLatin1String(kServersKey), QJsonObject{});
|
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;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ private:
|
|||||||
void updateWatchedPaths();
|
void updateWatchedPaths();
|
||||||
|
|
||||||
QList<PluginLLMCore::Provider *> toolsCapableProviders() const;
|
QList<PluginLLMCore::Provider *> toolsCapableProviders() const;
|
||||||
|
static QJsonObject builtinServers();
|
||||||
QJsonObject readRoot() const;
|
QJsonObject readRoot() const;
|
||||||
bool writeRoot(const QJsonObject &root);
|
bool writeRoot(const QJsonObject &root);
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,14 @@ QList<ExamplePreset> buildExamplePresets()
|
|||||||
{"url", "http://127.0.0.1:3001/sse"},
|
{"url", "http://127.0.0.1:3001/sse"},
|
||||||
{"spec", "2024-11-05"}}});
|
{"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(
|
out.append(
|
||||||
{McpClientsListAspect::tr("remote (SSE / HTTP)"),
|
{McpClientsListAspect::tr("remote (SSE / HTTP)"),
|
||||||
QStringLiteral("remote"),
|
QStringLiteral("remote"),
|
||||||
|
|||||||
Reference in New Issue
Block a user