Knowledge Graph
mcp_m7_knowledge_graphBuild and query a project code dependency graph to detect circular imports, find orphaned exports, analyze change impact, and generate Mermaid diagrams.
Instructions
Project Knowledge Graph - analyze code dependencies, detect cycles, find orphans, generate diagrams.
Actions:
build
Build graph from project directory.
rootPath: Root directory to scan (required)
include: File patterns to include (default: **/*.ts, **/*.tsx, **/*.js)
exclude: File patterns to exclude (default: node_modules, dist)
status
Get current graph status and summary.
metrics
Get detailed graph metrics (nodes, edges, coupling, cohesion, health grade).
query
Query nodes with filters.
nodeType: Filter by type
name: Filter by name (regex)
filePath: Filter by path
limit: Max results
search
Search nodes by name.
name: Name to search (required)
dependencies
Get dependencies of a node.
nodeId: Node ID (required)
dependents
Get dependents of a node (what depends on it).
nodeId: Node ID (required)
impact
Analyze impact of changing a node or file.
nodeId: Node ID to analyze
filePath: File path to analyze
cycles
Detect circular dependencies.
maxCycles: Max cycles to return (default: 100)
includeTypeOnly: Include type-only cycles
orphans
Find orphan code (unused exports).
diagram
Generate Mermaid diagram.
diagramType: dependency, class, component, module, impact
nodeId: Root node for impact diagram
maxNodes: Max nodes to show
direction: TB, BT, LR, RL
path
Find shortest path between two nodes.
nodeId: Source node (required)
targetId: Target node (required)
critical
Get most critical paths (highest impact nodes).
limit: Number of nodes to return
export
Export graph to JSON.
import
Import graph from JSON.
data: JSON string (required)
clear
Clear the graph.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | JSON data for import | |
| name | No | Name to search | |
| limit | No | Limit results | |
| action | Yes | ||
| nodeId | No | Node ID for operations | |
| exclude | No | File patterns to exclude | |
| include | No | File patterns to include | |
| filePath | No | File path for operations | |
| maxDepth | No | Max depth for traversal | |
| maxNodes | No | Max nodes in diagram | |
| nodeType | No | Filter by node type | |
| rootPath | No | Root path to scan | |
| targetId | No | Target node ID for path finding | |
| direction | No | Diagram direction | |
| maxCycles | No | Max cycles to detect | |
| diagramType | No | Type of diagram to generate | |
| includeTypeOnly | No | Include type-only cycles |