CodeRAG provides 23 powerful tools for code analysis:
Description: Add a new code node (class, method, field, etc.)
Parameters:
type: Node type (class, method, interface, field, package)id: Unique identifiername: Display nameproperties: Additional properties objectproject_id: Project identifier (optional, auto-detected if single project)
Example:
{
"type": "class",
"id": "com.example.UserService",
"name": "UserService",
"properties": {
"package": "com.example",
"access_modifier": "public",
"is_abstract": false
}
}Description: Update an existing node's properties
Parameters:
node_id: ID of node to updateproperties: Properties to updateproject_id: Project identifier (optional)
Description: Retrieve a node by ID
Parameters:
node_id: Unique node identifierproject_id: Project identifier (optional)
Description: Delete a node and its relationships
Parameters:
node_id: ID of node to deleteproject_id: Project identifier (optional)
Description: Add a relationship edge between nodes
Parameters:
source_id: Source node IDtarget_id: Target node IDrelationship_type: Type of relationship (extends, implements, calls, etc.)properties: Additional edge propertiesproject_id: Project identifier (optional)
Common relationship types:
EXTENDS: InheritanceIMPLEMENTS: Interface implementationCALLS: Method/function callsREFERENCES: Field/variable referencesCONTAINS: Containment (class contains method)BELONGS_TO: Package membership
Description: Retrieve an edge by ID
Parameters:
edge_id: Unique edge identifierproject_id: Project identifier (optional)
Description: Delete a relationship edge
Parameters:
edge_id: ID of edge to deleteproject_id: Project identifier (optional)
Description: Find all nodes of a specific type
Parameters:
node_type: Type to search for (class, interface, method, field, package)limit: Maximum results to return (default: 100)project_id: Project identifier (optional)
Example:
{
"node_type": "class",
"limit": 50,
"project_id": "my-project"
}Description: Search nodes by name or description
Parameters:
search_term: Text to search fornode_type: Optional type filterlimit: Maximum results (default: 100)project_id: Project identifier (optional)
Search capabilities:
- Partial name matching
- Case-insensitive search
- Searches name and description fields
- Supports wildcard patterns
Description: Find all edges from a source node
Parameters:
source_node_id: Source node identifierrelationship_type: Optional relationship filterlimit: Maximum results (default: 100)project_id: Project identifier (optional)
Description: Search for code using natural language queries to find functionality by meaning
Parameters:
query: Natural language description of functionality to search forproject_id: Optional project identifier to scope searchnode_types: Optional array of node types to filter (class, method, function, etc.)limit: Maximum results (default: 10)similarity_threshold: Minimum similarity score 0.0-1.0 (default: 0.7)include_graph_context: Include related entities in results (default: false)max_hops: Maximum relationship hops for context (default: 2)
Example:
{
"query": "functions that validate email addresses",
"project_id": "my-web-app",
"node_types": ["function", "method"],
"limit": 5,
"similarity_threshold": 0.8,
"include_graph_context": true
}Description: Find code entities semantically similar to a specific node
Parameters:
node_id: ID of the reference code entityproject_id: Project containing the reference nodelimit: Maximum results (default: 5)
Example:
{
"node_id": "UserValidator.validateEmail",
"project_id": "my-web-app",
"limit": 10
}Description: Generate or refresh semantic embeddings for code entities
Parameters:
project_id: Optional project identifier to scope updatenode_types: Optional array of node types to update
Example:
{
"project_id": "my-web-app",
"node_types": ["class", "method", "function"]
}Description: Initialize semantic search infrastructure and vector indexes
Parameters: None
Usage: Run once per database to set up vector search capabilities
Description: Find classes that call a specific method
Parameters:
method_name: Name of the method to search fortarget_class: Optional class that owns the methodproject_id: Project identifier (optional)
Use cases:
- Impact analysis for method changes
- Finding usage patterns
- Dependency analysis
- Refactoring planning
Description: Find classes implementing an interface
Parameters:
interface_name: Name of the interfaceproject_id: Project identifier (optional)
Returns:
- List of implementing classes
- Implementation details
- Inheritance hierarchy information
Description: Get complete inheritance hierarchy for a class
Parameters:
class_name: Name of the classdirection: "up" (ancestors), "down" (descendants), or "both" (default)max_depth: Maximum hierarchy depth (default: 10)project_id: Project identifier (optional)
Output format:
{
"root_class": "BaseEntity",
"hierarchy": {
"ancestors": [
{"name": "Object", "depth": 0},
{"name": "BaseEntity", "depth": 1}
],
"descendants": [
{"name": "User", "depth": 1},
{"name": "Product", "depth": 1},
{"name": "AdminUser", "depth": 2}
]
}
}Description: Calculate Chidamber & Kemerer metrics for a class
Parameters:
class_id: Unique class identifierproject_id: Project identifier (optional)
Metrics calculated:
- WMC (Weighted Methods per Class): Complexity measure
- DIT (Depth of Inheritance Tree): Inheritance depth
- NOC (Number of Children): Direct subclasses
- CBO (Coupling Between Objects): Class dependencies
- RFC (Response for Class): Total method calls
- LCOM (Lack of Cohesion in Methods): Method cohesion
Output includes:
- Raw metric values
- Quality classifications (Good/Warning/Critical)
- Interpretation guidance
- Improvement recommendations
Description: Calculate package-level metrics
Parameters:
package_name: Package/module nameproject_id: Project identifier (optional)
Metrics calculated:
- Ca (Afferent Coupling): Incoming dependencies
- Ce (Efferent Coupling): Outgoing dependencies
- I (Instability): Change resilience (Ce/(Ca+Ce))
- A (Abstractness): Abstract classes ratio
- D (Distance from Main Sequence): Balance measure
Description: Detect architectural problems
Parameters:
project_id: Project identifier (optional)severity: Filter by severity (low, medium, high, critical)
Issues detected:
- Circular Dependencies: Package dependency cycles
- God Classes: Classes with excessive responsibilities
- High Coupling: Classes with too many dependencies
- Unstable Dependencies: Architectural violations
- Dead Code: Unused classes and methods
- Long Parameter Lists: Methods with too many parameters
Description: Get overall project quality summary
Parameters:
project_id: Project identifier (optional)include_metrics: Include detailed metrics (default: true)
Summary includes:
- Entity counts by type
- Relationship statistics
- Quality score and grade
- Top architectural issues
- Recommendations for improvement
- Trend analysis (if historical data available)
Description: Parse and add a single source file
Parameters:
file_path: Absolute path to source filelanguage: Programming language (optional, auto-detected)clear_existing: Clear existing file data (default: false)project_id: Project identifier (optional)
Supported languages:
- TypeScript (
.ts,.tsx) - JavaScript (
.js,.jsx) - Java (
.java) - Python (
.py)
Description: Scan entire directory/project
Parameters:
directory_path: Path to project rootlanguages: Array of languages to scan (optional, auto-detected)exclude_paths: Directories to exclude (default: ["node_modules", "dist", "build"])include_tests: Include test files (default: false)clear_existing: Clear existing project data (default: false)max_depth: Maximum directory depth (default: 10)project_id: Project identifier (optional, derived from directory name)
Example:
{
"directory_path": "/path/to/my-project",
"languages": ["typescript", "javascript"],
"exclude_paths": ["node_modules", "dist", "coverage"],
"include_tests": true,
"clear_existing": true,
"max_depth": 8
}Description: List all projects with optional statistics and filtering
Parameters:
include_stats: Include entity/relationship counts (default: false)sort_by: Sort criteria (name, created_at, updated_at, entity_count)limit: Maximum projects to return (1-1000, default: 100)name_filter: Filter projects by name pattern (optional)
Example:
{
"include_stats": true,
"sort_by": "entity_count",
"limit": 20,
"name_filter": "*service*"
}Output includes:
- Project metadata (ID, name, description)
- Creation and update timestamps
- Entity and relationship statistics
- Supported languages
- Quality summary
# 1. Scan the project
scan_dir -> directory_path: "/path/to/project"
# 2. Get overview
get_project_summary
# 3. Find issues
find_architectural_issues
# 4. Analyze key classes
calculate_ck_metrics -> class_id: "com.example.UserService"# 1. Find the class
search_nodes -> search_term: "UserService"
# 2. Get its dependencies
find_edges_by_source -> source_node_id: "com.example.UserService"
# 3. Find what depends on it
find_classes_calling_method -> method_name: "authenticate"
# 4. Calculate coupling metrics
calculate_ck_metrics -> class_id: "com.example.UserService"# 1. Map inheritance hierarchies
get_inheritance_hierarchy -> class_name: "BaseEntity"
# 2. Find interface implementations
find_classes_implementing_interface -> interface_name: "Repository"
# 3. Analyze package structure
calculate_package_metrics -> package_name: "com.example.service"
# 4. Identify architectural issues
find_architectural_issues# 1. List all projects
list_projects -> include_stats: true
# 2. Compare projects
get_project_summary -> project_id: "project-a"
get_project_summary -> project_id: "project-b"
# 3. Cross-project analysis
search_nodes -> search_term: "Controller" # Searches all projects# 1. Initialize semantic search (one-time setup)
initialize_semantic_search
# 2. Generate embeddings for existing project
update_embeddings -> project_id: "my-project"
# 3. Search by functionality
semantic_search -> query: "functions that validate email addresses"
# 4. Find similar code
get_similar_code -> node_id: "UserValidator.validateEmail", project_id: "my-project"
# 5. Search with context
semantic_search -> query: "database connection utilities", include_graph_context: trueAll tools return standardized error responses:
{
"error": {
"code": "NODE_NOT_FOUND",
"message": "Node with ID 'com.example.Missing' not found",
"details": {
"node_id": "com.example.Missing",
"project_id": "my-project"
}
}
}Common error codes:
NODE_NOT_FOUND: Requested node doesn't existEDGE_NOT_FOUND: Requested edge doesn't existPROJECT_NOT_FOUND: Project doesn't existINVALID_PARAMETERS: Invalid or missing parametersDATABASE_ERROR: Neo4J connection or query errorSCAN_ERROR: File scanning or parsing error
Large result sets:
- Use
limitparameter to control result size - Filter by
project_idwhen possible - Use specific node types rather than broad searches
Complex analysis:
- Break large hierarchies into smaller queries
- Use targeted searches instead of full scans
- Consider caching results for repeated analysis
Multiple file scanning:
- Use
scan_dirinstead of multipleadd_filecalls - Exclude unnecessary directories to improve performance
- Process large projects in stages if needed
Bulk analysis:
- Group related queries together
- Use project-specific queries when possible
- Cache frequently accessed results
- Quality Metrics - Detailed explanation of metrics and thresholds
- MCP Prompts Guide - Guided workflows using these tools
- Troubleshooting - Solving common tool issues