Skip to main content
Glama
dmchet

PasNavigator MCP

by dmchet
README.md
# PasNavigator MCP

MCP server for semantic navigation in Delphi/Pascal codebases.

The long-term design is:

- Delphi-based indexer/backend that reuses ideas and code from `CodeComparer`
- thin MCP server layer that exposes project indexing and symbol navigation tools
- compact symbol-level responses for AI agents instead of raw grep output

## Current status

This repository contains:

- Python MCP tool surface and process adapter
- Delphi console backend with vendored CodeComparer/DelphiAST sources under `delphi/vendor/codecomparer/`
- no runtime dependency on a live CodeComparer repository checkout

DevExpress VCL is still required to compile the Delphi indexer (`DXVCL`).

The vendored importer carries a few local changes so that `defines` and
`unit_scopes` reach the parser; they are listed in
`delphi/vendor/codecomparer/NOTICE.txt`.

Docs:

- protocol: `docs/delphi-backend-protocol.md`
- Delphi build: `delphi/README.md`

## Tools

- `open_project`, `open_project_from_config`
- `project_status`
- `find_symbol` — ranked, capped, reports `total_count`
- `get_symbol`
- `get_hierarchy`
- `get_descendants`
- `get_source`

## Configuration

Example project configuration:

```json
{
  "project_name": "MyApp",
  "roots": [
    "E:/Work/MyApp/Source",
    "E:/Work/MyApp/Modules"
  ],
  "search_paths": [
    "E:/Libs/Common",
    "C:/RAD/Studio/22.0/source/vcl"
  ],
  "defines": ["MSWINDOWS", "VER350"],
  "unit_scopes": ["System", "Vcl", "Winapi"],
  "excludes": ["**/__history/**", "**/backup/**"]
}
```

## Development

Create a virtual environment and install the package in editable mode:

```powershell
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -e .
```

Run the server with the in-memory stub:

```powershell
python -m pasnavigator_mcp
```

Talk to the Delphi console backend (stub build, no DevExpress):

```powershell
$env:PASNAVIGATOR_BACKEND = "delphi"
$env:PASNAVIGATOR_DELPHI_EXE = "E:\Github_dm75\PasNavigator_MCP\delphi\bin\Win32\Debug\PasNavigatorBackend.exe"
python -m pasnavigator_mcp
```

Run the tests. Cases that need the compiled backend skip themselves when
`PasNavigatorBackend.exe` is missing; the rest run against a Python fake
process:

```powershell
python -m unittest discover -s tests
```

## Next step

The MCP layer itself (`server.py`, `config.py`) has no test coverage, because
the `mcp` dependency has not been installable in this environment.