log-collector

log-collector

MCP server for collecting and analyzing CLI/web server error logs. Enables watching log files/directories, parsing common error patterns, and querying/analyzing logs through natural language.

Category
Visit Server

README

log-collector

MCP server for collecting and analyzing CLI/web server error logs.

A lightweight server that watches log files and directories, parses common error patterns from CLI tools and web servers, and provides structured querying and analysis — all through the Model Context Protocol (MCP).


Features

  • File & directory watching — watch single log files or entire directories with glob patterns
  • Multi-source support — simultaneously monitor multiple log sources
  • Smart parsing — automatically detects and parses errors from:
    • Vite / Rollup build errors
    • JavaScript/TypeScript stack traces (Error, TypeError, ReferenceError, etc.)
    • esbuild / Vite ×-prefixed build errors
    • npm ERR! output
    • Build failures ("Build failed", "Failed to compile")
    • Warnings (WARN, ⚠, [warn])
    • HTTP server errors (4xx client errors, 5xx server errors)
    • Build success / ready messages
  • Filtered queries — retrieve logs by source, level, time range, and limit
  • Auto-analysis — get summary statistics and top error counts grouped by normalized message
  • In-memory ring buffer — retains up to 10,000 entries per session

Quick Start

Prerequisites

  • Node.js >= 20
  • npm

Installation

# Install globally
npm install --global @bonsai/log-collector

# Or run with npx
npx @bonsai/log-collector

Build from source

git clone https://github.com/bonsai/log-collector.git
cd log-collector
npm install
npm run build
npm start

Usage

log-collector is an MCP server that communicates over stdio. It is designed to be used as a tool provider for MCP-compatible clients (e.g., Claude Desktop, Claude Code).

MCP Tools

Tool Description
watch_start Start watching a log file or directory for changes
watch_stop Stop watching a log source
get_errors Retrieve collected error logs with optional filters
analyze Analyze collected logs and return a summary
list_sources List all currently watched log sources
clear Clear all stored logs or logs for a specific source

Tool Parameters

watch_start

Parameter Type Required Description
target string ✅ Path to log file or directory to watch
type `"file" "dir"` ✅
pattern string ❌ Glob pattern when watching a directory (default: **/*.log)

get_errors

Parameter Type Required Description
source string ❌ Filter by source path/name
level `"error" "warn" "info"`
limit number ❌ Max results (default: 50)
since string ❌ ISO timestamp — only return logs after this time

analyze

Parameter Type Required Description
source string ❌ Focus analysis on a specific source

Returns: total entries, error/warning/info counts, top 10 most frequent errors, and list of active sources.


Architecture

┌─────────────┐     ┌──────────┐     ┌──────────┐
│  chokidar   │────▶│Collector │────▶│ Storage  │
│ (FS watcher)│     │(readTail)│     │(10k ring)│
└─────────────┘     └──────────┘     └──────────┘
                            │
                     ┌──────▼──────┐
                     │   Parser    │
                     │ (pattern    │
                     │  matching)  │
                     └─────────────┘

┌─────────────┐
│  MCP Server │ (stdio transport)
│  (index.ts) │
└─────────────┘
     │
     ▼
  MCP Client
(Claude Desktop,
 Claude Code, etc.)

Components

  • index.ts — MCP server entry point; registers tools and handles requests
  • collector.ts — File watcher manager using chokidar; reads tail of changed files
  • parser.ts — Pattern-based log parser; recognizes Vite, npm, HTTP, and generic error formats; also provides analyze() for summary aggregation
  • storage.ts — In-memory ring buffer with filtered query support

Development

# Install dependencies
npm install

# Build
npm run build

# Run locally
npm start

# Watch mode (auto-restart on changes)
npx tsx src/index.ts

Adding new log patterns

Edit src/parser.ts and add a new entry to the patterns array:

{
  name: "my-tool-error",
  test: (line) => {
    const m = line.match(/^MY_ERROR:\s+(.+)/);
    if (m) return { level: "error", message: m[1], detail: line };
    return null;
  },
},

Use Cases

  • AI-assisted debugging — Feed your local dev server logs to Claude via MCP and ask it to diagnose errors
  • CI log monitoring — Watch build logs during development to catch failures early
  • Web server log analysis — Point it at your Nginx/Apache access logs to get structured error summaries
  • Multi-project log aggregation — Watch multiple project log directories simultaneously

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured