File size: 1,230 Bytes
1af10cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Concept graph tools for TutorX MCP.
"""
from typing import Dict, Any, Optional
import sys
import os
from pathlib import Path

# Add the parent directory to the Python path
current_dir = Path(__file__).parent
parent_dir = current_dir.parent.parent
sys.path.insert(0, str(parent_dir))

import sys
import os
from pathlib import Path

# Add the parent directory to the Python path
current_dir = Path(__file__).parent
parent_dir = current_dir.parent
sys.path.insert(0, str(parent_dir))

# Import from local resources
from resources import concept_graph

# Import MCP
from mcp_server.mcp_instance import mcp

@mcp.tool()
async def get_concept_graph_tool(concept_id: Optional[str] = None) -> Dict[str, Any]:
    """
    Get the complete concept graph or a specific concept.
    
    Args:
        concept_id: Optional concept ID to get a specific concept
        
    Returns:
        Dictionary containing the concept graph or a specific concept
    """
    if concept_id:
        concept = concept_graph.get_concept(concept_id)
        if not concept:
            return {"error": f"Concept {concept_id} not found"}
        return {"concept": concept}
    
    return {"concepts": list(concept_graph.get_concept_graph().values())}