33 lines
980 B
C++
33 lines
980 B
C++
#include "Mcp_Server.hpp"
|
|
#include <render_common.hpp>
|
|
#include <charconv>
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <string_view>
|
|
|
|
namespace {
|
|
|
|
[[nodiscard]] std::uint16_t parse_port(int argc, char** argv) {
|
|
constexpr std::uint16_t default_port{8850};
|
|
if (argc == 1) return default_port;
|
|
if (argc != 3 || std::string_view{argv[1]} != "--port") return 0;
|
|
unsigned value{};
|
|
const std::string_view text{argv[2]};
|
|
const auto [end, error] = std::from_chars(
|
|
text.data(), text.data() + text.size(), value);
|
|
if (error != std::errc{} || end != text.data() + text.size() ||
|
|
value == 0 || value > 65535)
|
|
return 0;
|
|
return static_cast<std::uint16_t>(value);
|
|
}
|
|
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
const auto port = parse_port(argc, argv);
|
|
if (port == 0) return 2;
|
|
aethera::initialize_runtime({});
|
|
std::cout << "Aethera MCP http://127.0.0.1:" << port << "/mcp\n";
|
|
return aethera::mcp::run_mcp_server(port);
|
|
}
|