Hybrid LSP Type Resolution in codebase-memory-mcp: 9 Supported Languages Explained

The hybrid LSP type resolution engine in codebase-memory-mcp supports nine programming languages—Go, C, C++, Rust, Python, TypeScript/JavaScript/JSX/TSX, Java, Kotlin, and C#—each implemented in dedicated C modules under internal/cbm/lsp/.

The codebase-memory-mcp repository provides a robust hybrid LSP type resolution system that combines static analysis with Language Server Protocol capabilities to resolve identifiers across files. This engine handles imports, inheritance, and cross-module calls for nine major programming languages through individual resolver implementations written in C.

Supported Languages in Hybrid LSP Type Resolution

The hybrid LSP implementation provides dedicated resolver modules for nine languages. Each module is implemented as a C source file that handles language-specific parsing, import resolution, and cross-file type linking.

The supported languages and their corresponding source files are:

These nine languages are validated throughout the test suite, specifically in tests/test_node_creation_probe.c and tests/test_lsp_resolution_probe.c, confirming that the hybrid LSP type resolution works correctly across all supported targets.

Implementation Architecture

Core Resolution API

The entry point for hybrid LSP type resolution is the cbm_resolve_type() function, which dispatches to language-specific resolvers based on the language identifier string. This function accepts a language tag, file URI, and symbol name, then routes to the appropriate module.

/* Generic entry point for hybrid LSP resolution */
int cbm_resolve_type(struct cbm *cbm,
                     const char *lang,      // e.g. "go", "rust", "python", …
                     const char *uri,       // file URI
                     const char *symbol)    // identifier to resolve
{
    if (strcmp(lang, "go") == 0) {
        return go_lsp_resolve(cbm, uri, symbol);
    } else if (strcmp(lang, "rust") == 0) {
        return rust_lsp_resolve(cbm, uri, symbol);
    }
    /* … analogous branches for c, cpp, python, ts, java, kotlin, cs … */
    return -1;   // unknown or unsupported language
}

Language-Specific Resolvers

Each supported language implements a dedicated resolver function (e.g., go_lsp_resolve(), rust_lsp_resolve(), java_lsp_resolve()) within its respective module. These functions handle the intricacies of their target languages, including import resolution, namespace handling, and cross-module symbol linking.

Practical Usage Examples

To resolve a symbol using the hybrid LSP engine, call cbm_resolve_type() with the appropriate language identifier. Below is a typical usage pattern from the test suite in tests/test_lsp_resolution_probe.c:

/* Resolve a call site in a Go fixture */
int result = cbm_resolve_type(cbm, "go",
                              "file:///path/to/go/main.go",
                              "MyFunc");
assert(result == CBM_RESOLVED);

The same pattern applies to all nine languages. Only the language identifier and the underlying resolver implementation differ:

/* Resolving a Rust symbol */
int result = cbm_resolve_type(cbm, "rust",
                              "file:///path/to/rust/lib.rs",
                              "my_function");

/* Resolving a Python symbol */
int result = cbm_resolve_type(cbm, "python",
                              "file:///path/to/project/main.py",
                              "MyClass");

Key Source Files

The hybrid LSP type resolution subsystem consists of several critical components:

Summary

  • codebase-memory-mcp supports nine languages through hybrid LSP type resolution: Go, C, C++, Rust, Python, TypeScript/JavaScript/JSX/TSX, Java, Kotlin, and C#.
  • Each language has a dedicated implementation file in internal/cbm/lsp/ (e.g., go_lsp.c, rust_lsp.c).
  • The cbm_resolve_type() function provides the central dispatch mechanism to route resolution requests to language-specific handlers.
  • Common data structures in type_rep.c ensure consistent type representation across all languages.
  • The implementation is validated by dedicated test probes that verify correct resolution behavior for each supported language.

Frequently Asked Questions

Does hybrid LSP type resolution support C++ separately from C?

Yes. While C and C++ share some architectural patterns, they have separate implementation files: internal/cbm/lsp/c_lsp.c for C and internal/cbm/lsp/cpp_lsp.c for C++. The C++ resolver handles C++-specific features such as classes, templates, and namespaces while utilizing the same underlying hybrid LSP framework.

How does the system handle TypeScript and JavaScript variants?

TypeScript, JavaScript, JSX, and TSX are all handled by a single module: internal/cbm/lsp/ts_lsp.c. This unified approach treats all ECMAScript variants through one resolver, distinguishing between them internally while exposing a consistent interface to the core cbm_resolve_type() function.

What function handles the dispatch to language-specific resolvers?

The cbm_resolve_type() function in the core framework handles dispatch. It accepts a language identifier string (e.g., "go", "rust", "python") and routes the resolution request to the appropriate language-specific function such as go_lsp_resolve() or rust_lsp_resolve().

Where are the hybrid LSP resolvers tested?

The resolvers are tested in tests/test_lsp_resolution_probe.c, which verifies type resolution across all nine languages, and tests/test_node_creation_probe.c, which validates that the LSP integration correctly creates graph nodes for symbols in each supported language.

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 →