| Crates.io | mcp-log-agent |
| lib.rs | mcp-log-agent |
| version | 1.1.0 |
| created_at | 2025-12-24 18:36:03.017898+00 |
| updated_at | 2026-01-24 17:58:54.719963+00 |
| description | Real-time log capture CLI for development projects with MCP integration |
| homepage | |
| repository | https://github.com/Yaici-Yacine/mcp-logs.git |
| max_upload_size | |
| id | 2003660 |
| size | 275,014 |
Real-time log capture CLI for development projects with MCP (Model Context Protocol) integration.
cargo install mcp-log-agent
The binary will be installed in ~/.cargo/bin/ (ensure this is in your $PATH).
git clone https://github.com/Yaici-Yacine/mcp-logs.git
cd mcp-logs/log-agent
# Install globally
cargo install --path .
# Or build without installing
cargo build --release
# Binary will be in ./target/release/mcp-log-agent
# Install the log agent
cargo install mcp-log-agent
# Install the MCP server
npm install -g mcp-logs
# or: bun install -g mcp-logs
Add to your MCP client configuration (OpenCode, Claude Desktop, Cline, etc.):
{
"mcpServers": {
"mcp-logs": {
"command": "mcp-logs"
}
}
}
Configuration file locations:
~/.config/opencode/mcp.json~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonsettings.json under cline.mcpServersRestart your client (OpenCode, Claude Desktop, Cline) to load the MCP server.
Create a local configuration file in your project directory:
cd your-project
mcp-log-agent config init --local
Edit .mcp-log-agent.toml and set your default command:
[agent]
default_project = "my-app"
# Uncomment and set your command:
default_command = ["npm", "start"]
# Or: default_command = ["bun", "dev"]
# Or: default_command = ["cargo", "run"]
With local config (simple):
# Just run without arguments!
mcp-log-agent run
Without config (specify command):
# Capture from any command
mcp-log-agent run --project my-app -- bun dev
# Node.js project
mcp-log-agent run --project api -- npm start
# Rust project
mcp-log-agent run --project backend -- cargo run
# Python project
mcp-log-agent run --project ml-script -- python train.py
Note: The
--separator is needed when providing a command to separate mcp-log-agent options from your command arguments.
Logs will be displayed in your terminal (colorized) AND captured by the MCP server.
In your MCP client (OpenCode, Claude Desktop, Cline), ask questions like:
Show me the recent logs
What errors occurred in my-app?
Search for "database" in the logs
List all connected projects
The client will automatically call the appropriate MCP tools (get_recent_logs, get_errors, search_logs, list_projects, etc.).
Spawn a process and capture its logs:
# With local config containing default_command
mcp-log-agent run
# With specific command
mcp-log-agent run [OPTIONS] -- <COMMAND> [ARGS...]
Options:
--project, -p: Project name for identification (overrides config)--verbose, -v: Enable verbose output--watch, -w: Enable interactive TUI (Terminal User Interface) mode--cmd, -C: Use a predefined command from configdefault_command from config if not provided)Define multiple commands in your config for quick access:
[agent]
# Simple syntax (uses default watch setting)
[agent.commands]
dev = ["npm", "run", "dev"]
build = ["npm", "run", "build"]
# Detailed syntax (specify watch mode per command)
test = { command = ["npm", "test"], watch = true }
serve = { command = ["python", "-m", "http.server"], watch = false }
Usage:
# Run predefined commands
mcp-log-agent run --cmd dev # Uses dev command
mcp-log-agent run --cmd test # Uses test command with watch mode enabled
mcp-log-agent run -C build # Short flag works too
# List available commands when none found
mcp-log-agent run --cmd unknown
# Error: Predefined command 'unknown' not found in config
# Available commands in config:
# dev = ["npm", "run", "dev"]
# test = ["npm", "test"] (watch: true)
# build = ["npm", "run", "build"]
Watch Mode Priority:
When using predefined commands, the watch mode is determined by:
--watch / -w) - highest prioritywatch setting - if using detailed syntaxwatch setting in [agent] - default for simple syntaxfalse)Examples:
# Command uses its own watch setting
mcp-log-agent run --cmd test # watch = true (from command config)
# Override with CLI flag
mcp-log-agent run --cmd test -w # Always uses watch mode
mcp-log-agent run --cmd dev # Uses global watch setting
# Mix predefined and inline commands
mcp-log-agent run --cmd dev # Uses config command
mcp-log-agent run -- npm start # Uses inline command
Watch mode provides an interactive terminal interface for monitoring and controlling your process:
# Enable TUI via CLI flag
mcp-log-agent run --watch -- npm start
mcp-log-agent run -w -- bun dev
# Or enable in config file
# In .mcp-log-agent.toml:
# [agent]
# watch = true
mcp-log-agent run # Auto-launches in TUI mode
TUI Features:
↑/↓ or j/k - Scroll up/downPage Up/Down - Fast scrollHome/End - Jump to top/bottomr - Restart the process (without quitting the agent)q - Quitc - Clear all logsp / Space - Pause/Resume log capture/ - Search logs (supports regex)s - Save logs to filey - Copy selected line to clipboard? - Show help overlay with all shortcutsr to restart immediatelyq to quit immediatelyTUI Configuration:
Add to your .mcp-log-agent.toml:
[agent]
watch = true # Enable TUI mode by default
[performance.tui]
max_logs = 5000 # Max logs kept in memory (default: 5000)
tick_rate_ms = 250 # Countdown refresh rate (default: 250ms)
frame_rate_ms = 100 # Max 10 FPS, prevents lag (default: 100ms)
Examples:
# Simple usage with config
cd my-project
mcp-log-agent config init --local
# Edit .mcp-log-agent.toml: default_command = ["npm", "start"]
mcp-log-agent run
# Watch mode for development server
mcp-log-agent run -w -- bun dev
# Watch mode with custom project name
mcp-log-agent run --watch --project frontend -- npm start
# Web server (normal mode)
mcp-log-agent run --project frontend -- bun dev
# Build process
mcp-log-agent run --project build -- npm run build
# Tests with TUI
mcp-log-agent run -w --project tests -- cargo test
# Shell script
mcp-log-agent run --project demo -- bash ./script.sh
# Override project name from config
mcp-log-agent run --project custom-name -- npm start
Test the connection to the MCP server:
mcp-log-agent test [--message <TEXT>]
Options:
--message, -m: Custom test message (optional)Example:
mcp-log-agent test --message "Hello from CLI"
Note: The MCP server must be running (via your MCP client) for the test to succeed.
Logs are sent as newline-delimited JSON to the Unix socket:
{
"version": "1.0",
"type": "log_entry",
"data": {
"timestamp": "2025-12-24T10:30:45.123Z",
"level": "info",
"source": "stdout",
"project": "my-app",
"message": "Server started on port 3000",
"pid": 12345
}
}
Log Levels:
info - Informational messageswarn - Warning messageserror - Error messagesdebug - Debug messagesLevels are automatically inferred from message content.
Sources:
stdout - Standard outputstderr - Standard errormcp-log-agent supports flexible configuration via files, environment variables, and CLI arguments.
Configuration priority (highest to lowest):
MCP_LOG_*).mcp-log-agent.toml)~/.config/mcp-log-agent/config.toml)# Create local config (project directory)
mcp-log-agent config init --local
# Create global config (user-wide)
mcp-log-agent config init --global
This generates a fully commented configuration file with explanations for each parameter.
Pro tip: Set default_command in your local config to avoid typing the command every time:
[agent]
default_project = "my-awesome-app"
default_command = ["npm", "run", "dev"]
# Now just run: mcp-log-agent run
# Or define multiple commands for quick access:
[agent.commands]
dev = ["npm", "run", "dev"]
test = { command = ["npm", "test"], watch = true }
build = ["npm", "run", "build"]
# Now run: mcp-log-agent run --cmd dev
# Initialize config with detailed comments
mcp-log-agent config init [--global|--local]
# Show current merged configuration
mcp-log-agent config show [--json]
# Get specific config value
mcp-log-agent config get <key>
# Set a config value
mcp-log-agent config set <key> <value> [--global]
# List all available config keys
mcp-log-agent config list
# Validate configuration
mcp-log-agent config validate
# Detect which config files are loaded
mcp-log-agent config detect
# Reset to defaults
mcp-log-agent config reset [--global|--local]
Customize colors for both CLI output and TUI interface using themes. Themes are stored as TOML files in ~/.config/mcp-log-agent/themes/.
Set a theme in your configuration file:
# In .mcp-log-agent.toml or ~/.config/mcp-log-agent/config.toml
theme = "dracula"
Or use the config command:
# Set theme in local config
mcp-log-agent config set theme dracula
# Set theme in global config
mcp-log-agent config set theme nord --global
The following themes are automatically created on first run:
default - Standard vibrant colors with blue/cyan accentsdracula - Popular dark theme with purple accents (#282A36 background)nord - Arctic, north-bluish color palette (#2E3440 background)monokai - Monokai Pro inspired scheme (#272822 background)solarized-dark - Solarized Dark color scheme (#002B36 background)minimal - Minimal monochrome theme (black/white/gray)Navigate to the themes directory:
cd ~/.config/mcp-log-agent/themes/
Copy an existing theme as a template:
cp default.toml my-theme.toml
Edit your theme file:
name = "my-theme"
description = "My custom color theme"
author = "Your Name"
# Log level colors (CLI output)
[colors.error]
fg = "#FF5555" # Hex color
style = ["bold"]
[colors.warn]
fg = "yellow" # Named color
style = []
[colors.info]
fg = "88C0D0" # Hex without #
style = []
[colors.debug]
fg = "blue"
style = []
# System messages
[colors.system.success]
fg = "green"
style = ["bold"]
[colors.system.error]
fg = "red"
style = ["bold"]
[colors.system.info]
fg = "cyan"
style = []
[colors.system.dim]
fg = "bright_black"
style = ["dimmed"]
# TUI interface colors
[tui]
header_bg = "#2E3440"
header_fg = "#ECEFF4"
status_bg = "#2E3440"
status_fg = "#A3BE8C"
border = "#88C0D0"
selected_bg = "#3B4252"
selected_fg = "#ECEFF4"
search_match = "#EBCB8B"
search_dimmed = "#4C566A"
help_bg = "#2E3440"
help_fg = "#ECEFF4"
Use your custom theme:
mcp-log-agent config set theme my-theme
Themes support three color formats:
"#FF5733" or "FF5733" - Full RGB control"red", "bright_cyan", "blue" - Standard terminal colors"255,87,51" - Direct RGB valuesAvailable named colors:
black, red, green, yellow, blue, magenta, cyan, whitebright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_whiteAvailable styles:
bold, dimmed, italic, underline, blink, reverse, strikethroughA complete theme file includes:
name, description, author (optional)colors.*): Colors for error, warn, info, debug logscolors.system.*): Colors for agent messages (success, error, info, dim)tui.*): Colors for the interactive Terminal UI
header_bg/fg: Top bar (project name, command)status_bg/fg: Bottom bar (stats, status)border: All borders and framesselected_bg/fg: Selected log line highlightsearch_match: Highlighted search resultssearch_dimmed: Dimmed/filtered out logshelp_bg/fg: Help overlay popupYou can modify configuration values directly using the config set command:
# Set a boolean value
mcp-log-agent config set agent.verbose true
# Set an integer value
mcp-log-agent config set agent.connection_timeout 10
# Set a string value
mcp-log-agent config set agent.socket_path "/tmp/my-socket.sock"
# Set an enum value
mcp-log-agent config set output.format plain
mcp-log-agent config set filters.min_level warn
# Set an array value (JSON format)
mcp-log-agent config set agent.default_command '["npm", "run", "dev"]'
# Set an array value (comma-separated)
mcp-log-agent config set filters.ignore_patterns "node_modules,webpack,DEBUG:"
# Modify global config instead of local
mcp-log-agent config set agent.verbose true --global
Key format: section.field (e.g., agent.socket_path, output.colors, filters.min_level)
Supported types:
true, false5, 1000, 100"value" or valuecolored, plain, json, debug, info, warn, error["item1", "item2"] (JSON) or item1,item2 (comma-separated)Example .mcp-log-agent.toml:
[agent]
socket_path = "/tmp/log-agent.sock"
default_project = "my-app"
# Set default command to run with just "mcp-log-agent run"
default_command = ["npm", "start"]
# Or: default_command = ["bun", "dev"]
# Or: default_command = ["cargo", "run", "--release"]
watch = false # Enable TUI mode by default
verbose = false
connection_timeout = 5
retry_attempts = 3
# Predefined commands for quick execution
[agent.commands]
dev = ["npm", "run", "dev"] # Simple syntax
test = { command = ["npm", "test"], watch = true } # Detailed syntax
build = ["npm", "run", "build"]
serve = { command = ["python", "-m", "http.server"], watch = true }
[output]
colors = true # Enable/disable colors
format = "colored" # colored | plain | json
show_timestamps = false
show_pid = false
# Theme configuration (colors are loaded from theme file)
theme = "default" # default | dracula | nord | monokai | solarized-dark | minimal
[filters]
ignore_patterns = [] # Regex patterns to exclude
min_level = "debug" # debug | info | warn | error
[performance]
buffer_size = 1000
flush_interval = 100
[performance.tui]
max_logs = 5000 # Max logs in TUI memory (default: 5000)
tick_rate_ms = 250 # Countdown refresh rate (default: 250ms)
frame_rate_ms = 100 # Max 10 FPS, prevents lag (default: 100ms)
Override any config value using environment variables:
# Agent settings
export MCP_LOG_AGENT_SOCKET_PATH="/custom/path.sock"
export MCP_LOG_AGENT_DEFAULT_PROJECT="my-project"
export MCP_LOG_AGENT_VERBOSE=true
export MCP_LOG_AGENT_CONNECTION_TIMEOUT=10
export MCP_LOG_AGENT_RETRY_ATTEMPTS=5
# Output settings
export MCP_LOG_AGENT_COLORS=false
export MCP_LOG_AGENT_FORMAT=json
export MCP_LOG_AGENT_SHOW_TIMESTAMPS=true
export MCP_LOG_AGENT_SHOW_PID=true
# Color customization
export MCP_LOG_COLOR_ERROR_FG=bright_red
export MCP_LOG_COLOR_WARN_FG=bright_yellow
export MCP_LOG_COLOR_INFO_FG=cyan
export MCP_LOG_COLOR_DEBUG_FG=bright_blue
# Filter settings
export MCP_LOG_FILTER_MIN_LEVEL=warn
# Performance settings
export MCP_LOG_AGENT_BUFFER_SIZE=2000
export MCP_LOG_AGENT_FLUSH_INTERVAL=50
# Run with env vars
mcp-log-agent run -- npm start
Configuration priority (highest to lowest):
MCP_LOG_*).mcp-log-agent.toml)~/.config/mcp-log-agent/config.toml)Default: /tmp/log-agent.sock
Change via:
agent.socket_path = "/custom/path.sock"MCP_LOG_AGENT_SOCKET_PATH=/custom/path.sockThis CLI works in tandem with the MCP server to provide real-time log analysis capabilities:
Once configured, your MCP client will have access to 8 tools:
| Tool | Description |
|---|---|
get_recent_logs |
Get the most recent logs |
get_logs |
Advanced filtering (project, level, source, text search, time range) |
search_logs |
Text search or regex patterns across all logs |
get_errors |
Get only error-level logs |
get_stats |
Statistics about captured logs |
get_analytics |
NEW in v1.0.0 - Advanced analytics with distributions, timelines, top messages, error rates |
list_projects |
List all connected log agents |
clear_logs |
Clear all logs from memory |
The MCP server now includes powerful analytics and filtering capabilities:
Advanced Analytics (get_analytics):
Temporal Filtering (get_logs):
startTime and endTimeRegex Search (search_logs):
regex: true parameterExample queries in your MCP client:
Show me analytics for the last hour
Get error logs from the last 30 minutes
Search for logs matching pattern "error.*timeout" using regex
What are the most common error messages in project "api"?
See the mcp-logs documentation for detailed MCP server setup and configuration.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Yacine Yaici - yaiciy01@gmail.com
--watch / -w flag or watch = true in configr to restart, c to clear logs, q to quit/ to enter search modep or Space to pause/resumes to save current logs to filey to copy selected line? to show full keyboard shortcuts[performance.tui] section in config
max_logs - Max logs kept in TUI memory (default: 5000)tick_rate_ms - Countdown refresh rate (default: 250ms)frame_rate_ms - Max 10 FPS, prevents lag (default: 100ms)ShortcutList and StatusInfoList builders for DRY coderatatui 0.29, crossterm 0.29, regex 1.11, and arboard 3.4~/.config/mcp-log-agent/config.toml.mcp-log-agent.tomlMCP_LOG_*)default_command setting
mcp-log-agent run without argumentsdefault_command = ["npm", "start"]MCP_LOG_COLOR_ERROR_FG, MCP_LOG_COLOR_WARN_FG, etc.config init, show, get, list, validate, detect, resetconfig set: Modify config values directly from CLI
mcp-log-agent config set agent.verbose truemcp-log-agent config set agent.default_command '["npm", "run", "dev"]'config colors list/set/preview/test