13#include <nlohmann/json.hpp>
66 const std::string& )
const {
86using ojson = nlohmann::ordered_json;
98 if (!type.is_array()) {
return type.get<std::string>(); }
100 for (
const auto&
t : type) {
101 out += (out.empty() ?
"" :
"|") +
t.get<std::string>();
116 for (
const auto&
a :
alts) {
117 out += (out.empty() ?
"" :
" | ")
132 const auto props =
schema.value(
"properties", ojson::object());
133 std::string out =
"{";
136 out += (out.size() > 1 ?
", " :
"") +
ojson(key).dump()
140 if (
extra.is_object()) {
141 out += (out.size() > 1 ?
", " :
"") + std::string(
"<string>: ")
156 std::string out =
"any";
157 if (type ==
"object") {
159 }
else if (type ==
"array") {
161 }
else if (!type.is_null()) {
176 if (
schema.contains(
"enum")) {
178 }
else if (
schema.contains(
"oneOf")) {
194 const auto props =
schema.value(
"properties", ojson::object());
196 if (
prop.contains(
"description")) {
217 if (!
schema.contains(
"oneOf")) {
223 out +=
"- " +
branch.value(
"title",
"variant " + std::to_string(
n))
249 std::vector<std::string>
notes;
251 for (
const auto& note :
notes) { out += note +
"\n"; }
255 out +=
"Other failures: plain text `Error: ...`.\n";
298 const std::string& tool_name,
306 path +=
"/" + tool_name +
".json";
308 std::ifstream
file(path);
309 if (!
file.is_open()) {
310 throw std::runtime_error(
311 "Tool definition not found: " + path);
315 auto json = nlohmann::ordered_json::parse(
file);
318 def.
name = json.at(
"name").get<std::string>();
319 def.description = json.value(
"description",
"");
320 def.input_schema = json.at(
"inputSchema").dump();
321 if (json.contains(
"outputSchema")) {
322 def.output_schema = json[
"outputSchema"].dump();
326 logger->info(
"Loaded tool definition: {} from {}",
std::string err
size_exceeded, when set
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
ToolDefinition load_tool_definition(const std::string &tool_name, const std::string &server_prefix, const std::string &data_dir)
Load a tool definition from a JSON file.
@ optional
optional: every escape asks the host's path approver
std::string tool_error_json(const std::string &code, const std::string &message)
A declared tool error: {"error": code, "message": message}.
MCPAccessLevel
MCP tool access level for per-identity authorization.
@ WRITE
Read + write operations (e.g., write_file, execute)
std::string render_response_format(const std::string &output_schema_json)
Render an outputSchema as the compact "Response format" text a model reads (gh#203).
MCPServerBase concrete base class + ServerResponse.