MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / tool_code_intel

Method tool_code_intel

modules/mcp/mcp_tools.cpp:594–695  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594MCPTools::ToolResult MCPTools::tool_code_intel(const Dictionary &p_args) {
595 ToolResult result;
596 String action = p_args.get("action", "");
597 if (action == "get_docs") {
598 String query = p_args.get("query", "");
599 if (ClassDB::class_exists(query)) {
600 Dictionary info;
601 info["class"] = query;
602 info["inherits"] = ClassDB::get_parent_class(query);
603 Array props;
604 List<PropertyInfo> plist;
605 ClassDB::get_property_list(query, &plist);
606 for (const PropertyInfo &p : plist) {
607 props.push_back(p.name + " (" + Variant::get_type_name(p.type) + ")");
608 }
609 info["properties"] = props;
610 Array signals;
611 List<MethodInfo> slist;
612 ClassDB::get_signal_list(query, &slist);
613 for (const MethodInfo &s : slist) {
614 signals.push_back(s.name);
615 }
616 info["signals"] = signals;
617 Array methods;
618 List<MethodInfo> mlist;
619 ClassDB::get_method_list(query, &mlist);
620 for (const MethodInfo &m : mlist) {
621 if (m.name.begins_with("_")) {
622 continue;
623 }
624 String sig = m.name + "(";
625 for (int i = 0; i < m.arguments.size(); i++) {
626 if (i > 0) {
627 sig += ", ";
628 }
629 sig += m.arguments[i].name;
630 }
631 sig += ")";
632 methods.push_back(sig);
633 }
634 info["methods"] = methods;
635 result.add_text(JSON::stringify(info, " "));
636 } else {
637 result.set_error("Class not found");
638 }
639 return result;
640 }
641 String path = p_args.get("path", "");
642 if (path.is_empty()) {
643 result.set_error("Missing path");
644 return result;
645 }
646 String normalized = normalize_path(path);
647#ifdef MODULE_GDSCRIPT_ENABLED
648 if (action == "validate" || action == "get_symbols") {
649 Error err;
650 Ref<FileAccess> f = FileAccess::open(normalized, FileAccess::READ, &err);
651 if (err != OK) {

Callers

nothing calls this directly

Calls 14

get_property_listFunction · 0.85
get_method_listFunction · 0.85
itosFunction · 0.85
begins_withMethod · 0.80
sizeMethod · 0.65
getMethod · 0.45
push_backMethod · 0.45
add_textMethod · 0.45
set_errorMethod · 0.45
is_emptyMethod · 0.45
get_as_textMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected