Languages Supported by the Hybrid LSP in CBM: Complete Technical Reference

TLDR: The hybrid Language Server Protocol (LSP) implementation in Codebase-Memory-MCP (CBM) currently supports seven programming languages—Python, Go, Rust, JavaScript/TypeScript, Java, C/C++, and PHP—each backed by a dedicated driver defined in internal/cbm/lsp/cbmlsp.h and registered via register_lsp_drivers() in internal/cbm/lsp/cbmlsp.c.

The hybrid LSP in CBM bridges static analysis with real-time language server queries to resolve call graphs across polyglot repositories. According to the DeusData/codebase-memory-mcp source code, language support is hardcoded in the LSPLanguage enum and implemented through isolated driver modules under internal/cbm/lsp/drivers/.

Core Language Enumeration in cbmlsp.h

In internal/cbm/lsp/cbmlsp.h, the LSPLanguage enum explicitly lists every supported language alongside implementation limits:

#define LSP_MAX_INFERENCE_DEPTH 64
#define LSP_MAX_WALK_DEPTH 2000

typedef enum {
  LSP_NONE,
  LSP_PY,    // Python
  LSP_GO,    // Go
  LSP_RUST,  // Rust
  LSP_JS,    // JavaScript/TypeScript
  LSP_JAVA,  // Java
  LSP_C,     // C/C++
  LSP_PHP,   // PHP
  LSP_MAX
} LSPLanguage;

This enumeration drives the hybrid resolution pipeline, where LSP_NONE signifies pure static analysis and specific values like LSP_PY trigger the corresponding language server integration.

Supported Language Breakdown

The hybrid LSP resolves symbols for the following languages:

Each driver translates LSP-specific JSON responses into CBM’s internal type system, enabling cross-language call-graph edges.

Driver Registration Architecture

The register_lsp_drivers() function in internal/cbm/lsp/cbmlsp.c maps each enum value to its driver at runtime:

void register_lsp_drivers(void) {
  lsp_register_driver(LSP_PY,   "python",    ...);
  lsp_register_driver(LSP_GO,   "go",        ...);
  lsp_register_driver(LSP_RUST, "rust",      ...);
  lsp_register_driver(LSP_JS,   "typescript",...);
  lsp_register_driver(LSP_JAVA, "java",      ...);
  lsp_register_driver(LSP_C,    "c",         ...);
  lsp_register_driver(LSP_PHP,  "php",       ...);
}

This registration pattern decouples language-specific logic from the core resolver, allowing the hybrid engine to query the appropriate LSP server based on the source file extension or shebang detection.

Practical Usage: Enabling LSP Resolution

To activate the hybrid LSP for a specific language in your project, initialize the drivers and enable the desired language flag before resolving calls:

#include "internal/cbm/lsp/cbmlsp.h"

int main(void) {
    /* Register all language drivers once */
    register_lsp_drivers();

    /* Load project and enable TypeScript/JS hybrid resolution */
    CBMProject *proj = cbm_load_project("src/example.ts");
    cbm_enable_lsp(proj, LSP_JS);

    /* Build call graph using both static and LSP-derived types */
    cbm_resolve_calls(proj);
    cbm_print_graph(proj);

    return 0;
}

In this workflow, cbm_enable_lsp() toggles hybrid resolution for the specified LSPLanguage, while cbm_resolve_calls() transparently falls back to static analysis when the LSP server is unavailable or when LSP_MAX_INFERENCE_DEPTH is exceeded.

Summary

  • The hybrid LSP in CBM supports seven languages: Python, Go, Rust, JavaScript/TypeScript, Java, C/C++, and PHP.
  • Language constants are defined in internal/cbm/lsp/cbmlsp.h via the LSPLanguage enum.
  • Each language has a dedicated driver under internal/cbm/lsp/drivers/ (e.g., python.c, go.c).
  • Drivers are registered centrally in internal/cbm/lsp/cbmlsp.c through register_lsp_drivers().
  • Enable hybrid resolution programmatically using cbm_enable_lsp() with the appropriate enum value (e.g., LSP_RUST).

Frequently Asked Questions

Can the hybrid LSP in CBM support languages beyond the seven listed?

No. According to the source code in internal/cbm/lsp/cbmlsp.h, the LSPLanguage enum terminates at LSP_MAX, and the register_lsp_drivers() function in cbmlsp.c only initializes the seven specific drivers. Adding a new language requires extending the enum, implementing a new driver in internal/cbm/lsp/drivers/, and registering it in cbmlsp.c.

How does CBM distinguish between C and C++ in the hybrid LSP?

The LSP_C enum value covers both C and C++ within a single driver implemented in drivers/c.c. The underlying LSP server (typically clangd) handles dialect detection based on file extensions (.c vs .cpp), while CBM treats both as the LSP_C language type for resolution purposes.

What limits does CBM impose on LSP inference depth?

The hybrid resolver enforces a maximum inference depth of 64 levels (LSP_MAX_INFERENCE_DEPTH) and a maximum AST walk depth of 2000 (LSP_MAX_WALK_DEPTH), as defined in internal/cbm/lsp/cbmlsp.h. These guards prevent infinite recursion or excessive memory consumption when traversing deeply nested generic types or circular dependencies.

Is it possible to enable multiple hybrid LSP languages in the same project?

Yes. You can call cbm_enable_lsp() multiple times with different enum values (e.g., LSP_PY for Python files and LSP_JAVA for Java files) within the same CBMProject instance. The resolver routes each source file to its registered driver based on the detected language, allowing seamless cross-language call-graph construction.

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 →