# Codebase-Memory-MCP Graph Schema: Complete Guide to Edge Types

> Explore the codebase-memory-mcp graph schema and its 26 edge types like CALLS, IMPORTS, and HTTP_CALLS. Understand code dependencies, data flows, and semantic relationships.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: api-reference
- Published: 2026-07-12

---

**The codebase-memory-mcp graph schema defines 26 distinct edge types—including `CALLS`, `IMPORTS`, `HTTP_CALLS`, and `SEMANTICALLY_RELATED`—that model dependencies, data flows, and semantic relationships between source code entities.**

The `DeusData/codebase-memory-mcp` project constructs a directed graph to represent source code relationships, enabling precise querying of how functions, files, and services interconnect. Understanding the complete set of edge types in this graph schema is essential for writing accurate queries against the MCP server and interpreting the codebase topology correctly.

## Complete List of Edge Types in Codebase-Memory-MCP

The graph schema enumerates exactly 26 relationship types, formally defined in the `ALL_EDGE_TYPES` constant array within the test suite. These edges fall into four functional categories:

**Dependency and Invocation Edges**
- **`CALLS`** – A function or method invokes another callable.
- **`IMPORTS`** – Import statements linking modules or files.
- **`DEPENDS_ON`** – General dependency relationships (e.g., module imports).
- **`USAGE`** – General usage relationships (e.g., variable usage).

**Container and Definition Edges**
- **`CONTAINS_FILE`** – Folder or project containment of a file.
- **`CONTAINS_FOLDER`** – Folder containment of a sub-folder.
- **`DEFINES`** – File to top-level definition (function, class, etc.).
- **`DEFINES_METHOD`** – Class to method definition.
- **`DECORATES`** – A decorator applied to a definition.

**Inheritance and Implementation Edges**
- **`INHERITS`** – Class inheritance relationships.
- **`IMPLEMENTS`** – Trait or interface implementation.
- **`OVERRIDE`** – Method override in a subclass.

**Network and Protocol Edges**
- **`HTTP_CALLS`** – Calls performing HTTP requests.
- **`GRPC_CALLS`** – Calls targeting gRPC endpoints.
- **`GRAPHQL_CALLS`** – Calls targeting GraphQL endpoints.
- **`TRPC_CALLS`** – Calls targeting tRPC endpoints.
- **`ASYNC_CALLS`** – Asynchronous message-bus or pub/sub calls.
- **`HANDLES`** – HTTP route handler relationships (e.g., Flask `@app.route`).
- **`DATA_FLOWS`** – Data-flow relationships between caller and handler.

**Semantic and Similarity Edges**
- **`SEMANTICALLY_RELATED`** – Semantic similarity from the similarity pass.
- **`SIMILAR_TO`** – Structural near-clone relationships (MinHash similarity).

**Testing and Configuration Edges**
- **`TESTS`** – Test-to-code relationships (which functions are exercised).
- **`TESTS_FILE`** – Test file to production file mapping.
- **`CONFIGURES`** – Configuration relationships (e.g., tooling config).
- **`INFRA_MAPS`** – Infrastructure mapping (e.g., service-to-resource).
- **`FILE_CHANGES_WITH`** – Version-control change relationships.

## How Edge Types Are Defined in the Source Code

The canonical definition of all edge types resides in [`tests/test_lang_contract.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_lang_contract.c) at lines 50-57, where the `ALL_EDGE_TYPES` array serves as the single source of truth for the graph schema. This array drives contract verification across the pipeline, ensuring that every emitted edge matches a sanctioned type.

According to the implementation in [`src/store/store.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/store/store.c), edges are stored in SQLite with their type as a string identifier, queried via functions like `cbm_store_count_edges_by_type` which executes `SELECT COUNT(*) FROM edges WHERE type = ?`.

## Key Edge Types and Their Usage

### Dependency and Call Edges (CALLS, IMPORTS, DEPENDS_ON)

**`CALLS`** edges represent the most fundamental relationship in code analysis: one function invoking another. The pipeline creates these during the calls-resolution pass implemented in [`src/pipeline/pass_calls.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_calls.c).

**`IMPORTS`** edges track module dependencies, capturing `import` statements in Python and equivalent directives in other languages.

### HTTP and Route Handling Edges (HTTP_CALLS, HANDLES, GRAPHQL_CALLS)

Modern microservices require specialized edges for network communication. **`HTTP_CALLS`** identifies functions performing HTTP requests, while **`HANDLES`** marks Flask or Express route handlers. The route-node pass in [`src/pipeline/pass_route_nodes.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_route_nodes.c) emits these edges, along with **`GRPC_CALLS`**, **`GRAPHQL_CALLS`**, **`TRPC_CALLS`**, and **`ASYNC_CALLS`** for异步 messaging.

### Structural and Semantic Edges (CONTAINS_FILE, SIMILAR_TO, SEMANTICALLY_RELATED)

Container edges like **`CONTAINS_FILE`** and **`CONTAINS_FOLDER`** establish the hierarchical file system structure. Meanwhile, **`SIMILAR_TO`** (MinHash-based structural similarity) and **`SEMANTICALLY_RELATED`** (AI-derived semantic similarity) connect code entities that share functionality but may not directly interact. These are generated by [`src/pipeline/pass_semantic_edges.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_semantic_edges.c).

## Implementation: How Edges Are Created

The MCP server creates edges during the indexing pipeline. Below are concrete examples showing how specific edge types are generated from source code.

A **`CALLS`** edge is created when a function invokes another:

```c
static const char *C_SRC =
    "int helper(int x) { return x + 1; }\n"
    "int run(int y) { return helper(y); }\n";
cbm_store_t *store = lang_index(&lp, "a.c", C_SRC);
int calls = cbm_store_count_edges_by_type(store, lp.project, "CALLS");

```

An **`IMPORTS`** edge captures Python relative imports:

```c
static const char *PY_SRC[] = {
    "def helper(x): return x + 1\n",
    "from .util import helper\n\ndef run(y): return helper(y)\n"
};
LangMetrics m = lang_metrics(PyFiles, 2);
int imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");

```

**`HTTP_CALLS`** edges identify external HTTP requests:

```c
static const char *PY_HTTP =
    "def requests_get(url): return {'url': url}\n"
    "def client(): return requests_get('/api/orders')\n";
LangMetrics m = lang_metrics(&PY_HTTP, 1);
int http_calls = cbm_store_count_edges_by_type(store, lp.project, "HTTP_CALLS");

```

**`HANDLES`** edges mark HTTP route handlers from framework decorators:

```c
static const char *PY_HANDLES =
    "from flask import Flask\n"
    "app = Flask(__name__)\n"
    "@app.route('/users')\ndef list_users(): return []\n";
LangMetrics m = lang_metrics(&PY_HANDLES, 1);
int handles = cbm_store_count_edges_by_type(store, lp.project, "HANDLES");

```

## Pipeline Passes That Generate Edges

Different analysis passes specialize in specific edge type categories:

- **[`src/pipeline/pass_calls.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_calls.c)** – Emits `CALLS` edges during call-resolution.
- **[`src/pipeline/pass_route_nodes.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_route_nodes.c)** – Generates `HTTP_CALLS`, `ASYNC_CALLS`, `GRPC_CALLS`, and `HANDLES` edges from route definitions.
- **[`src/pipeline/pass_semantic_edges.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_semantic_edges.c)** – Creates `SIMILAR_TO` and `SEMANTICALLY_RELATED` edges from similarity analysis.
- **[`src/pipeline/pass_cross_repo.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_cross_repo.c)** – Derives cross-repository variants of protocol edges (e.g., `CROSS_HTTP_CALLS`).

## Querying Edge Types in the Graph Store

The storage layer in [`src/store/store.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/store/store.c) provides SQLite-backed persistence for all edges. Use `cbm_store_count_edges_by_type()` to verify edge presence or analyze graph density for specific relationship types. This function executes parameterized SQL queries against the edges table, filtering by the type string.

## Summary

- The **codebase-memory-mcp graph schema** defines 26 distinct edge types covering dependencies, containers, protocols, and semantic relationships.
- All valid edge labels are enumerated in the **`ALL_EDGE_TYPES`** array in [`tests/test_lang_contract.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_lang_contract.c), serving as the schema's contract definition.
- **Invocation edges** (`CALLS`, `IMPORTS`) track code execution flow, while **protocol edges** (`HTTP_CALLS`, `GRPC_CALLS`) map service communication.
- **Semantic edges** (`SIMILAR_TO`, `SEMANTICALLY_RELATED`) enable discovery of related code through structure and meaning rather than direct coupling.
- The pipeline creates edges through specialized passes ([`pass_calls.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/pass_calls.c), [`pass_route_nodes.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/pass_route_nodes.c), [`pass_semantic_edges.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/pass_semantic_edges.c)) that analyze source code and populate the SQLite store via `cbm_store_count_edges_by_type()`.

## Frequently Asked Questions

### What is the complete list of edge types in codebase-memory-mcp?

The codebase-memory-mcp graph schema includes 26 edge types: `CALLS`, `CONFIGURES`, `CONTAINS_FILE`, `CONTAINS_FOLDER`, `DATA_FLOWS`, `DECORATES`, `DEFINES`, `DEFINES_METHOD`, `DEPENDS_ON`, `FILE_CHANGES_WITH`, `GRAPHQL_CALLS`, `GRPC_CALLS`, `HANDLES`, `HTTP_CALLS`, `IMPLEMENTS`, `IMPORTS`, `INHERITS`, `INFRA_MAPS`, `OVERRIDE`, `SEMANTICALLY_RELATED`, `SIMILAR_TO`, `TESTS_FILE`, `TESTS`, `TRPC_CALLS`, `USAGE`, and `ASYNC_CALLS`.

### Where are edge types defined in the codebase-memory-mcp source code?

Edge types are defined in the `ALL_EDGE_TYPES` constant array located in [`tests/test_lang_contract.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/tests/test_lang_contract.c) at lines 50-57. This array serves as the single source of truth for the graph schema and is used to validate that all edges created by the pipeline conform to sanctioned types.

### How does codebase-memory-mcp handle HTTP and API call relationships?

The schema uses specialized edges to model network interactions: `HTTP_CALLS` for HTTP requests, `GRPC_CALLS` for gRPC endpoints, `GRAPHQL_CALLS` for GraphQL queries, `TRPC_CALLS` for tRPC procedures, and `ASYNC_CALLS` for message-bus communications. These are generated by [`src/pipeline/pass_route_nodes.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_route_nodes.c) when analyzing route definitions and client calls.

### What is the difference between SIMILAR_TO and SEMANTICALLY_RELATED edges?

`SIMILAR_TO` edges represent structural similarity between code entities (detected via MinHash algorithms), identifying near-duplicate or cloned code. `SEMANTICALLY_RELATED` edges represent functional similarity derived from AI-powered semantic analysis, connecting code that serves similar purposes regardless of structural similarity. Both are generated by [`src/pipeline/pass_semantic_edges.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/pipeline/pass_semantic_edges.c).