whallysson / log-viewer-mcp
MCP Server for opcodesio/log-viewer - expose log analysis tools to AI agents via Laravel MCP
Requires
- php: ^8.2
- laravel/mcp: ^0.6
- opcodesio/log-viewer: ^3.0|^4.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.7
- pestphp/pest-plugin-laravel: ^3.1
README
An MCP (Model Context Protocol) server that exposes opcodesio/log-viewer to AI agents. Let Claude, GPT, and other AI assistants read, search, and analyze your Laravel application logs.
Built on top of the official laravel/mcp package using STDIO transport.
Why?
When debugging production issues with AI, the agent needs to see your logs. Instead of copy-pasting stack traces, this package gives your AI assistant direct access to your log files — with search, filtering, and structured output.
4 tools, zero config. Install the package and your AI agent can immediately:
- List all available log files
- Search logs by text or severity level
- Get full details of any log entry (stack trace, context, extra data)
- Get a health overview with error counts and recent failures
Requirements
- PHP 8.2+
- Laravel 10.x, 11.x, or 12.x
- opcodesio/log-viewer 3.x or 4.x
- laravel/mcp 0.6+
Installation
composer require whallysson/log-viewer-mcp
The package auto-discovers its service provider. No additional setup required.
Publish Configuration (Optional)
php artisan vendor:publish --tag=log-viewer-mcp-config
Configuration
// config/log-viewer-mcp.php return [ // Enable or disable the MCP server 'enabled' => env('LOG_VIEWER_MCP_ENABLED', true), // Maximum results per search page 'max_results' => 50, // Truncate full log text (stack traces) longer than this 'max_log_text_length' => 10000, ];
Available Tools
list_log_files
Discover available log files with metadata (name, size, date range, type).
| Parameter | Type | Required | Description |
|---|---|---|---|
folder |
string | No | Folder identifier to filter by |
search_logs
Search logs by text query and/or severity level with pagination.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | No* | File identifier from list_log_files |
query |
string | No* | Text to search (case-insensitive regex) |
level |
string | No | Severity: emergency, alert, critical, error, warning, notice, info, debug |
per_page |
integer | No | Results per page (default: 15, max: 50) |
page |
integer | No | Page number (default: 1) |
*At least file or query is required.
get_log_entry
Get full details of a specific log entry including stack trace, context, and extra data.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | Yes | File identifier |
index |
integer | Yes | Log entry index from search results |
get_error_summary
Get a high-level health overview: counts per severity level and most recent errors.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | No | File identifier (omit for overview of all files) |
recent_errors_count |
integer | No | Number of recent errors to include (default: 5, max: 20) |
Usage with Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"log-viewer": {
"command": "php",
"args": ["artisan", "mcp:start", "log-viewer"],
"cwd": "/path/to/your/laravel/app"
}
}
}
Then ask Claude things like:
- "Check my application logs for recent errors"
- "Search for any SQLSTATE errors in the last log file"
- "Give me a health summary of the application"
- "Show me the full stack trace for that error"
Suggested Workflow
The tools are designed to be used in sequence:
1. list_log_files → discover what log files exist
2. get_error_summary → quick health check
3. search_logs → find specific errors
4. get_log_entry → get full details + stack trace
Testing
composer test
Code Style
This package uses Laravel Pint for code style.
# Check for style issues composer lint # Fix style issues composer lint:fix
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Please see the pull request template for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/new-tool) - Ensure tests pass (
composer test) and code style is clean (composer lint) - Submit a pull request
License
The MIT License (MIT). Please see License File for more information.