mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
fix(mcp): Fix TrinityCore API compatibility issues
- Use GetBoolDefault/GetIntDefault/GetStringDefault instead of GetOption<T> - Remove non-existent GetRealmName(), use hardcoded name - Simplify Field access to just GetString() (no GetType()) - Handle null Alias in field metadata gracefully
This commit is contained in:
@@ -42,11 +42,11 @@ bool MCPServer::Initialize()
|
||||
return true;
|
||||
|
||||
// Load configuration
|
||||
_port = sConfigMgr->GetOption<uint16>("Araxia.MCP.Port", 8765);
|
||||
_authToken = sConfigMgr->GetOption<std::string>("Araxia.MCP.AuthToken", "");
|
||||
_allowRemote = sConfigMgr->GetOption<bool>("Araxia.MCP.AllowRemote", false);
|
||||
_port = static_cast<uint16>(sConfigMgr->GetIntDefault("Araxia.MCP.Port", 8765));
|
||||
_authToken = sConfigMgr->GetStringDefault("Araxia.MCP.AuthToken", "");
|
||||
_allowRemote = sConfigMgr->GetBoolDefault("Araxia.MCP.AllowRemote", false);
|
||||
|
||||
if (!sConfigMgr->GetOption<bool>("Araxia.MCP.Enable", false))
|
||||
if (!sConfigMgr->GetBoolDefault("Araxia.MCP.Enable", false))
|
||||
{
|
||||
TC_LOG_INFO("araxia.mcp", "[MCP] Araxia MCP Server is disabled in config");
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,13 @@ json QueryResultToJson(QueryResult result)
|
||||
for (uint32 i = 0; i < fieldCount; ++i)
|
||||
{
|
||||
QueryResultFieldMetadata const& meta = result->GetFieldMetadata(i);
|
||||
fieldNames.push_back(meta.Alias);
|
||||
// Use Alias if available, otherwise Name, otherwise generic "field_N"
|
||||
if (meta.Alias && meta.Alias[0])
|
||||
fieldNames.push_back(meta.Alias);
|
||||
else if (meta.Name && meta.Name[0])
|
||||
fieldNames.push_back(meta.Name);
|
||||
else
|
||||
fieldNames.push_back("field_" + std::to_string(i));
|
||||
}
|
||||
|
||||
do
|
||||
@@ -42,35 +48,9 @@ json QueryResultToJson(QueryResult result)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to preserve types
|
||||
switch (fields[i].GetType())
|
||||
{
|
||||
case DatabaseFieldTypes::Int8:
|
||||
case DatabaseFieldTypes::Int16:
|
||||
case DatabaseFieldTypes::Int32:
|
||||
row[fieldNames[i]] = fields[i].GetInt32();
|
||||
break;
|
||||
case DatabaseFieldTypes::Int64:
|
||||
row[fieldNames[i]] = fields[i].GetInt64();
|
||||
break;
|
||||
case DatabaseFieldTypes::UInt8:
|
||||
case DatabaseFieldTypes::UInt16:
|
||||
case DatabaseFieldTypes::UInt32:
|
||||
row[fieldNames[i]] = fields[i].GetUInt32();
|
||||
break;
|
||||
case DatabaseFieldTypes::UInt64:
|
||||
row[fieldNames[i]] = fields[i].GetUInt64();
|
||||
break;
|
||||
case DatabaseFieldTypes::Float:
|
||||
row[fieldNames[i]] = fields[i].GetFloat();
|
||||
break;
|
||||
case DatabaseFieldTypes::Double:
|
||||
row[fieldNames[i]] = fields[i].GetDouble();
|
||||
break;
|
||||
default:
|
||||
row[fieldNames[i]] = fields[i].GetString();
|
||||
break;
|
||||
}
|
||||
// Get as string - JSON parser can handle conversion
|
||||
// This is simpler and works across all field types
|
||||
row[fieldNames[i]] = fields[i].GetString();
|
||||
}
|
||||
}
|
||||
rows.push_back(row);
|
||||
|
||||
@@ -47,7 +47,7 @@ void RegisterServerTools()
|
||||
return {
|
||||
{"success", true},
|
||||
{"server", {
|
||||
{"name", sWorld->GetRealmName()},
|
||||
{"name", "Araxia Online"},
|
||||
{"version", GitRevision::GetFullVersion()},
|
||||
{"branch", GitRevision::GetBranch()},
|
||||
{"revision", GitRevision::GetHash()}
|
||||
|
||||
Reference in New Issue
Block a user