godot_search_docs
Search local Godot documentation for classes, methods, properties, signals, and constants using free-text queries or specific filters to find relevant engine information.
Instructions
Search the exact local Godot docs for the installed engine version, including class, method, property, signal, and constant docs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Free-text query, such as 'add child node' or 'timer start one shot'. | |
| class_name | No | Optional class filter or exact class lookup, such as Node, Timer, Sprite2D, or CharacterBody3D. | |
| member_name | No | Optional member filter or exact member lookup, such as add_child, start, position, or ready. | |
| member_type | No | Optional result type filter: any, class, method, property, signal, or constant. | any |
| max_results | No | Maximum number of matches to return. | |
| refresh_cache | No | Whether to rebuild the local docs cache from the selected Godot executable. | |
| godot_executable | No | Optional explicit path to the Godot executable or .app bundle. |
Implementation Reference
- src/godot_mcp/godot.py:1896-2056 (handler)The actual implementation logic for the search_docs tool.
def search_docs( self, query: str | None = None, class_name: str | None = None, member_name: str | None = None, member_type: str = "any", max_results: int = 8, refresh_cache: bool = False, godot_executable: str | None = None, ) -> dict[str, Any]: executable, version = resolve_godot_executable(godot_executable) search_query = (query or "").strip() class_filter = (class_name or "").strip() member_filter = (member_name or "").strip() kind_filter = member_type.strip().lower() or "any" if kind_filter not in {"any", "class", "method", "property", "signal", "constant"}: raise GodotError( "`member_type` must be one of: any, class, method, property, signal, constant." ) if max_results < 1: raise GodotError("`max_results` must be at least 1.") if not (search_query or class_filter or member_filter): raise GodotError("Provide at least one of `query`, `class_name`, or `member_name`.") docs_path, docs_api = self._get_docs_api( executable=executable, version=version, refresh_cache=refresh_cache, ) effective_query = search_query or " ".join(part for part in [class_filter, member_filter] if part) query_text = _normalize_search_text(effective_query) query_tokens = set(_tokenize_search_text(effective_query)) class_filter_lower = class_filter.lower() member_filter_lower = member_filter.lower() raw_results: list[tuple[int, dict[str, Any]]] = [] for cls in docs_api.get("classes", []): if not isinstance(cls, dict): continue class_name_value = str(cls.get("name", "")).strip() if not class_name_value: continue class_name_lower = class_name_value.lower() class_exact = bool(class_filter and class_name_lower == class_filter_lower) class_partial = bool(class_filter and class_filter_lower in class_name_lower) if class_filter and not (class_exact or class_partial): continue class_brief = str(cls.get("brief_description", "")) class_description = str(cls.get("description", "")) class_score = _score_identifier(class_name_value, query_text, query_tokens) class_score += _score_description(class_brief, query_text, query_tokens) class_score += _score_description(class_description, query_text, query_tokens) if class_exact: class_score += 160 elif class_partial: class_score += 60 if kind_filter in {"any", "class"} and not member_filter: if class_score > 0 or class_exact: raw_results.append( ( class_score, { "kind": "class", "class_name": class_name_value, "inherits": cls.get("inherits"), "signature": _format_match_signature("class", class_name_value, cls), "brief_description": _compact_doc_text(class_brief, 180), "description_snippet": _compact_doc_text(class_description), }, ) ) collections: list[tuple[str, list[dict[str, Any]]]] = [] if kind_filter in {"any", "method"}: collections.append(("method", cls.get("methods", []))) if kind_filter in {"any", "property"}: collections.append(("property", cls.get("properties", []))) if kind_filter in {"any", "signal"}: collections.append(("signal", cls.get("signals", []))) if kind_filter in {"any", "constant"}: collections.append(("constant", cls.get("constants", []))) for kind, items in collections: if not isinstance(items, list): continue for item in items: if not isinstance(item, dict): continue item_name = str(item.get("name", "")).strip() if not item_name: continue item_name_lower = item_name.lower() member_exact = bool(member_filter and item_name_lower == member_filter_lower) member_partial = bool(member_filter and member_filter_lower in item_name_lower) if member_filter and not (member_exact or member_partial): continue item_description = str(item.get("description", "")) score = _score_identifier(item_name, query_text, query_tokens) score += _score_description(item_description, query_text, query_tokens) if class_exact: score += 40 elif class_partial: score += 10 if member_exact: score += 180 elif member_partial: score += 70 if score <= 0 and not member_exact: continue raw_results.append( ( score, { "kind": kind, "class_name": class_name_value, "name": item_name, "signature": _format_match_signature(kind, class_name_value, item), "description_snippet": _compact_doc_text(item_description), }, ) ) raw_results.sort(key=lambda item: (-item[0], item[1].get("kind", ""), item[1].get("class_name", ""), item[1].get("name", ""))) unique_results: list[dict[str, Any]] = [] seen: set[tuple[str, str, str]] = set() for score, result in raw_results: key = ( str(result.get("kind", "")), str(result.get("class_name", "")), str(result.get("name", "")), ) if key in seen: continue seen.add(key) result["score"] = score unique_results.append(result) return { "query": search_query or None, "class_name": class_filter or None, "member_name": member_filter or None, "member_type": kind_filter, "results": unique_results[:max_results], "total_matches": len(unique_results), "docs_cache_path": str(docs_path), "godot_executable": str(executable), "godot_version": version, } - src/godot_mcp/server.py:806-855 (registration)Registration of the godot_search_docs tool within the server, linking the definition to the GodotController handler.
name="godot_search_docs", description="Search the exact local Godot docs for the installed engine version, including class, method, property, signal, and constant docs.", input_schema={ "type": "object", "properties": { "query": { "type": "string", "description": "Free-text query, such as 'add child node' or 'timer start one shot'.", }, "class_name": { "type": "string", "description": "Optional class filter or exact class lookup, such as Node, Timer, Sprite2D, or CharacterBody3D.", }, "member_name": { "type": "string", "description": "Optional member filter or exact member lookup, such as add_child, start, position, or ready.", }, "member_type": { "type": "string", "description": "Optional result type filter: any, class, method, property, signal, or constant.", "default": "any", }, "max_results": { "type": "integer", "description": "Maximum number of matches to return.", "default": 8, "minimum": 1, }, "refresh_cache": { "type": "boolean", "description": "Whether to rebuild the local docs cache from the selected Godot executable.", "default": False, }, "godot_executable": { "type": "string", "description": "Optional explicit path to the Godot executable or .app bundle.", }, }, "additionalProperties": False, }, handler=lambda args: self.controller.search_docs( query=args.get("query"), class_name=args.get("class_name"), member_name=args.get("member_name"), member_type=args.get("member_type", "any"), max_results=int(args.get("max_results", 8)), refresh_cache=bool(args.get("refresh_cache", False)), godot_executable=args.get("godot_executable"), ), ),