Skip to main content
Glama
ayabenz

NAV 2015 FastMCP Server

by ayabenz
README.md
# NAV 2015 FastMCP Server

Production-ready FastMCP server for read-only Dynamics NAV 2015 analytics. The external MCP tool behavior is preserved while the code is split into Clean Architecture layers.

## Tools

- `get_user_detail(emp_no: str)`
- `get_user_permissions()`
- `list_accessible_tables()`
- `get_table_schema(navision_table_name: str)`
- `execute_autonomous_readonly_query(sql_query: str)`

## Architecture

- `core/`: configuration, database context manager, structured logging, exceptions, sessions, cache
- `models/`: immutable dataclass domain models
- `repositories/`: database and metadata access
- `services/`: workflow rules, validation, and application behavior
- `orchestrator/`: JSON contract preservation and service coordination
- `tools/`: FastMCP tool registration
- `resources/`: NAV object whitelist metadata
- `tests/`: regression tests for workflow and SQL safety behavior

## Configuration

Copy `.env.example` to `.env` and set the NAV SQL Server connection details.

```powershell
Copy-Item .env.example .env
```

Important variables:

- `NAV_CONNECTION_STRING`: pyodbc SQL Server connection string
- `NAV_COMPANY_PREFIX`: NAV company table prefix used in metadata responses
- `MCP_HOST` and `MCP_PORT`: SSE host and port
- `QUERY_ROW_LIMIT`: maximum rows returned by read-only query execution

## Run

Install with Python 3.13.5:

```powershell
python -m pip install -e ".[dev]"
```

Run local stdio transport:

```powershell
python app.py
```

Run SSE transport:

```powershell
python app.py sse
```

The legacy launcher still works:

```powershell
python nav2015_auto_sql_fastapi.py sse
```

## Test And Quality

```powershell
python -m unittest discover -s tests -v
python -m ruff format .
python -m ruff check .
```

## Docker

```powershell
docker build -t nav-2015-fastmcp .
docker run --env-file .env -p 8000:8000 nav-2015-fastmcp
```