Labsco
mariosss logo

Local Logs MCP Server

โ˜… 4

from mariosss

MCP for monitoring local application logs with real-time tailing, error tracking, and log search capabilities.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

Local Logs MCP Server

A Model Context Protocol (MCP) server for monitoring local application logs with real-time tailing, error tracking, and log search capabilities.

Perfect for monitoring Node.js applications, web servers, or any application that writes to log files.

License Node Version

โœจ Features

  • ๐Ÿ“ Log File Discovery - Automatically finds and lists available log files
  • ๐Ÿ“œ Real-time Log Tailing - Get the last N lines from any log file
  • โš ๏ธ Error Monitoring - Quickly check error logs for issues
  • ๐Ÿ“Š Server Status - Get server status summary from log analysis
  • ๐Ÿ‘€ Log Watching - Monitor log files for changes
  • ๐Ÿ” Log Search - Search for specific text patterns in logs
  • ๐Ÿ”ง Configurable - Supports custom log directories and file extensions
  • ๐Ÿš€ Easy Setup - Works with Cursor, Claude Desktop, VS Code Copilot, and more

๐Ÿ› ๏ธ Available Tools

ToolDescriptionParameters
get_log_filesList available log files with metadataNone
tail_logGet last N lines from a log filefilename, lines
get_errorsGet recent error log entrieslines
get_server_statusServer status summary from logsNone
watch_logMonitor log file for changesfilename
search_logsSearch for text in log filesquery, filename, lines

๐Ÿ”ง Environment Variables

VariableDescriptionDefault
LOGS_DIRDirectory containing log filesAuto-detected (see below)
LOG_EXTENSIONSComma-separated log file extensions.log,.txt

Log Directory Auto-Detection

If LOGS_DIR is not specified, the server automatically searches for logs in this priority order:

  1. ./logs (current directory)
  2. ./apps/backend/logs (monorepo structure)
  3. ./server/logs (server directory)
  4. ./backend/logs (backend directory)
  5. /var/log (system logs on Linux/Mac)
  6. C:\logs (system logs on Windows)

๐Ÿ—๏ธ Project Structure Examples

Standard Node.js Project

your-project/
โ”œโ”€โ”€ logs/
โ”‚   โ”œโ”€โ”€ combined.log    # Main application log
โ”‚   โ”œโ”€โ”€ error.log      # Error log
โ”‚   โ””โ”€โ”€ access.log     # Access log (optional)
โ”œโ”€โ”€ .cursor/
โ”‚   โ””โ”€โ”€ mcp.json       # MCP configuration
โ”œโ”€โ”€ src/
โ””โ”€โ”€ package.json

Monorepo Structure

your-monorepo/
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ backend/
โ”‚       โ””โ”€โ”€ logs/
โ”‚           โ”œโ”€โ”€ combined.log
โ”‚           โ””โ”€โ”€ error.log
โ”œโ”€โ”€ .cursor/
โ”‚   โ””โ”€โ”€ mcp.json
โ””โ”€โ”€ package.json

๐Ÿ” Supported Log Formats

The server works with any text-based log files and can parse:

  • Winston logs (JSON and text format)
  • Morgan access logs
  • Pino logs
  • Bunyan logs
  • Custom application logs
  • System logs
  • Any .log or .txt files

Example Log Formats

Winston Text Format:

2024-01-15 10:30:45 [INFO]: Server started on port 3000
2024-01-15 10:30:50 [ERROR]: Database connection failed

Winston JSON Format:

{"level":"info","message":"Server started","timestamp":"2024-01-15T10:30:45.123Z"}
{"level":"error","message":"Database connection failed","timestamp":"2024-01-15T10:30:50.456Z"}

๐Ÿ›ก๏ธ Security

  • Read-only access - Server only reads log files, never writes or modifies
  • Directory scoping - Only accesses files in the specified logs directory
  • No network access - Operates entirely on local files
  • Permission respect - Respects file system permissions

๐Ÿš€ Performance

  • Efficient file reading - Uses streaming for large log files
  • Memory conscious - Doesn't load entire files into memory
  • Fast search - Optimized text search algorithms
  • Minimal dependencies - Only uses Node.js built-in modules

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“š Examples

Complete Cursor Setup

  1. Install globally:

    npm install -g local-logs-mcp-server
  2. Add to .cursor/mcp.json:

    {
      "mcpServers": {
        "local-logs": {
          "command": "local-logs-mcp",
          "env": {
            "LOGS_DIR": "./logs"
          }
        }
      }
    }
  3. Restart Cursor and test:

    • Ask: "Check my server logs"

Complete Claude Desktop Setup

  1. Open Claude Desktop config:

    # Mac
    open ~/Library/Application\ Support/Claude/claude_desktop_config.json
    
    # Windows
    notepad %APPDATA%\Claude\claude_desktop_config.json
  2. Add configuration:

    {
      "mcpServers": {
        "local-logs": {
          "command": "npx",
          "args": ["-y", "local-logs-mcp-server"],
          "env": {
            "LOGS_DIR": "/Users/yourusername/projects/myapp/logs"
          }
        }
      }
    }
  3. Restart Claude Desktop

๐Ÿ”— Related Projects


Made with โค๏ธ for the MCP community