# Node Labels in Codebase-Memory-MCP: Complete Guide to Graph Entities

> Discover Node labels in Codebase-Memory-MCP. Learn how these identifiers classify source code elements like Files, Classes, and Functions for effective codebase graph analysis and visualization.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: deep-dive
- Published: 2026-07-04

---

**Node labels in Codebase-Memory-MCP are categorical identifiers assigned to every `GraphNode` that classify the type of source code element—such as File, Class, Function, or Package—enabling filtering, visualization, and statistical analysis of the codebase graph.**

Codebase-Memory-MCP represents your entire repository as a navigable graph where each entity is a `GraphNode` with a strongly-typed `label` field. Understanding these node labels is essential for querying the graph schema, customizing the UI, and building accurate filters that isolate specific code constructs.

## What Are Node Labels in Codebase-Memory-MCP?

In Codebase-Memory-MCP, every entity in the source-code graph is represented as a **`GraphNode`**. Each node carries a mandatory `label` field that identifies the specific kind of program element it represents, such as a Class, Function, or File.

The canonical set of supported labels is defined by the UI color-mapping table in [`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts). This same list drives the schema statistics displayed in the **`StatsTab`** component, renders node badges throughout the interface, and powers the label-based filtering logic in the graph visualization.

## Complete List of Node Labels

The following table enumerates every node label recognized by the system, along with the source code element it typically represents:

| Label | Meaning / Typical Source Element |
|-------|----------------------------------|
| **Project** | Top-level repository or workspace |
| **Package** | Python/Node package (directory with a manifest) |
| **Module** | Sub-module inside a package |
| **Folder** | Generic directory (non-package) |
| **File** | Source file (e.g., `.py`, `.js`, `.ts`) |
| **Class** | Class definition |
| **Interface** | TypeScript interface |
| **Function** | Stand-alone function |
| **Method** | Class/instance method |
| **Route** | Web-framework route handler |
| **Variable** | Global or local variable |

These labels are stored in the project schema as an array of `{ label, count }` objects under `schema.node_labels`, which the UI aggregates to display totals in the stats panel.

## How Node Labels Are Stored and Accessed

Project metadata exposes label statistics through the `schema.node_labels` property. Each entry contains the label name and the count of nodes of that type in the graph.

To access the label list for a project:

```typescript
// Assume `project` is a ProjectInfo obtained from the API
const labels = project.schema?.node_labels ?? [];
labels.forEach(l => console.log(`${l.label}: ${l.count}`));

```

This data structure is consumed by the `StatsTab` component to render the categorical breakdown of your codebase.

## Working with Node Labels in the UI

The React frontend uses the `colorForLabel` utility from [`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts) to maintain consistent visual identity for each node type.

### Rendering a Label Badge with Its Color

When displaying node labels as badges, the UI combines the label text with a color-derived background and foreground:

```tsx
import { colorForLabel } from '@/lib/colors';

function LabelBadge({ label, count }: { label: string; count: number }) {
  const bg = `${colorForLabel(label)}10`;   // semi-transparent background
  const fg = `${colorForLabel(label)}bb`;   // foreground colour
  return (
    <span
      className="inline-flex items-center gap-1 px-1.5 py-[2px] rounded-md text-[10px] font-medium"
      style={{ backgroundColor: bg, color: fg }}
    >
      <span className="w-[4px] h-[4px] rounded-full" style={{ backgroundColor: colorForLabel(label) }} />
      {label} {count.toLocaleString()}
    </span>
  );
}

```

### Filtering the Graph by Label

The `GraphTab` component allows users to toggle visibility of nodes by their labels. The implementation tracks active labels in a `Set` and filters the node list accordingly:

```typescript
const [activeLabels, setActiveLabels] = useState<Set<string>>(new Set());

function toggleLabel(label: string) {
  setActiveLabels(prev => {
    const next = new Set(prev);
    next.has(label) ? next.delete(label) : next.add(label);
    return next;
  });
}

// In the graph rendering logic
nodes.filter(node => activeLabels.has(node.label));

```

## Key Implementation Files

Understanding the node label system requires familiarity with these specific source files:

- **[`graph-ui/src/lib/types.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/types.ts)** – Defines the `GraphNode` interface (including the `label` field) and the `SchemaInfo.node_labels` shape.
- **[`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts)** – Maps each label to a specific hex color value; this file serves as the definitive list of supported labels.
- **[`graph-ui/src/components/StatsTab.tsx`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/components/StatsTab.tsx)** – Aggregates and displays node-label statistics for a project using the `schema.node_labels` data.
- **[`graph-ui/src/components/GraphTab.tsx`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/components/GraphTab.tsx)** – Uses `colorForLabel` to assign colors to nodes and provides the UI toggles for label-based filtering.

## Summary

- **Node labels** classify every `GraphNode` in Codebase-Memory-MCP by element type (File, Class, Function, etc.).
- The complete label set is defined in [`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts) and includes eleven distinct categories from Project to Variable.
- Label statistics are exposed via `schema.node_labels` as an array of `{ label, count }` objects.
- The UI uses **`colorForLabel`** to render consistent, color-coded badges and supports filtering the graph by label.
- Core implementation resides in [`types.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/types.ts), [`colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/colors.ts), [`StatsTab.tsx`](https://github.com/DeusData/codebase-memory-mcp/blob/main/StatsTab.tsx), and [`GraphTab.tsx`](https://github.com/DeusData/codebase-memory-mcp/blob/main/GraphTab.tsx).

## Frequently Asked Questions

### What is the complete list of node labels available in Codebase-Memory-MCP?

Codebase-Memory-MCP supports eleven node labels: Project, Package, Module, Folder, File, Class, Interface, Function, Method, Route, and Variable. These are defined in the color-mapping table located at [`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts) and represent the full taxonomy of source code elements tracked by the system.

### How do I query node label statistics for a project?

Label statistics are accessible via the `schema.node_labels` property on a `ProjectInfo` object. This property returns an array of objects where each entry contains a `label` string and a `count` number indicating how many nodes of that type exist in the graph. The `StatsTab` component consumes this data to display the categorical breakdown.

### Where are node label colors defined?

All label colors are centralized in [`graph-ui/src/lib/colors.ts`](https://github.com/DeusData/codebase-memory-mcp/blob/main/graph-ui/src/lib/colors.ts). This module exports the `colorForLabel` function, which returns a hex color string for any given label. This function is used by `GraphTab` for node rendering and by `StatsTab` for badge generation, ensuring visual consistency across the application.

### Can I filter the graph view by specific node labels?

Yes. The `GraphTab` component implements label filtering by maintaining a `Set<string>` of active labels. Nodes are filtered using `nodes.filter(node => activeLabels.has(node.label))`, allowing users to dynamically show or hide specific categories of code elements such as Classes, Functions, or Routes.