Skip to main content
Glama

nest-atlas

Stop letting AI guess your NestJS app.

nest-atlas is an MCP server that lets AI coding agents (Claude Code, Cursor, and any other MCP client) ask your NestJS application what it is made of: modules, providers, who injects whom, routes, DTOs, entities, event handlers and config keys. The answers come from the module graph NestJS itself builds, joined with what the source says.

An agent reading files sees classes. It does not see that ConfigModule is global, that a repository is registered only for one module, that an app-wide guard runs before every route, or that the import it is about to add closes a cycle. Those are the things it gets wrong: a provider that is never registered, a service duplicated because the existing one was not found, a "can't resolve dependencies" error on the next boot.

> how_to_use { provider: "OrdersService", module: "UsersModule" }

OrdersService (src/orders/orders.service.ts:8) is provided by OrdersModule.
No: UsersModule cannot inject it yet. To make it injectable:
1. Add OrdersService to the exports of OrdersModule.
2. Add OrdersModule to the imports of UsersModule.
3. Careful: OrdersModule already imports UsersModule (directly or through other modules),
   so this creates a circular dependency. Prefer moving the shared logic to a third module,
   or emit an event; forwardRef() on both sides is the last resort.

Install

npm install -D https://github.com/gustavolovizotto/nest-atlas/releases/download/v2.0.0/nest-atlas-2.0.0.tgz
npx nest-atlas init

The package is not on the npm registry yet, so it installs from the release file.

init adds the server to your project's .mcp.json. Restart your agent in the project and it will find the tools. To check that your project can be mapped, and what to fix if it cannot:

npx nest-atlas doctor

Requirements: Node.js 20 or newer, NestJS 10, 11 or 12, Express or Fastify.

Related MCP server: Carto MCP Server

Tools

Tool

Question it answers

app_overview

What is this app? Modules, global modules, app-wide enhancers, what main.ts sets

list_modules

Which modules exist and what does each import and hold?

describe_module

What does this module provide, export and expose, and what can it inject?

list_routes

Which HTTP routes exist, who handles them, what guards them?

describe_route

What are this route's parameters, body and response fields, validators and decorators?

find_provider

Does something like this already exist? Where, and how do I inject it?

who_injects

What depends on this provider, and what does it depend on?

how_to_use

Can module X inject provider Y? If not, what exactly has to change?

list_entities / describe_entity

What is the data model? (TypeORM)

list_handlers

What runs outside HTTP: event listeners, cron jobs, queue processors?

config_keys

Which environment variables does the app read, and where?

diagnose

Circular imports, duplicate registrations, unused providers, unguarded routes

add_note

Record what the code does not show about a module, route, provider or entity

list_notes

Browse the team's notes and find the ones whose target no longer exists

Every tool is read-only except add_note, which writes one file in .atlas/notes/. Answers are short text with file:line locations.

> describe_route { path: "/users", method: "POST" }

POST /users
Handled by UsersController.create in UsersModule (src/users/users.controller.ts:23)
Runs through: guard AuthGuard (app-wide)

Parameters:
  body dto: CreateUserDto

Returns: UserResponseDto

Input:
  CreateUserDto (src/users/dto/create-user.dto.ts:3)
    name: string  @IsString @MaxLength(120)
    email: string  @IsEmail
    nickname?: string  @IsOptional @IsString

Guidelines for agents, generated from the app

npx nest-atlas guidelines

Writes a section into your AGENTS.md and CLAUDE.md (creating AGENTS.md if neither exists) that describes how this app is wired: the modules with their imports and exports, the direction of dependencies between them, what applies to every route, where files go, and the project's commands. It is written from the map, not from a template, and each convention comes with how many cases follow it:

- `OrdersModule` (`src/orders/orders.module.ts`): imports `UsersModule`; exports nothing; 2 routes
- `AuthGuard` (guard) runs on every route; it is registered in `AppModule`. Do not add it to controllers.
- Inside a module folder: services in `services/` (all 8); DTOs in `dto/` (26 of 29).
- Tests live in a `__tests__/` folder next to the code (46 of 47 test files).

The section sits between two markers. Everything outside them is yours and is never touched.

npx nest-atlas guidelines --check exits 1 when the section no longer matches the app, so CI can catch instructions that went stale. --print shows the section without writing; --file <name> picks the file.

It states what the code shows. Rules about intent (why a boundary exists, how to write a migration, what language to name things in) still have to be written by a person.

Team notes, anchored to the code

Some knowledge is not in the code: why a boundary exists, a trap someone fell into, a constraint from outside. Agents rediscover it every session, or never do.

With add_note an agent (or you, by writing the file) records it against the thing it is about:

> add_note { anchor: "module:UsersModule", title: "Users are soft-deleted",
             body: "Never issue DELETE on the users table. Use the archive flow instead." }

Saved .atlas/notes/usersmodule-users-are-soft-deleted.md, anchored to module:UsersModule.

From then on the note comes with every answer about that module, for every person and agent on the team:

> describe_module { name: "UsersModule" }

UsersModule (src/users/users.module.ts:11)
...
Team notes (1), written by people and agents who worked on this:
- Users are soft-deleted [2026-11-28]
    Never issue DELETE on the users table. Use the archive flow instead.

Notes are plain Markdown files in .atlas/notes/, meant to be committed and reviewed like code. An anchor is module:<Name>, provider:<Name>, route:<METHOD> <path>, entity:<Name> or app.

Because the anchor is checked against the app's map, a note does not silently rot: when the module, route or class it describes is renamed or removed, the note is reported as orphaned.

npx nest-atlas notes --check   # exits 1 if a note points at something that no longer exists

Notes are text that agents will read later. Review them in pull requests the way you review code, and do not put secrets in them.

How it works

Two engines build one map of your app.

The runtime engine loads your root module in a separate process, in NestJS preview mode, and reads the graph Nest assembles. In preview mode providers and controllers are not instantiated: no constructor runs, no database connection opens, nothing listens on a port. This is the authority on wiring, because it is what Nest will actually do, dynamic modules and library internals included.

The static engine reads your TypeScript source for what the graph does not carry: line numbers, handler signatures, DTO fields and validators, your own decorators, entities, config keys, and what main.ts sets on the app.

If the app cannot be loaded (a missing .env, a project that is not built), the map is built from the source alone and every answer says so.

The map is cached and rebuilt only when a source file changes, so each answer reflects the code as it is right now.

What it does not do

  • It never changes your source code, your database or your configuration.

  • It makes no network requests and collects no telemetry.

  • It never prints the value of an environment variable, only its name.

  • Installing it runs no script and writes nothing to your project. It writes in three places, each only when asked: init writes .mcp.json, guidelines writes its own section of your agent files, and add_note writes a file in .atlas/notes/.

Code that runs while your files are being imported (top-level statements, forRoot() calls) does run, as it would in any tool that loads your app.

Does it help?

I measured it on a private NestJS 11 app of about 100 source files: 16 questions about the app's structure, each asked twice in a fresh read-only Claude Code session (Sonnet), with and without nest-atlas. 64 sessions in total.

Without

With nest-atlas

Correct answers

30 of 32

32 of 32

Round trips per question (mean)

3.9

2.4

Time per question (mean)

10.0 s

7.7 s

Cost of the whole set

$0.81

$0.53

What this does and does not show:

  • On an app this size the agent is already right most of the time by reading files. The gain is mostly speed and cost, about a third less of each.

  • The one question it got wrong both times without the tool was "which modules are global?". The answer lives in how libraries behave at runtime, which is not in your source.

  • The tool has a fixed cost: its definitions took about 2,500 tokens per request when this was measured, with 13 tools, and take about 3,100 now, with 15. For a one-file lookup the agent was cheaper without it (6 of the 16 questions).

  • I wrote the questions, and they are the structural kind the tool is built for. This is not a benchmark of coding ability, and I have not measured larger apps or code-writing tasks.

Method, per-question numbers and the harness to run it on your own app: docs/EVALUATION.md.

Limits

  • Dynamic modules (forRoot, forFeature) build their providers at runtime. With the runtime engine they are fully mapped; in source-only mode their contents are missing.

  • Entities: TypeORM only. Prisma, Drizzle and Mongoose are not read yet.

  • Config keys read through a computed name or a validated config object are not detected.

  • Types come from the annotation as written; an inferred type shows as unknown.

  • list_handlers shows who listens, not who emits.

  • The app is loaded with ts-node or from the compiled build. tsx is not supported: esbuild does not emit the decorator metadata Nest's injection needs.

  • GraphQL resolvers and microservice transports are not mapped as routes.

Commands

nest-atlas init [--print]    Register the MCP server in this project's .mcp.json
nest-atlas mcp               Start the MCP server on stdio (what your AI agent runs)
nest-atlas map [--json]      Print a map of the app
nest-atlas doctor            Check that this project can be mapped, and what to fix if not
nest-atlas guidelines        Write how the app is wired into AGENTS.md / CLAUDE.md (--check, --print, --file)
nest-atlas notes [--check]   List the team notes and flag the ones whose target no longer exists

--cwd <dir> points at another project. --entry <file>#<ExportName> names the root module when it is not src/app.module.ts#AppModule.

Development

npm install
npm run fixtures:install   # NestJS 11 fixtures, plus NestJS 10, NestJS 12 and Fastify apps
npm test

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers