mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
Aupdates to get the admin panel to talk to llm. Remove actions from TC core that we dont want
This commit is contained in:
@@ -70,14 +70,14 @@ void RegisterDatabaseTools()
|
|||||||
// db_query - Execute SELECT query on any database
|
// db_query - Execute SELECT query on any database
|
||||||
sMCPServer->RegisterTool(
|
sMCPServer->RegisterTool(
|
||||||
"db_query",
|
"db_query",
|
||||||
"Execute a SELECT query on the specified database (world, characters, auth). Returns rows as JSON.",
|
"Execute a SELECT query on the specified database (world, characters, auth, hotfixes). Returns rows as JSON.",
|
||||||
{
|
{
|
||||||
{"type", "object"},
|
{"type", "object"},
|
||||||
{"properties", {
|
{"properties", {
|
||||||
{"database", {
|
{"database", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
{"description", "Database to query: world, characters, or auth"},
|
{"description", "Database to query: world, characters, auth, or hotfixes"},
|
||||||
{"enum", {"world", "characters", "auth"}}
|
{"enum", {"world", "characters", "auth", "hotfixes"}}
|
||||||
}},
|
}},
|
||||||
{"query", {
|
{"query", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
@@ -111,7 +111,7 @@ void RegisterDatabaseTools()
|
|||||||
}
|
}
|
||||||
|
|
||||||
TC_LOG_DEBUG("araxia.mcp", "[MCP] db_query on {}: {}", database, query);
|
TC_LOG_DEBUG("araxia.mcp", "[MCP] db_query on {}: {}", database, query);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QueryResult result;
|
QueryResult result;
|
||||||
@@ -121,9 +121,11 @@ void RegisterDatabaseTools()
|
|||||||
result = CharacterDatabase.Query(query.c_str());
|
result = CharacterDatabase.Query(query.c_str());
|
||||||
else if (database == "auth")
|
else if (database == "auth")
|
||||||
result = LoginDatabase.Query(query.c_str());
|
result = LoginDatabase.Query(query.c_str());
|
||||||
|
else if (database == "hotfixes")
|
||||||
|
result = HotfixDatabase.Query(query.c_str());
|
||||||
else
|
else
|
||||||
return {{"success", false}, {"error", "Unknown database: " + database}};
|
return {{"success", false}, {"error", "Unknown database: " + database}};
|
||||||
|
|
||||||
json data = QueryResultToJson(result);
|
json data = QueryResultToJson(result);
|
||||||
data["success"] = true;
|
data["success"] = true;
|
||||||
data["database"] = database;
|
data["database"] = database;
|
||||||
@@ -163,8 +165,8 @@ void RegisterDatabaseTools()
|
|||||||
{"properties", {
|
{"properties", {
|
||||||
{"database", {
|
{"database", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
{"description", "Database to modify: world, characters, or auth"},
|
{"description", "Database to modify: world, characters, auth, or hotfixes"},
|
||||||
{"enum", {"world", "characters", "auth"}}
|
{"enum", {"world", "characters", "auth", "hotfixes"}}
|
||||||
}},
|
}},
|
||||||
{"query", {
|
{"query", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
@@ -210,6 +212,8 @@ void RegisterDatabaseTools()
|
|||||||
CharacterDatabase.DirectExecute(query.c_str());
|
CharacterDatabase.DirectExecute(query.c_str());
|
||||||
else if (database == "auth")
|
else if (database == "auth")
|
||||||
LoginDatabase.DirectExecute(query.c_str());
|
LoginDatabase.DirectExecute(query.c_str());
|
||||||
|
else if (database == "hotfixes")
|
||||||
|
HotfixDatabase.DirectExecute(query.c_str());
|
||||||
else
|
else
|
||||||
return {{"success", false}, {"error", "Unknown database: " + database}};
|
return {{"success", false}, {"error", "Unknown database: " + database}};
|
||||||
|
|
||||||
@@ -247,15 +251,15 @@ void RegisterDatabaseTools()
|
|||||||
{"properties", {
|
{"properties", {
|
||||||
{"database", {
|
{"database", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
{"description", "Database to list: world, characters, or auth"},
|
{"description", "Database to list: world, characters, auth, or hotfixes"},
|
||||||
{"enum", {"world", "characters", "auth"}}
|
{"enum", {"world", "characters", "auth", "hotfixes"}}
|
||||||
}}
|
}}
|
||||||
}},
|
}},
|
||||||
{"required", {"database"}}
|
{"required", {"database"}}
|
||||||
},
|
},
|
||||||
[](const json& params) -> json {
|
[](const json& params) -> json {
|
||||||
std::string database = params.value("database", "world");
|
std::string database = params.value("database", "world");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QueryResult result;
|
QueryResult result;
|
||||||
@@ -265,6 +269,8 @@ void RegisterDatabaseTools()
|
|||||||
result = CharacterDatabase.Query("SHOW TABLES");
|
result = CharacterDatabase.Query("SHOW TABLES");
|
||||||
else if (database == "auth")
|
else if (database == "auth")
|
||||||
result = LoginDatabase.Query("SHOW TABLES");
|
result = LoginDatabase.Query("SHOW TABLES");
|
||||||
|
else if (database == "hotfixes")
|
||||||
|
result = HotfixDatabase.Query("SHOW TABLES");
|
||||||
else
|
else
|
||||||
return {{"success", false}, {"error", "Unknown database: " + database}};
|
return {{"success", false}, {"error", "Unknown database: " + database}};
|
||||||
|
|
||||||
@@ -307,7 +313,7 @@ void RegisterDatabaseTools()
|
|||||||
{"database", {
|
{"database", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
{"description", "Database containing the table"},
|
{"description", "Database containing the table"},
|
||||||
{"enum", {"world", "characters", "auth"}}
|
{"enum", {"world", "characters", "auth", "hotfixes"}}
|
||||||
}},
|
}},
|
||||||
{"table", {
|
{"table", {
|
||||||
{"type", "string"},
|
{"type", "string"},
|
||||||
@@ -319,16 +325,16 @@ void RegisterDatabaseTools()
|
|||||||
[](const json& params) -> json {
|
[](const json& params) -> json {
|
||||||
std::string database = params.value("database", "world");
|
std::string database = params.value("database", "world");
|
||||||
std::string table = params.value("table", "");
|
std::string table = params.value("table", "");
|
||||||
|
|
||||||
// Sanitize table name (alphanumeric and underscore only)
|
// Sanitize table name (alphanumeric and underscore only)
|
||||||
for (char c : table)
|
for (char c : table)
|
||||||
{
|
{
|
||||||
if (!std::isalnum(c) && c != '_')
|
if (!std::isalnum(c) && c != '_')
|
||||||
return {{"success", false}, {"error", "Invalid table name"}};
|
return {{"success", false}, {"error", "Invalid table name"}};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string query = "DESCRIBE " + table;
|
std::string query = "DESCRIBE " + table;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QueryResult result;
|
QueryResult result;
|
||||||
@@ -338,6 +344,8 @@ void RegisterDatabaseTools()
|
|||||||
result = CharacterDatabase.Query(query.c_str());
|
result = CharacterDatabase.Query(query.c_str());
|
||||||
else if (database == "auth")
|
else if (database == "auth")
|
||||||
result = LoginDatabase.Query(query.c_str());
|
result = LoginDatabase.Query(query.c_str());
|
||||||
|
else if (database == "hotfixes")
|
||||||
|
result = HotfixDatabase.Query(query.c_str());
|
||||||
else
|
else
|
||||||
return {{"success", false}, {"error", "Unknown database: " + database}};
|
return {{"success", false}, {"error", "Unknown database: " + database}};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user