local-lens-cli
v0.1.0
Published
Universal CLI tool to capture server logs from any backend framework
Maintainers
Readme
Local Lens CLI
Universal CLI tool to capture server logs from any backend framework and forward them to Local Lens.
Features
- Framework-agnostic: Works with any backend (Rails, Express, Django, FastAPI, Laravel, etc.)
- Zero configuration: No setup required, just wrap your server command
- Real-time forwarding: Logs appear immediately in Local Lens MCP tools
- Process management: Graceful start/stop with proper signal handling
Installation
Install globally via npm:
npm install -g @local-lens/cliOr build locally with Local Lens:
npm run build:allUsage
Basic Usage
Wrap any server command with local-lens capture:
# Rails server
local-lens capture "rails server"
# Express/Node.js
local-lens capture "npm start"
# Django
local-lens capture "python manage.py runserver"
# FastAPI
local-lens capture "uvicorn main:app --reload"
# Any command with arguments
local-lens capture "rails server" "-p" "4000"Options
# Custom process name for logs
local-lens capture "rails server" --name "my-api"
# Custom Local Lens server URL
local-lens capture "npm start" --server "http://localhost:27497"
# Silent mode (suppress Local Lens output)
local-lens capture "rails server" --silentStatus Check
Check if Local Lens server is running:
local-lens statusExamples
Rails Development
# Start Rails server with log capture
local-lens capture "rails server" --name "rails-api"Your Rails logs (including ActiveRecord queries) will now appear in Local Lens with source: backend-console.
Express Development
# Start Express server with log capture
local-lens capture "npm run dev" --name "express-server"Django Development
# Start Django server with log capture
local-lens capture "python manage.py runserver" --name "django-api"Integration with Local Lens
Once your server is running with Local Lens CLI, you can query the logs using MCP tools:
// Get all backend console logs
get_console_logs({ source: "backend-console" })
// Search for specific logs from your process
search_logs({ query: "error", source: "backend-console", backendProcess: "rails-api" })
// Get logs from a specific process
get_console_logs({ backendProcess: "express-server" })How It Works
- Process Wrapping: CLI spawns your server process and captures stdout/stderr
- Log Formatting: Formats logs according to Local Lens schema with metadata
- Real-time Forwarding: Sends logs to Local Lens server via HTTP API
- Source Tagging: Tags all logs with
source: "backend-console"for filtering
Process Management
- Graceful Shutdown: Ctrl+C properly terminates the wrapped process
- Signal Forwarding: SIGTERM and SIGINT are forwarded to your server
- Exit Codes: Preserves original process exit codes
- Error Handling: Captures and reports process startup errors
This allows you to capture server logs from any backend framework without modifying your application code.
