Labsco
MCP SERVER

Log-MCP

by caijianying

Read and search logs on remote servers over SSH, without opening a terminal on each one.

Observability, Monitoring & Incident Response
Summary
A connection pool is the reason this beats a shell tool.

Every log question over plain SSH pays reconnection cost; here connections are pooled and reused, with automatic reconnect and a retry budget. The constraint to check before installing is the file layout: the server finds logs through a configured filename pattern built from level, date and sequence, so a service that names its logs differently needs that pattern adjusted first.

What it is

A Java server that keeps a pool of SSH connections to the machines you configure and answers log questions across them. Several servers are managed as one namespace, with a default so most calls do not need to name one.

What you get
  • `list_servers` reports the configured servers with their connection state
  • `list_log_files` lists log files on a server, filtered by level and by date range
  • `read_log_file` reads a file, optionally between two line numbers or up to a maximum line count
  • `search_logs` searches by keyword across levels and dates, with regular expressions, context lines around each match, and a result cap
  • `tail_logs` returns the most recent lines at a chosen level, defaulting to fifty
  • Filtering by level — info, warn, error and debug — is built in rather than left to grep
  • Safety on the shell side: parameter validation, path validation and shell escaping
Requirements

JDK 21+ and Maven 3.6+ to build the JAR. Authentication is SSH private key only — password authentication is not supported, so the key must already be authorised on each target and readable at the path named in the config. Servers go in a config.json listing host, port, username, key path and a log root directory. Run it over stdio with the key and config paths as JVM properties, or start it in HTTP mode on a port and register the URL. Log filenames are expected to follow the pattern in the config.