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

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. 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:

// 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 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:

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:

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:

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 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, colors.ts, StatsTab.tsx, and 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 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. 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.

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 →