This repository has been archived on 2026-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
php-mcp/src/Website/Mcp/View/Modal/McpMetrics.php
Snider 92e2097022
Some checks failed
CI / PHP 8.3 (push) Failing after 4s
CI / PHP 8.4 (push) Failing after 3s
fix: register MCP layout in layouts:: namespace
- Change <x-layouts.mcp> to <x-layouts::mcp> in all blade views
- Change Livewire #[Layout('components.layouts.mcp')] to layouts::mcp
- Register layouts path via Blade::anonymousComponentPath in Boot
- Layout file already exists at src/Front/View/Blade/layouts/mcp.blade.php

The dot notation couldn't resolve because mcp.blade.php lives in the
package, not the app's components directory. The layouts:: namespace
is the correct pattern matching core-php's component registration.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 15:38:27 +00:00

90 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Website\Mcp\View\Modal;
use Livewire\Attributes\Layout;
use Livewire\Component;
use Core\Mcp\Services\McpMetricsService;
/**
* MCP Metrics Dashboard
*
* Displays analytics and metrics for MCP tool usage.
*/
#[Layout('layouts::mcp')]
class McpMetrics extends Component
{
public int $days = 7;
public string $activeTab = 'overview';
protected McpMetricsService $metricsService;
public function boot(McpMetricsService $metricsService): void
{
$this->metricsService = $metricsService;
}
public function setDays(int $days): void
{
// Bound days to a reasonable range (1-90)
$this->days = min(max($days, 1), 90);
}
public function setTab(string $tab): void
{
$this->activeTab = $tab;
}
public function getOverviewProperty(): array
{
return app(McpMetricsService::class)->getOverview($this->days);
}
public function getDailyTrendProperty(): array
{
return app(McpMetricsService::class)->getDailyTrend($this->days);
}
public function getTopToolsProperty(): array
{
return app(McpMetricsService::class)->getTopTools($this->days, 10);
}
public function getServerStatsProperty(): array
{
return app(McpMetricsService::class)->getServerStats($this->days);
}
public function getRecentCallsProperty(): array
{
return app(McpMetricsService::class)->getRecentCalls(20);
}
public function getErrorBreakdownProperty(): array
{
return app(McpMetricsService::class)->getErrorBreakdown($this->days);
}
public function getToolPerformanceProperty(): array
{
return app(McpMetricsService::class)->getToolPerformance($this->days, 10);
}
public function getHourlyDistributionProperty(): array
{
return app(McpMetricsService::class)->getHourlyDistribution();
}
public function getPlanActivityProperty(): array
{
return app(McpMetricsService::class)->getPlanActivity($this->days, 10);
}
public function render()
{
return view('mcp::web.mcp-metrics');
}
}