15 MCP Tools in codebase-memory-mcp: Complete Function Signatures and Usage Guide

The codebase-memory-mcp server exposes 15 JSON-RPC 2.0 tools defined in src/mcp/mcp.c that enable repository indexing, graph querying, code navigation, and architecture analysis through structured function signatures.

The codebase-memory-mcp repository by DeusData implements a Model Context Protocol (MCP) server that transforms static code analysis into an interactive knowledge graph. These 15 MCP tools provide programmatic access to repository structure, semantic relationships, and architectural insights via standardized JSON-RPC calls defined in the TOOLS[] array.

Repository Lifecycle Tools

These four tools manage the indexing, listing, and deletion of projects within the knowledge graph.

index_repository

Purpose: Index a repository or run cross-repo intelligence analysis.

Function Signature:

{
  "type": "object",
  "properties": {
    "repo_path": {
      "type": "string",
      "description": "Path to the repository"
    },
    "mode": {
      "type": "string",
      "enum": ["full", "moderate", "fast", "cross-repo-intelligence"],
      "default": "full",
      "description": "Indexing mode"
    },
    "target_projects": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Projects to search for cross-repo links"
    },
    "name": {
      "type": "string",
      "description": "Override derived project name"
    },
    "persistence": {
      "type": "boolean",
      "default": false,
      "description": "Write compressed artifact to .codebase-memory/graph.db.zst"
    }
  },
  "required": ["repo_path"]
}

list_projects

Purpose: List all indexed projects currently available in the knowledge graph.

Function Signature:

{
  "type": "object",
  "properties": {}
}

delete_project

Purpose: Remove a project and its associated graph data from the index.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    }
  },
  "required": ["project"]
}

index_status

Purpose: Show indexing statistics and coverage flags for a specific project.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    }
  },
  "required": ["project"]
}

Graph Search and Query Tools

These three tools provide full-text search, Cypher querying, and grep-style code search capabilities.

search_graph

Purpose: Full-text, regex, or semantic search over the knowledge graph.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    },
    "query": {
      "type": "string",
      "description": "Natural-language or keyword full-text search"
    },
    "label": {
      "type": "string"
    },
    "name_pattern": {
      "type": "string"
    },
    "qn_pattern": {
      "type": "string"
    },
    "file_pattern": {
      "type": "string"
    },
    "relationship": {
      "type": "string"
    },
    "min_degree": {
      "type": "integer"
    },
    "max_degree": {
      "type": "integer"
    },
    "exclude_entry_points": {
      "type": "boolean"
    },
    "include_connected": {
      "type": "boolean"
    },
    "semantic_query": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "limit": {
      "type": "integer"
    },
    "offset": {
      "type": "integer",
      "default": 0
    },
    "format": {
      "type": "string",
      "enum": ["toon", "json"],
      "default": "toon"
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": ["project"]
}

query_graph

Purpose: Run arbitrary Cypher queries against the code or missed-opportunity graph.

Function Signature:

{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "Cypher query"
    },
    "project": {
      "type": "string"
    },
    "graph": {
      "type": "string",
      "enum": ["code", "missed"],
      "default": "code",
      "description": "Graph to query"
    },
    "max_rows": {
      "type": "integer",
      "description": "Optional row limit"
    }
  },
  "required": ["query", "project"]
}

search_code

Purpose: Graph-augmented grep-style code search with context support.

Function Signature:

{
  "type": "object",
  "properties": {
    "pattern": {
      "type": "string"
    },
    "project": {
      "type": "string"
    },
    "file_pattern": {
      "type": "string",
      "description": "Glob for grep"
    },
    "path_filter": {
      "type": "string",
      "description": "Regex on file paths"
    },
    "mode": {
      "type": "string",
      "enum": ["compact", "full", "files"],
      "default": "compact"
    },
    "context": {
      "type": "integer",
      "description": "Lines of context"
    },
    "regex": {
      "type": "boolean",
      "default": false
    },
    "limit": {
      "type": "integer",
      "default": 10
    }
  },
  "required": ["pattern", "project"]
}

Code Navigation and Relationship Tools

These three tools enable call-graph traversal, source retrieval, and schema inspection.

trace_path

Purpose: Trace callers, callees, data-flow, or cross-service edges through the graph.

Function Signature:

{
  "type": "object",
  "properties": {
    "function_name": {
      "type": "string"
    },
    "project": {
      "type": "string"
    },
    "direction": {
      "type": "string",
      "enum": ["inbound", "outbound", "both"],
      "default": "both"
    },
    "depth": {
      "type": "integer",
      "default": 3
    },
    "mode": {
      "type": "string",
      "enum": ["calls", "data_flow", "cross_service"],
      "default": "calls"
    },
    "parameter_name": {
      "type": "string"
    },
    "edge_types": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "risk_labels": {
      "type": "boolean",
      "default": false
    },
    "include_tests": {
      "type": "boolean",
      "default": false
    },
    "format": {
      "type": "string",
      "enum": ["toon", "json"],
      "default": "toon"
    }
  },
  "required": ["function_name", "project"]
}

get_code_snippet

Purpose: Retrieve source code for a specific qualified name from the graph.

Function Signature:

{
  "type": "object",
  "properties": {
    "qualified_name": {
      "type": "string",
      "description": "Full qualified_name from search_graph"
    },
    "project": {
      "type": "string"
    },
    "include_neighbors": {
      "type": "boolean",
      "default": false
    }
  },
  "required": ["qualified_name", "project"]
}

get_graph_schema

Purpose: Return the graph's node-label and edge-type schema for query construction.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    }
  },
  "required": ["project"]
}

Architecture Analysis and Coverage Tools

These three tools provide high-level architectural summaries, coverage verification, and change detection.

get_architecture

Purpose: Summarize high-level architecture including dependencies, clusters, and hotspots.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    },
    "path": {
      "type": "string",
      "description": "Optional directory prefix"
    },
    "aspects": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["all", "overview", "structure", "dependencies", "routes", "languages", "packages", "entry_points", "hotspots", "boundaries", "layers", "file_tree", "clusters"]
      },
      "description": "Aspects to include"
    }
  },
  "required": ["project"]
}

check_index_coverage

Purpose: Verify coverage for specific file paths or scopes with pagination support.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    },
    "paths": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 128
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 32
    },
    "scope_limit": {
      "type": "integer",
      "default": 200,
      "minimum": 1,
      "maximum": 1000
    },
    "scope_offset": {
      "type": "integer",
      "default": 0
    }
  },
  "required": ["project"],
  "anyOf": [
    {
      "required": ["paths"]
    },
    {
      "required": ["scopes"]
    }
  ]
}

detect_changes

Purpose: Detect code changes and their impact across the codebase.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    },
    "scope": {
      "type": "string"
    },
    "depth": {
      "type": "integer",
      "default": 2
    },
    "base_branch": {
      "type": "string",
      "default": "main"
    },
    "since": {
      "type": "string",
      "description": "Git ref or tag to compare from"
    }
  },
  "required": ["project"]
}

Knowledge Management and Trace Ingestion

These two tools manage Architecture Decision Records (ADRs) and runtime trace data.

manage_adr

Purpose: Create or update Architecture Decision Records for the project.

Function Signature:

{
  "type": "object",
  "properties": {
    "project": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["get", "update", "sections"]
    },
    "content": {
      "type": "string"
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": ["project"]
}

ingest_traces

Purpose: Ingest runtime traces to enrich the graph with dynamic call information.

Function Signature:

{
  "type": "object",
  "properties": {
    "traces": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "caller": {
            "type": "string"
          },
          "callee": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          }
        },
        "additionalProperties": false
      }
    },
    "project": {
      "type": "string"
    }
  },
  "required": ["traces", "project"]
}

Implementation Details in src/mcp/mcp.c

All 15 tool definitions reside in the TOOLS[] array at lines 31-95 of [src/mcp/mcp.c](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/mcp/mcp.c#L31-L95). Each entry maps the tool name to its JSON Schema input specification and human-readable description.

The tool annotation table, which marks each tool as read-only, destructive, or administrative, is defined at lines 101-127 in the same file. This metadata determines which operations require additional confirmation or specific capabilities from the MCP client.

The public API headers exposing these functions are located in [src/mcp/mcp.h](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/mcp/mcp.h), which declares cbm_mcp_tools_list() and cbm_mcp_tool_input_schema() for runtime introspection.

JSON-RPC Request Examples

The following examples demonstrate how to invoke these tools via JSON-RPC 2.0:

Index a repository in full mode:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "index_repository",
  "params": {
    "repo_path": "/path/to/my/repo",
    "mode": "full"
  }
}

Search the graph for "cache" with JSON output:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "search_graph",
  "params": {
    "project": "myproj",
    "query": "cache",
    "limit": 20,
    "format": "json"
  }
}

Trace call paths for a specific function:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "trace_path",
  "params": {
    "project": "myproj",
    "function_name": "my_namespace::my_function",
    "direction": "both",
    "depth": 4,
    "format": "toon"
  }
}

Execute a custom Cypher query:

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "query_graph",
  "params": {
    "project": "myproj",
    "query": "MATCH (f:Function) WHERE f.transitive_loop_depth >= 3 RETURN f.qualified_name, f.transitive_loop_depth",
    "max_rows": 50
  }
}

Summary

  • 15 MCP tools are available in src/mcp/mcp.c, ranging from repository indexing to runtime trace ingestion.
  • Tool signatures follow JSON Schema conventions with required/optional parameters, enums, and default values.
  • Core files include src/mcp/mcp.c (definitions), src/mcp/mcp.h (API), and tests/test_mcp.c (validation).
  • Output formats support both human-readable "toon" tables and machine-parseable JSON.
  • Graph databases support both "code" and "missed" graphs for different analysis modes.

Frequently Asked Questions

What is the difference between search_graph and search_code?

search_graph performs semantic and structural queries against the knowledge graph using natural language or keywords, while search_code executes grep-style text searches with regex support against raw source files. Use search_graph for relationship-based discovery and search_code for exact text matching.

How do I persist indexed data across server restarts?

Set the persistence parameter to true when calling index_repository. This writes a compressed artifact to .codebase-memory/graph.db.zst that can be reloaded on subsequent server initializations without re-indexing the entire repository.

Where are the MCP tool definitions located in the source code?

All tool definitions and their JSON schemas are stored in the TOOLS[] array at lines 31-95 of [src/mcp/mcp.c](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/mcp/mcp.c#L31-L95). The tool annotation metadata (read-only, destructive flags) appears at lines 101-127 in the same file.

What is the maximum depth for trace_path operations?

The depth parameter accepts any positive integer, with a default value of 3. The tool supports tracing in three directions—inbound, outbound, or both—and can traverse calls, data flow, or cross-service edges depending on the mode parameter.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →