MCP server exposing NestJS dev server logs to AI coding agents (Claude Code, Cursor, Codex)
nestjs-dev-logs-mcp
An MCP server that exposes NestJS development server logs to AI coding agents (Claude Code, Cursor, Codex). Reads log files produced by a NestJS dev server and provides structured, filterable access through 7 MCP tools.
Setup
1. Pipe NestJS logs to a file
# Option A: pipe via tee (keeps terminal output)
nest start --watch 2>&1 | tee /tmp/nest-dev.log
# Option B: redirect to file
nest start --watch > /tmp/nest-dev.log 2>&1
2. Build the server
npm install
npm run build
3. Configure your MCP client
Claude Code (~/.claude/claude_desktop_config.json or project .mcp.json):
{
"mcpServers": {
"nestjs-logs": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "/path/to/nestjs-dev-logs-mcp",
"env": {
"NEST_LOG_PATH": "/tmp/nest-dev.log"
}
}
}
}
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"nestjs-logs": {
"command": "node",
"args": ["/path/to/nestjs-dev-logs-mcp/dist/index.js"],
"env": {
"NEST_LOG_PATH": "/tmp/nest-dev.log"
}
}
}
}
Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| NEST_LOG_PATH | /tmp/nest-dev.log | Path to the NestJS log file |
| NEST_LOG_FORMAT | auto | auto, text, or json |
| NEST_LOG_MAX_LINES | 10000 | Max lines to scan per query |
| NEST_LOG_TAIL_BYTES | 1048576 | Bytes to read from file end (1MB) |
Tools
get_recent_errors
Get recent errors and exceptions from logs.
since_minutes— only errors from the last N minutesmodule— filter by NestJS module namelimit— max errors to return (default 20, max 100)
get_request_logs
Get HTTP request logs.
status_code— filter by exact status codestatus_range— filter by range:2xx,3xx,4xx,5xxpath_pattern— regex to match request pathsmethod— filter by HTTP methodmin_duration_ms— only requests slower than N mssince_minutes,limit
get_db_queries
Get database query logs (TypeORM, Prisma, Mongoose).
min_duration_ms— only slow queriesfailed_only— only failed queriestable_pattern— regex to match table namessince_minutes,limit
get_di_errors
Get NestJS dependency injection resolution errors.
since_minutes,limit
tail_logs
Get the last N lines from the log file (escape hatch for raw access).
lines— number of lines (default 50, max 500)grep— regex to filter lines
get_log_summary
Health check — counts by severity, top error patterns, status code distribution.
since_minutes
truncate_logs
Clear the log file. Uses file truncation (not deletion) so NestJS keeps writing.
confirm— must betrue
Supported Log Formats
NestJS text (default logger):
[Nest] 12345 - 04/16/2026, 10:30:00 AM LOG [HTTP] GET /api/users 200 12ms
nestjs-pino JSON (recommended for full request data):
{"level":30,"time":1713254465000,"msg":"GET /api/users 200","req":{"method":"GET","url":"/api/users"},"res":{"statusCode":200},"responseTime":12}
Format is auto-detected by sampling lines. Use NEST_LOG_FORMAT to override.
Development
npm run dev # run with tsx (hot reload)
npm test # vitest
npm run test:watch # vitest --watch
npm run build # tsc → dist/
Multiple Log Files
For multiple NestJS services, configure a separate MCP server entry per log file:
{
"mcpServers": {
"api-logs": {
"command": "node",
"args": ["dist/index.js"],
"env": { "NEST_LOG_PATH": "/tmp/api-dev.log" }
},
"worker-logs": {
"command": "node",
"args": ["dist/index.js"],
"env": { "NEST_LOG_PATH": "/tmp/worker-dev.log" }
}
}
}