graph_demo.md•2.83 kB
# Graph Visualization Demo
This file demonstrates the graph visualization capabilities of SCS-MCP.
## Example: SCS-MCP Core Dependencies
Here's a visualization of the core module dependencies in SCS-MCP itself:
```mermaid
graph TD
%% Core SCS-MCP Dependencies
server["server.py<br/>MCP Server"]
search["clean_search.py<br/>Search Engine"]
db["db_wrapper.py<br/>Database"]
dep["dependency_analyzer.py<br/>Dependencies"]
usage["usage_analyzer.py<br/>Usage Tracking"]
metrics["metrics/<br/>Code Metrics"]
tools["tools/<br/>MCP Tools"]
server --> search
server --> dep
server --> tools
search --> db
search --> dep
search --> usage
dep --> db
usage --> db
tools --> metrics
style server fill:#f9f,stroke:#333,stroke-width:4px
style search fill:#bbf,stroke:#333,stroke-width:2px
style db fill:#bfb,stroke:#333,stroke-width:2px
```
## How This Was Generated
This diagram can be generated using the SCS-MCP tool:
```json
{
"tool": "generate_dependency_graph",
"arguments": {
"output_format": "mermaid",
"graph_type": "imports",
"file_pattern": "src/core/*.py"
}
}
```
## Other Visualization Examples
### 1. Call Graph
Shows function relationships:
```mermaid
graph LR
main --> setup_handlers
setup_handlers --> handle_search
setup_handlers --> handle_analyze
handle_search --> search_engine
handle_analyze --> analyze_symbol
search_engine --> encode_query
search_engine --> calculate_similarity
```
### 2. Class Inheritance
Shows OOP structure:
```mermaid
graph BT
CleanSmartCodeSearch --> BaseSearchEngine
DependencyAnalyzer --> BaseAnalyzer
UsageAnalyzer --> BaseAnalyzer
ThreadSafeDB --> object
BaseAnalyzer --> ABC
```
### 3. Circular Dependency Detection
When circular dependencies are detected, they're highlighted:
```mermaid
graph TD
module_a --> module_b
module_b --> module_c
module_c --> module_a
style module_a fill:#faa,stroke:#f00,stroke-width:3px
style module_b fill:#faa,stroke:#f00,stroke-width:3px
style module_c fill:#faa,stroke:#f00,stroke-width:3px
```
## Benefits of Graph Visualization
1. **Architecture Understanding**: Quickly grasp system structure
2. **Dependency Management**: Identify coupling and cohesion issues
3. **Refactoring Planning**: See impact of changes
4. **Documentation**: Auto-generate architecture diagrams
5. **Code Review**: Spot architectural problems
6. **Onboarding**: Help new developers understand codebase
## Try It Yourself
To generate graphs for your own project:
1. Install SCS-MCP
2. Configure Claude Desktop
3. Use the `generate_dependency_graph` tool
4. Copy the output to your documentation
See [docs/GRAPH_VISUALIZATION.md](../docs/GRAPH_VISUALIZATION.md) for complete guide.