MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / _legacy_get_module_tree

Function _legacy_get_module_tree

codewiki/mcp/server.py:513–545  ·  view source on GitHub ↗

Legacy get_module_tree.

(arguments: dict[str, Any])

Source from the content-addressed store, hash-verified

511
512
513async def _legacy_get_module_tree(arguments: dict[str, Any]) -> list[TextContent]:
514 """Legacy get_module_tree."""
515 repo_path = Path(arguments["repo_path"]).expanduser().resolve()
516 output_dir = Path(arguments.get("output_dir", "docs")).expanduser().resolve()
517
518 module_tree_path = output_dir / "module_tree.json"
519 if not module_tree_path.exists():
520 return [_text(json.dumps({
521 "error": f"Module tree not found at {module_tree_path}. Run 'codewiki generate' first."
522 }))]
523
524 module_tree = json.loads(module_tree_path.read_text(encoding="utf-8"))
525
526 def _summarize_tree(tree, depth=0):
527 lines = []
528 for name, info in tree.items():
529 indent = " " * depth
530 comp_count = len(info.get("components", []))
531 children = info.get("children", {})
532 child_count = len(children) if isinstance(children, dict) else 0
533 lines.append(f"{indent}- {name} ({comp_count} components, {child_count} children)")
534 if isinstance(children, dict) and children:
535 lines.extend(_summarize_tree(children, depth + 1))
536 return lines
537
538 summary = "\n".join(_summarize_tree(module_tree))
539 result = {
540 "status": "success",
541 "module_tree_path": str(module_tree_path),
542 "total_modules": len(module_tree),
543 "tree_summary": summary,
544 }
545 return [_text(json.dumps(result, indent=2))]
546
547
548# ===================================================================

Callers 1

call_toolFunction · 0.85

Calls 4

_textFunction · 0.85
_summarize_treeFunction · 0.85
resolveMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected