# How to Configure Custom File Extensions for Unsupported Languages in Codebase-Memory-MCP

> Learn how to configure custom file extensions for unsupported languages in Codebase-Memory-MCP. Modify the new-languages.json file and regenerate C lookup tables for seamless integration.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: how-to-guide
- Published: 2026-07-30

---

**To configure custom file extensions for unsupported languages in Codebase-Memory-MCP, edit the [`scripts/new-languages.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/new-languages.json) manifest to add your extensions, run [`./scripts/generate-lang-code.py`](https://github.com/DeusData/codebase-memory-mcp/blob/main/./scripts/generate-lang-code.py) to regenerate the C lookup tables, and paste the output into [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c) before rebuilding.**

The **Codebase-Memory-MCP** project (also referred to as Instagit) uses a declarative language manifest system to manage file type detection. Instead of hardcoding extensions directly into the discovery engine, the project maintains a central JSON registry that drives automatic code generation for the underlying C tables. This architecture allows you to configure custom file extensions for any language—including those not yet natively supported—without modifying complex parser logic.

## Understanding the Language Manifest System

At the core of the extension system lies [`scripts/new-languages.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/new-languages.json), a language manifest that defines every supported grammar. Each entry contains metadata fields—including `"name"`, `"enum"`, and **"extensions"**—that map file suffixes to internal language identifiers.

When you modify this manifest, the helper script [`scripts/generate-lang-code.py`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/generate-lang-code.py) processes your changes and outputs C boilerplate. Specifically, it regenerates the `EXT_TABLE` entries found in [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c), which the runtime uses to classify files during the discovery phase.

## Step-by-Step Configuration Guide

Follow this workflow to add custom extensions for existing languages or introduce entirely new language support.

### Edit the Language Manifest

Locate the language definition in [`scripts/new-languages.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/new-languages.json) (or create a new JSON object for unsupported languages). Add your custom extensions to the `"extensions"` array:

```json
{
  "name": "mylang",
  "enum": "MYLANG",
  "display": "MyLang",
  "ts_func": "tree_sitter_mylang",
  "repo": "https://github.com/example/tree-sitter-mylang",
  "subdir": "",
  "extensions": [".mlg", ".myext"],
  "filenames": [],
  "has_scanner": false,
  "module_root": "source_file"
}

```

For existing languages, simply append to the existing array. For example, adding `.jsx` to JavaScript requires updating the `"javascript"` entry to include `".jsx"` alongside `".js"`, `".cjs"`, and `".mjs"`.

### Regenerate the Language Tables

Run the generator script from the repository root to produce updated C code:

```bash

# Regenerate all language components

./scripts/generate-lang-code.py

# Or update only the extension tables

./scripts/generate-lang-code.py language

```

The script outputs formatted `EXT_TABLE` entries ready for insertion. You will see output similar to:

```c
/* MyLang */
{".mlg", CBM_LANG_MYLANG},
{".myext", CBM_LANG_MYLANG},

```

### Update the C Source Files

Open [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c) and locate the `EXT_TABLE` definition (around line 30). Insert the generated lines in alphabetical order to maintain the sorted structure required by the discovery engine:

```c
static const ext_entry_t EXT_TABLE[] = {
    /* ... existing entries ... */
    /* MyLang */
    {".mlg", CBM_LANG_MYLANG},
    {".myext", CBM_LANG_MYLANG},
    /* ... remaining entries ... */
};

```

### Rebuild the Project

Execute your standard build command (e.g., `make` or the repository-specific build script). The build system compiles the updated [`language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/language.c) with your new extension mappings, making them available to the file discovery logic immediately.

## Practical Configuration Examples

### Adding Extensions to an Existing Language

To add `.jsx` support to the existing JavaScript entry, modify [`scripts/new-languages.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/new-languages.json):

```json
{
  "name": "javascript",
  "enum": "JAVASCRIPT",
  "display": "JavaScript",
  "ts_func": "tree_sitter_javascript",
  "repo": "https://github.com/tree-sitter/tree-sitter-javascript",
  "subdir": "",
  "extensions": [".js", ".cjs", ".mjs", ".jsx"],
  "filenames": [],
  "has_scanner": false,
  "module_root": "program"
}

```

After running `./scripts/generate-lang-code.py language`, paste the generated lines into [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c):

```c
/* JavaScript */
{".cjs",  CBM_LANG_JAVASCRIPT},
{".js",   CBM_LANG_JAVASCRIPT},
{".jsx",  CBM_LANG_JAVASCRIPT},
{".mjs",  CBM_LANG_JAVASCRIPT},

```

### Adding a Completely New Language

For unsupported languages, create a full entry in the manifest:

```json
{
  "name": "mynewlang",
  "enum": "MYNEWLANG",
  "display": "MyNewLang",
  "ts_func": "tree_sitter_mynewlang",
  "repo": "https://github.com/example/tree-sitter-mynewlang",
  "subdir": "",
  "extensions": [".mnl", ".mnx"],
  "filenames": [],
  "has_scanner": true,
  "module_root": "source_file"
}

```

Run the generator and update [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c) with the new `EXT_TABLE` entries as shown in the previous steps.

## Summary

- **Codebase-Memory-MCP** manages file extensions through the declarative manifest at [`scripts/new-languages.json`](https://github.com/DeusData/codebase-memory-mcp/blob/main/scripts/new-languages.json).
- The **`"extensions"`** field in the JSON maps file suffixes to language enums.
- Running **[`./scripts/generate-lang-code.py`](https://github.com/DeusData/codebase-memory-mcp/blob/main/./scripts/generate-lang-code.py)** automates the creation of C table entries found in [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c).
- The **`EXT_TABLE`** in [`language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/language.c) requires manual insertion of generated lines in alphabetical order.
- Rebuild the project after updating the C tables to activate new file extension support.

## Frequently Asked Questions

### What file format does the language manifest use?

The manifest uses standard **JSON**. Each language object contains string fields for metadata and array fields for `"extensions"` and `"filenames"`, making it easy to version control and validate.

### Do I need to manually edit C code to add custom extensions?

Yes, but only minimally. While the **[`generate-lang-code.py`](https://github.com/DeusData/codebase-memory-mcp/blob/main/generate-lang-code.py)** script automates the generation of C syntax, you must manually paste the output into [`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c) at the correct location within `EXT_TABLE`. This ensures the sorted order required by the discovery engine's lookup logic.

### Can I add multiple extensions for the same language?

Absolutely. The **`"extensions"`** field accepts an array of strings. You can define as many file suffixes as needed for a single language—the generator will create separate `EXT_TABLE` entries for each extension pointing to the same language enum.

### Where is the extension-to-language mapping stored at runtime?

The runtime mapping lives in **[`src/discover/language.c`](https://github.com/DeusData/codebase-memory-mcp/blob/main/src/discover/language.c)** within the `EXT_TABLE` constant array. This table is compiled into the binary and consulted during the file discovery phase to classify each file path into the correct Tree-sitter grammar.