Fix mcp_docs component initialization order issue

Fixed AttributeError where selected_servers was accessed before initialization.
The issue was that Component.__init__() calls _discover_component_files()
which tried to access self.selected_servers before it was set.

Solution: Initialize selected_servers and server_docs_map before calling
super().__init__() to ensure they're available when needed.

Fixes:
- mcp_docs component now properly discovered and listed
- Installation commands work correctly with mcp_docs
- Dry-run installations complete successfully

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NomenAK
2025-08-14 22:14:56 +02:00
parent d273b60f2e
commit 572028b285

View File

@@ -14,7 +14,9 @@ class MCPDocsComponent(Component):
def __init__(self, install_dir: Optional[Path] = None):
"""Initialize MCP docs component"""
super().__init__(install_dir, Path(""))
# Initialize attributes before calling parent constructor
# because parent calls _discover_component_files() which needs these
self.selected_servers: List[str] = []
# Map server names to documentation files
self.server_docs_map = {
@@ -26,8 +28,7 @@ class MCPDocsComponent(Component):
"morphllm": "MCP_Morphllm.md"
}
# This will be set during installation - initialize as empty list
self.selected_servers: List[str] = []
super().__init__(install_dir, Path(""))
def get_metadata(self) -> Dict[str, str]:
"""Get component metadata"""