MCPcopy Create free account
hub / github.com/antirez/ds4 / responses_namespace_function_schema_from_tool

Function responses_namespace_function_schema_from_tool

ds4_server.c:1283–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1281static bool parse_stream_options(const char **p, bool *include_usage) {
1282 json_ws(p);
1283 if (**p != '{') return json_skip_value(p);
1284 (*p)++;
1285 json_ws(p);
1286 while (**p && **p != '}') {
1287 char *key = NULL;
1288 if (!json_string(p, &key)) return false;
1289 json_ws(p);
1290 if (**p != ':') {
1291 free(key);
1292 return false;
1293 }
1294 (*p)++;
1295 if (!strcmp(key, "include_usage")) {
1296 if (!json_bool(p, include_usage)) {
1297 free(key);
1298 return false;
1299 }
1300 } else if (!json_skip_value(p)) {
1301 free(key);
1302 return false;
1303 }
1304 free(key);
1305 json_ws(p);
1306 if (**p == ',') (*p)++;
1307 json_ws(p);
1308 }
1309 if (**p != '}') return false;
1310 (*p)++;
1311 return true;
1312}
1313
1314static bool parse_function_call(const char **p, tool_call *tc) {
1315 json_ws(p);
1316 if (**p != '{') return false;
1317 (*p)++;
1318 json_ws(p);
1319 while (**p && **p != '}') {
1320 char *key = NULL;
1321 if (!json_string(p, &key)) goto bad;
1322 json_ws(p);
1323 if (**p != ':') {
1324 free(key);
1325 goto bad;
1326 }
1327 (*p)++;
1328 if (!strcmp(key, "name")) {
1329 if (!json_string_replace(p, &tc->name)) {
1330 free(key);
1331 goto bad;
1332 }
1333 } else if (!strcmp(key, "arguments")) {
1334 json_ws(p);
1335 if (**p == '"') {
1336 if (!json_string_replace(p, &tc->arguments)) {
1337 free(key);
1338 goto bad;
1339 }
1340 } else if (!json_raw_value_replace(p, &tc->arguments)) {

Calls 10

json_wsFunction · 0.85
json_stringFunction · 0.85
json_raw_valueFunction · 0.85
json_skip_valueFunction · 0.85
buf_putsFunction · 0.85
json_escapeFunction · 0.85
buf_putcFunction · 0.85
buf_takeFunction · 0.85
xstrdupFunction · 0.70
buf_freeFunction · 0.70

Tested by

no test coverage detected