diff --git a/changelog/2026/jan/code-review.md b/changelog/2026/jan/code-review.md new file mode 100644 index 0000000..a15fb54 --- /dev/null +++ b/changelog/2026/jan/code-review.md @@ -0,0 +1,179 @@ +# Mcp Module Review + +**Updated:** 2026-01-21 - Security improvements: DataRedactor service for sensitive data redaction in tool/API logs, UUID v4 for session IDs (~122 bits entropy). Previous: rate limiting, cache TTL config, input validation, database indexes, cleanup command, server consolidation, circuit breaker, tool call migrations + +## Overview + +The MCP (Model Context Protocol) module provides infrastructure for AI agent integration with the Host Hub platform. It offers: + +1. **STDIO MCP Server** - Single command-based server (`mcp:agent-server`) for Claude/AI integration via JSON-RPC using registry pattern with extracted tools +2. **HTTP API** - API key authenticated access to MCP tools +3. **Agent Tooling** - Comprehensive tool suite for plan/phase/task management, session handling, and multi-agent handoff +4. **Monitoring** - Metrics collection, Prometheus export, health checks, and alerting +5. **Admin UI** - Livewire components for API key management, playground, and request logging + +The module bridges Laravel's MCP package with a custom agent orchestration system (Agentic module) and provides extensive analytics/monitoring capabilities. + +## Production Readiness Score: 94/100 (was 92/100 - Security hardening 2026-01-21) + +**Breakdown:** +- Code Quality: 88/100 (clean patterns, good separation, single server) +- Test Coverage: 65/100 (core services covered, tools undertested) +- Security: 95/100 (solid auth, SQL injection fixed, rate limiting, data redaction, UUID session IDs) +- Documentation: 60/100 (good inline docs, missing user docs) +- Error Handling: 90/100 (workspace fallback fixed, input validation added, circuit breaker for fault tolerance) +- Production Hardening: 92/100 (rate limits, indexes, cleanup jobs, configurable TTLs, circuit breaker, all migrations present, PII redaction) + +## Critical Issues (Must Fix) + +- [x] **Missing migration for `mcp_tool_calls` and `mcp_tool_call_stats` tables** - FIXED 2026-01-21: Migration `2026_01_21_000002_create_mcp_tool_call_tables.php` now exists with both tables, proper indexes, and foreign keys. + +- [x] **QueryDatabase SQL injection risk** - FIXED: Added comprehensive validation including semicolon check (prevents stacked queries), table allowlist (19 safe tables), 14 forbidden keywords (INSERT, UPDATE, DELETE, DROP, etc.), and UNION attack prevention. + +- [x] **Server implementations consolidated** - FIXED: The monolithic V1 server (~2000 lines) has been removed and replaced by the clean V2 implementation using the registry pattern with extracted tools. Content generation tools were V1-only features not yet migrated to the tool pattern - out of scope for this consolidation. + +- [x] **Hardcoded workspace_id fallback** - FIXED: `SessionStart.php` now returns error if workspace_id cannot be determined instead of falling back to ID 1. Validates workspace_id is required from context or plan. + +## Recommended Improvements + +- [x] **Add rate limiting to STDIO servers** - VERIFIED: `ToolRateLimiter` service at `Mcp/Services/ToolRateLimiter.php` provides cache-based rate limiting with configurable per-tool limits. `McpAgentServerCommand` uses `$rateLimiter->check()` and `$rateLimiter->hit()` before tool execution (lines 216-228). + +- [x] **Implement scheduled cleanup for tool call logs** - VERIFIED: `CleanupToolCallLogsCommand` at `Mcp/Console/Commands/CleanupToolCallLogsCommand.php` prunes `mcp_tool_calls`, `mcp_api_requests`, and `mcp_tool_call_stats` with configurable retention (default 90 days for logs, 365 days for stats). Supports `--dry-run` and chunk-based deletion. + +- [x] **Add input validation to agent tools** - VERIFIED: `AgentTool` base class at `Mcp/Tools/Agent/AgentTool.php` provides comprehensive validation helpers: `requireString()`, `requireInt()`, `requireArray()`, `requireEnum()`, `optionalString()`, `optionalInt()`, `optionalEnum()` with min/max bounds, length limits, and enum validation. Plan tools like `PlanCreate` use these (e.g., `$this->requireString($args, 'title', 255)`). + +- [x] **Consolidate server implementations** - VERIFIED: Only `McpAgentServerCommand.php` exists (no V2 file). Uses `AgentToolRegistry` pattern with 22 extracted tool classes. Content generation tools out of scope. + +- [x] **Add circuit breaker for external dependencies** - IMPLEMENTED 2026-01-21: `CircuitBreaker` service at `Mcp/Services/CircuitBreaker.php` provides fault tolerance with configurable thresholds, reset timeouts, and half-open state recovery. `AgentTool` base class exposes `withCircuitBreaker()` helper for wrapping external calls. Tools like `PlanGet` and `SessionStart` now use circuit breaker pattern with graceful fallbacks. Config in `mcp.circuit_breaker`. + +- [x] **Add missing database indexes** - VERIFIED: Migration `2026_01_21_000003_add_indexes_to_agent_sessions.php` adds indexes on `agent_sessions` table: + - `last_active_at` (stale session cleanup) + - `agent_type` (filtering) + - `(workspace_id, last_active_at)` (active session queries) + - `(status, last_active_at)` (cleanup queries) + +- [x] **Configuration extraction** - PARTIALLY COMPLETED: Created `config/mcp.php` with: + - Rate limit settings (moved from hardcoded values in `McpApiKeyAuth`) + - Cache TTL settings (moved from hardcoded 86400 in `AgentSessionService`) + - Protocol version setting + - Monitoring thresholds now configurable + - Note: Some values still hardcoded in V1 server pending deprecation + +- [x] **Fix DEFAULT_TTL bug** - VERIFIED: `AgentSessionService` at lines 28-31 uses `getCacheTtl()` method that reads from `config('mcp.session.cache_ttl', 86400)` instead of hardcoded constant. Used in `setState()` and `cacheActiveSession()` methods. + +- [ ] **Add OpenTelemetry/distributed tracing** - The monitoring service exports to Prometheus but lacks trace context propagation for debugging complex multi-agent flows. + +## Missing Features (Future) + +- [ ] **WebSocket support for real-time updates** - Currently all communication is request/response. Real-time session status would improve agent UX. + +- [ ] **Tool execution audit log** - While `McpToolCall` logs calls, there's no immutable audit trail for compliance. Consider event sourcing for sensitive tools. + +- [ ] **Multi-server federation** - The `HostHub` and `Marketing` servers are registered but there's no mechanism to route requests between them or aggregate tool listings. + +- [ ] **Session recovery/replay** - No mechanism to replay a session from its work log. Would be valuable for debugging and resuming failed sessions. + +- [ ] **Tool versioning** - No version tracking on tools. Breaking changes to tool schemas would affect running agents with no fallback. + +- [ ] **Usage quotas per workspace** - API keys have rate limiting but no workspace-level quotas for tool calls or token consumption. + +- [ ] **Tool dependency graph** - Some tools depend on others (e.g., `task_update` requires a valid plan). No validation that prerequisites are met. + +## Test Coverage Assessment + +**Current Coverage:** + +| Area | Coverage | Notes | +|------|----------|-------| +| McpApiKeyAuth middleware | Good | Comprehensive tests for auth, rate limiting, server scopes | +| AgentToolRegistry | Good | Registration, permissions, execution tested | +| AgentSessionService | Good | Session lifecycle, handoff, statistics covered | +| McpMonitoringService | Good | Health status, Prometheus export, anomaly detection | +| Core MCP Tools | Partial | ListSites, GetStats, QueryDatabase tested | +| Agent Tools | Missing | 22 extracted tools have no direct tests | +| Server Command | Partial | Core server loop tested via integration, tool execution via registry tests | +| Admin Livewire Components | Missing | ApiKeyManager, Playground, RequestLog untested | +| Resources/Prompts | Missing | No tests for AppConfig, DatabaseSchema, ContentResource, or prompts | + +**Test File Inventory:** +- `Tests/Feature/McpApiKeyAuthTest.php` - 370 lines, thorough +- `Tests/Feature/AgentToolRegistryTest.php` - 196 lines, good +- `Tests/Feature/AgentSessionServiceTest.php` - 203 lines, good +- `Tests/Feature/McpToolsTest.php` - 289 lines, partial +- `Tests/Feature/McpMonitoringServiceTest.php` - 171 lines, good +- `Tests/UseCase/ApiKeyManagerBasic.php` - Unclear purpose, possibly incomplete + +**Estimated Coverage:** ~40% of module code is tested. + +## Security Concerns + +1. **SQL Injection via QueryDatabase** (Critical) + - Regex check insufficient + - Allows UNION attacks, stacked queries + - Recommendation: Use read-only database user + parameterised views or whitelist specific queries + +2. **API Key exposure in error responses** (Low) + - The `toCurl()` method on `McpApiRequest` uses placeholder but could log actual keys if misused + +3. **Session ID predictability** (Low) - FIXED 2026-01-21 + - Session IDs now use UUID v4 (~122 bits entropy) via `Uuid::uuid4()` in `AgentSession::start()` + - Format: `sess_` prefix + UUID v4 (e.g., `sess_550e8400-e29b-41d4-a716-446655440000`) + +4. **Missing CSRF protection on Livewire components** (Medium) + - Admin components could be vulnerable if session hijacked + - Verify Livewire's built-in CSRF is enabled + +5. **No tool call signing** (Low) + - Tool calls aren't cryptographically signed + - Replay attacks possible within rate limit window + +6. **Sensitive data in tool call logs** (Medium) - FIXED 2026-01-21 + - New `DataRedactor` service at `Mcp/Services/DataRedactor.php` provides automatic redaction + - `McpToolCall::log()` now redacts `input_params` and summarizes `result_summary` + - `McpApiRequest::log()` now redacts `request_body` and summarizes `response_body` + - Redacts: passwords, tokens, API keys, credit cards, NI numbers, JWTs, PII fields + - Partially redacts PII like emails (shows `joh***@e***om`) + +## Notes + +### Architecture Observations + +The module now uses a clean registry-based architecture: +1. Single server command (`mcp:agent-server`) using `AgentToolRegistry` +2. Tools are extracted classes implementing `AgentToolInterface` +3. Content generation tools were removed during consolidation (out of scope, can be added as extracted tools later) + +The dependency on the `Agentic` module (`Mod\Agentic\Models\*`) is extensive. Consider: +- Moving shared models to a Core package +- Or defining interfaces in Mcp and having Agentic implement them + +### Positive Patterns + +- Clean use of PHP 8 features (enums, named arguments, union types) +- Consistent error response structure across tools +- Good use of Eloquent scopes for query building +- Prometheus metrics export is well-implemented +- Rate limiting with automatic clear on success +- Circuit breaker pattern for external module fault tolerance +- DataRedactor service for automatic PII/credential sanitisation in logs +- UUID v4 session IDs providing cryptographic-strength unpredictability + +### Technical Debt + +1. `onMcpTools` event handler in Boot.php is empty (commented as "once extracted") +2. The `UseCase/ApiKeyManagerBasic.php` test file appears incomplete +3. Content generation tools (content_status, content_brief_*, content_generate, etc.) were removed during consolidation - add as extracted tools if needed + +### Dependencies + +External module dependencies: +- `Mod\Agentic` - AgentPlan, AgentPhase, AgentSession, AgentWorkspaceState, PlanTemplateService +- `Mod\Api` - ApiKey, ApiKeyFactory +- `Mod\Tenant` - Workspace, User, EntitlementService +- `Mod\Content` - ContentBrief, AIUsage, GenerateContentJob, AIGatewayService +- `Mod\Web` - BioLink tools (BioResource, various Mcp\Tools) +- `Mod\Trust` - TrustHost tools +- `Laravel\Mcp` - Server, Tool, Request, Response +- `Website\Mcp` - Dashboard, McpRegistryController + +This deep coupling may cause issues during module extraction or independent deployment. diff --git a/composer.json b/composer.json index d085cc1..c159cbb 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ }, "autoload": { "psr-4": { - "Core\\Mod\\Mcp\\": "src/Mod/Mcp/", + "Core\\Mcp\\": "src/Mcp/", "Core\\Website\\Mcp\\": "src/Website/Mcp/" } }, "autoload-dev": { "psr-4": { - "Core\\Mod\\Mcp\\Tests\\": "tests/" + "Core\\Mcp\\Tests\\": "tests/" } }, "extra": { diff --git a/src/Mod/Mcp/Boot.php b/src/Mcp/Boot.php similarity index 89% rename from src/Mod/Mcp/Boot.php rename to src/Mcp/Boot.php index afc6a89..3eb46b7 100644 --- a/src/Mod/Mcp/Boot.php +++ b/src/Mcp/Boot.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace Core\Mod\Mcp; +namespace Core\Mcp; use Core\Events\AdminPanelBooting; use Core\Events\ConsoleBooting; use Core\Events\McpToolsRegistering; -use Core\Mod\Mcp\Events\ToolExecuted; -use Core\Mod\Mcp\Listeners\RecordToolExecution; -use Core\Mod\Mcp\Services\AuditLogService; -use Core\Mod\Mcp\Services\McpQuotaService; -use Core\Mod\Mcp\Services\ToolAnalyticsService; -use Core\Mod\Mcp\Services\ToolDependencyService; -use Core\Mod\Mcp\Services\ToolRegistry; -use Core\Mod\Mcp\Services\ToolVersionService; +use Core\Mcp\Events\ToolExecuted; +use Core\Mcp\Listeners\RecordToolExecution; +use Core\Mcp\Services\AuditLogService; +use Core\Mcp\Services\McpQuotaService; +use Core\Mcp\Services\ToolAnalyticsService; +use Core\Mcp\Services\ToolDependencyService; +use Core\Mcp\Services\ToolRegistry; +use Core\Mcp\Services\ToolVersionService; use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; diff --git a/src/Mod/Mcp/Console/Commands/CleanupToolCallLogsCommand.php b/src/Mcp/Console/Commands/CleanupToolCallLogsCommand.php similarity index 99% rename from src/Mod/Mcp/Console/Commands/CleanupToolCallLogsCommand.php rename to src/Mcp/Console/Commands/CleanupToolCallLogsCommand.php index 42923eb..d56a8a6 100644 --- a/src/Mod/Mcp/Console/Commands/CleanupToolCallLogsCommand.php +++ b/src/Mcp/Console/Commands/CleanupToolCallLogsCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Console\Commands; +namespace Core\Mcp\Console\Commands; use Illuminate\Console\Command; use Mod\Mcp\Models\McpApiRequest; diff --git a/src/Mod/Mcp/Console/Commands/McpAgentServerCommand.php b/src/Mcp/Console/Commands/McpAgentServerCommand.php similarity index 99% rename from src/Mod/Mcp/Console/Commands/McpAgentServerCommand.php rename to src/Mcp/Console/Commands/McpAgentServerCommand.php index 411752e..fe49ed8 100644 --- a/src/Mod/Mcp/Console/Commands/McpAgentServerCommand.php +++ b/src/Mcp/Console/Commands/McpAgentServerCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Console\Commands; +namespace Core\Mcp\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; @@ -16,7 +16,7 @@ use Core\Mod\Content\Jobs\GenerateContentJob; use Core\Mod\Content\Models\AIUsage; use Core\Mod\Content\Models\ContentBrief; use Core\Mod\Content\Services\AIGatewayService; -use Core\Mod\Mcp\Models\McpToolCall; +use Core\Mcp\Models\McpToolCall; use Throwable; /** diff --git a/src/Mod/Mcp/Console/Commands/McpMonitorCommand.php b/src/Mcp/Console/Commands/McpMonitorCommand.php similarity index 99% rename from src/Mod/Mcp/Console/Commands/McpMonitorCommand.php rename to src/Mcp/Console/Commands/McpMonitorCommand.php index d3869b8..52415e7 100644 --- a/src/Mod/Mcp/Console/Commands/McpMonitorCommand.php +++ b/src/Mcp/Console/Commands/McpMonitorCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Console\Commands; +namespace Core\Mcp\Console\Commands; use Illuminate\Console\Command; use Mod\Mcp\Services\McpMetricsService; diff --git a/src/Mod/Mcp/Console/Commands/PruneMetricsCommand.php b/src/Mcp/Console/Commands/PruneMetricsCommand.php similarity index 97% rename from src/Mod/Mcp/Console/Commands/PruneMetricsCommand.php rename to src/Mcp/Console/Commands/PruneMetricsCommand.php index 0c088f7..812779a 100644 --- a/src/Mod/Mcp/Console/Commands/PruneMetricsCommand.php +++ b/src/Mcp/Console/Commands/PruneMetricsCommand.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Console\Commands; +namespace Core\Mcp\Console\Commands; -use Core\Mod\Mcp\Models\ToolMetric; +use Core\Mcp\Models\ToolMetric; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; diff --git a/src/Mod/Mcp/Console/Commands/VerifyAuditLogCommand.php b/src/Mcp/Console/Commands/VerifyAuditLogCommand.php similarity index 97% rename from src/Mod/Mcp/Console/Commands/VerifyAuditLogCommand.php rename to src/Mcp/Console/Commands/VerifyAuditLogCommand.php index c6f67ef..e9808c2 100644 --- a/src/Mod/Mcp/Console/Commands/VerifyAuditLogCommand.php +++ b/src/Mcp/Console/Commands/VerifyAuditLogCommand.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Console\Commands; +namespace Core\Mcp\Console\Commands; -use Core\Mod\Mcp\Services\AuditLogService; +use Core\Mcp\Services\AuditLogService; use Illuminate\Console\Command; /** diff --git a/src/Mod/Mcp/Context/WorkspaceContext.php b/src/Mcp/Context/WorkspaceContext.php similarity index 100% rename from src/Mod/Mcp/Context/WorkspaceContext.php rename to src/Mcp/Context/WorkspaceContext.php diff --git a/src/Mod/Mcp/Controllers/McpApiController.php b/src/Mcp/Controllers/McpApiController.php similarity index 99% rename from src/Mod/Mcp/Controllers/McpApiController.php rename to src/Mcp/Controllers/McpApiController.php index 19ff660..befd412 100644 --- a/src/Mod/Mcp/Controllers/McpApiController.php +++ b/src/Mcp/Controllers/McpApiController.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace Mod\Api\Controllers; use Core\Front\Controller; -use Core\Mod\Mcp\Services\McpQuotaService; +use Core\Mcp\Services\McpQuotaService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; diff --git a/src/Mod/Mcp/DTO/ToolStats.php b/src/Mcp/DTO/ToolStats.php similarity index 98% rename from src/Mod/Mcp/DTO/ToolStats.php rename to src/Mcp/DTO/ToolStats.php index 01f8e50..f64253b 100644 --- a/src/Mod/Mcp/DTO/ToolStats.php +++ b/src/Mcp/DTO/ToolStats.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\DTO; +namespace Core\Mcp\DTO; /** * Tool Statistics Data Transfer Object. diff --git a/src/Mod/Mcp/Database/Seeders/SensitiveToolSeeder.php b/src/Mcp/Database/Seeders/SensitiveToolSeeder.php similarity index 98% rename from src/Mod/Mcp/Database/Seeders/SensitiveToolSeeder.php rename to src/Mcp/Database/Seeders/SensitiveToolSeeder.php index 4ce6f8e..525af11 100644 --- a/src/Mod/Mcp/Database/Seeders/SensitiveToolSeeder.php +++ b/src/Mcp/Database/Seeders/SensitiveToolSeeder.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Database\Seeders; +namespace Core\Mcp\Database\Seeders; -use Core\Mod\Mcp\Models\McpSensitiveTool; +use Core\Mcp\Models\McpSensitiveTool; use Illuminate\Database\Seeder; /** diff --git a/src/Mod/Mcp/Dependencies/DependencyType.php b/src/Mcp/Dependencies/DependencyType.php similarity index 97% rename from src/Mod/Mcp/Dependencies/DependencyType.php rename to src/Mcp/Dependencies/DependencyType.php index 78cc407..8a7040a 100644 --- a/src/Mod/Mcp/Dependencies/DependencyType.php +++ b/src/Mcp/Dependencies/DependencyType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Dependencies; +namespace Core\Mcp\Dependencies; /** * Types of tool dependencies. diff --git a/src/Mod/Mcp/Dependencies/HasDependencies.php b/src/Mcp/Dependencies/HasDependencies.php similarity index 91% rename from src/Mod/Mcp/Dependencies/HasDependencies.php rename to src/Mcp/Dependencies/HasDependencies.php index 692fcfc..537b3c6 100644 --- a/src/Mod/Mcp/Dependencies/HasDependencies.php +++ b/src/Mcp/Dependencies/HasDependencies.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Dependencies; +namespace Core\Mcp\Dependencies; /** * Interface for tools that declare dependencies. diff --git a/src/Mod/Mcp/Dependencies/ToolDependency.php b/src/Mcp/Dependencies/ToolDependency.php similarity index 99% rename from src/Mod/Mcp/Dependencies/ToolDependency.php rename to src/Mcp/Dependencies/ToolDependency.php index 69ff64d..bf657e4 100644 --- a/src/Mod/Mcp/Dependencies/ToolDependency.php +++ b/src/Mcp/Dependencies/ToolDependency.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Dependencies; +namespace Core\Mcp\Dependencies; /** * Represents a single tool dependency. diff --git a/src/Mod/Mcp/Events/ToolExecuted.php b/src/Mcp/Events/ToolExecuted.php similarity index 98% rename from src/Mod/Mcp/Events/ToolExecuted.php rename to src/Mcp/Events/ToolExecuted.php index 5c3ce77..6479143 100644 --- a/src/Mod/Mcp/Events/ToolExecuted.php +++ b/src/Mcp/Events/ToolExecuted.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Events; +namespace Core\Mcp\Events; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/src/Mod/Mcp/Exceptions/CircuitOpenException.php b/src/Mcp/Exceptions/CircuitOpenException.php similarity index 100% rename from src/Mod/Mcp/Exceptions/CircuitOpenException.php rename to src/Mcp/Exceptions/CircuitOpenException.php diff --git a/src/Mod/Mcp/Exceptions/ForbiddenQueryException.php b/src/Mcp/Exceptions/ForbiddenQueryException.php similarity index 97% rename from src/Mod/Mcp/Exceptions/ForbiddenQueryException.php rename to src/Mcp/Exceptions/ForbiddenQueryException.php index adc98b1..34f1504 100644 --- a/src/Mod/Mcp/Exceptions/ForbiddenQueryException.php +++ b/src/Mcp/Exceptions/ForbiddenQueryException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Exceptions; +namespace Core\Mcp\Exceptions; use RuntimeException; diff --git a/src/Mod/Mcp/Exceptions/MissingDependencyException.php b/src/Mcp/Exceptions/MissingDependencyException.php similarity index 96% rename from src/Mod/Mcp/Exceptions/MissingDependencyException.php rename to src/Mcp/Exceptions/MissingDependencyException.php index f38117d..f12bf29 100644 --- a/src/Mod/Mcp/Exceptions/MissingDependencyException.php +++ b/src/Mcp/Exceptions/MissingDependencyException.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Exceptions; +namespace Core\Mcp\Exceptions; -use Core\Mod\Mcp\Dependencies\ToolDependency; +use Core\Mcp\Dependencies\ToolDependency; use RuntimeException; /** diff --git a/src/Mod/Mcp/Exceptions/MissingWorkspaceContextException.php b/src/Mcp/Exceptions/MissingWorkspaceContextException.php similarity index 100% rename from src/Mod/Mcp/Exceptions/MissingWorkspaceContextException.php rename to src/Mcp/Exceptions/MissingWorkspaceContextException.php diff --git a/src/Mod/Mcp/Lang/en_GB/mcp.php b/src/Mcp/Lang/en_GB/mcp.php similarity index 100% rename from src/Mod/Mcp/Lang/en_GB/mcp.php rename to src/Mcp/Lang/en_GB/mcp.php diff --git a/src/Mod/Mcp/Listeners/RecordToolExecution.php b/src/Mcp/Listeners/RecordToolExecution.php similarity index 97% rename from src/Mod/Mcp/Listeners/RecordToolExecution.php rename to src/Mcp/Listeners/RecordToolExecution.php index 25e09b9..a7cef21 100644 --- a/src/Mod/Mcp/Listeners/RecordToolExecution.php +++ b/src/Mcp/Listeners/RecordToolExecution.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Listeners; +namespace Core\Mcp\Listeners; -use Core\Mod\Mcp\Services\ToolAnalyticsService; +use Core\Mcp\Services\ToolAnalyticsService; /** * Listener to record MCP tool executions for analytics. diff --git a/src/Mod/Mcp/Middleware/CheckMcpQuota.php b/src/Mcp/Middleware/CheckMcpQuota.php similarity index 97% rename from src/Mod/Mcp/Middleware/CheckMcpQuota.php rename to src/Mcp/Middleware/CheckMcpQuota.php index e370220..b94c73d 100644 --- a/src/Mod/Mcp/Middleware/CheckMcpQuota.php +++ b/src/Mcp/Middleware/CheckMcpQuota.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Middleware; +namespace Core\Mcp\Middleware; use Closure; -use Core\Mod\Mcp\Services\McpQuotaService; +use Core\Mcp\Services\McpQuotaService; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Mod/Mcp/Middleware/McpApiKeyAuth.php b/src/Mcp/Middleware/McpApiKeyAuth.php similarity index 98% rename from src/Mod/Mcp/Middleware/McpApiKeyAuth.php rename to src/Mcp/Middleware/McpApiKeyAuth.php index 96150b3..dadcf34 100644 --- a/src/Mod/Mcp/Middleware/McpApiKeyAuth.php +++ b/src/Mcp/Middleware/McpApiKeyAuth.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Middleware; +namespace Core\Mcp\Middleware; use Core\Mod\Api\Models\ApiKey; use Closure; diff --git a/src/Mod/Mcp/Middleware/McpAuthenticate.php b/src/Mcp/Middleware/McpAuthenticate.php similarity index 98% rename from src/Mod/Mcp/Middleware/McpAuthenticate.php rename to src/Mcp/Middleware/McpAuthenticate.php index a4264af..61016fe 100644 --- a/src/Mod/Mcp/Middleware/McpAuthenticate.php +++ b/src/Mcp/Middleware/McpAuthenticate.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Middleware; +namespace Core\Mcp\Middleware; use Core\Mod\Tenant\Models\Workspace; use Core\Mod\Tenant\Services\EntitlementService; diff --git a/src/Mod/Mcp/Middleware/ValidateToolDependencies.php b/src/Mcp/Middleware/ValidateToolDependencies.php similarity index 96% rename from src/Mod/Mcp/Middleware/ValidateToolDependencies.php rename to src/Mcp/Middleware/ValidateToolDependencies.php index 8992a27..f4e7405 100644 --- a/src/Mod/Mcp/Middleware/ValidateToolDependencies.php +++ b/src/Mcp/Middleware/ValidateToolDependencies.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Middleware; +namespace Core\Mcp\Middleware; use Closure; -use Core\Mod\Mcp\Exceptions\MissingDependencyException; -use Core\Mod\Mcp\Services\ToolDependencyService; +use Core\Mcp\Exceptions\MissingDependencyException; +use Core\Mcp\Services\ToolDependencyService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/src/Mod/Mcp/Middleware/ValidateWorkspaceContext.php b/src/Mcp/Middleware/ValidateWorkspaceContext.php similarity index 100% rename from src/Mod/Mcp/Middleware/ValidateWorkspaceContext.php rename to src/Mcp/Middleware/ValidateWorkspaceContext.php diff --git a/src/Mod/Mcp/Migrations/2026_01_07_004936_create_mcp_api_requests_table.php b/src/Mcp/Migrations/2026_01_07_004936_create_mcp_api_requests_table.php similarity index 100% rename from src/Mod/Mcp/Migrations/2026_01_07_004936_create_mcp_api_requests_table.php rename to src/Mcp/Migrations/2026_01_07_004936_create_mcp_api_requests_table.php diff --git a/src/Mod/Mcp/Migrations/2026_01_26_000001_create_mcp_tool_metrics_table.php b/src/Mcp/Migrations/2026_01_26_000001_create_mcp_tool_metrics_table.php similarity index 100% rename from src/Mod/Mcp/Migrations/2026_01_26_000001_create_mcp_tool_metrics_table.php rename to src/Mcp/Migrations/2026_01_26_000001_create_mcp_tool_metrics_table.php diff --git a/src/Mod/Mcp/Migrations/2026_01_26_000002_create_mcp_usage_quotas_table.php b/src/Mcp/Migrations/2026_01_26_000002_create_mcp_usage_quotas_table.php similarity index 100% rename from src/Mod/Mcp/Migrations/2026_01_26_000002_create_mcp_usage_quotas_table.php rename to src/Mcp/Migrations/2026_01_26_000002_create_mcp_usage_quotas_table.php diff --git a/src/Mod/Mcp/Migrations/2026_01_26_000003_create_mcp_audit_logs_table.php b/src/Mcp/Migrations/2026_01_26_000003_create_mcp_audit_logs_table.php similarity index 100% rename from src/Mod/Mcp/Migrations/2026_01_26_000003_create_mcp_audit_logs_table.php rename to src/Mcp/Migrations/2026_01_26_000003_create_mcp_audit_logs_table.php diff --git a/src/Mod/Mcp/Migrations/2026_01_26_000004_create_mcp_tool_versions_table.php b/src/Mcp/Migrations/2026_01_26_000004_create_mcp_tool_versions_table.php similarity index 100% rename from src/Mod/Mcp/Migrations/2026_01_26_000004_create_mcp_tool_versions_table.php rename to src/Mcp/Migrations/2026_01_26_000004_create_mcp_tool_versions_table.php diff --git a/src/Mod/Mcp/Models/McpApiRequest.php b/src/Mcp/Models/McpApiRequest.php similarity index 99% rename from src/Mod/Mcp/Models/McpApiRequest.php rename to src/Mcp/Models/McpApiRequest.php index bdacb4c..b76469c 100644 --- a/src/Mod/Mcp/Models/McpApiRequest.php +++ b/src/Mcp/Models/McpApiRequest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Core\Mod\Tenant\Models\Workspace; use Illuminate\Database\Eloquent\Builder; diff --git a/src/Mod/Mcp/Models/McpAuditLog.php b/src/Mcp/Models/McpAuditLog.php similarity index 99% rename from src/Mod/Mcp/Models/McpAuditLog.php rename to src/Mcp/Models/McpAuditLog.php index ecf3e7a..c602bc0 100644 --- a/src/Mod/Mcp/Models/McpAuditLog.php +++ b/src/Mcp/Models/McpAuditLog.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Core\Mod\Tenant\Concerns\BelongsToWorkspace; use Core\Mod\Tenant\Models\Workspace; diff --git a/src/Mod/Mcp/Models/McpSensitiveTool.php b/src/Mcp/Models/McpSensitiveTool.php similarity index 99% rename from src/Mod/Mcp/Models/McpSensitiveTool.php rename to src/Mcp/Models/McpSensitiveTool.php index 3a03bf1..7649102 100644 --- a/src/Mod/Mcp/Models/McpSensitiveTool.php +++ b/src/Mcp/Models/McpSensitiveTool.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/src/Mod/Mcp/Models/McpToolCall.php b/src/Mcp/Models/McpToolCall.php similarity index 99% rename from src/Mod/Mcp/Models/McpToolCall.php rename to src/Mcp/Models/McpToolCall.php index 9281d99..31a8c97 100644 --- a/src/Mod/Mcp/Models/McpToolCall.php +++ b/src/Mcp/Models/McpToolCall.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Core\Mod\Tenant\Concerns\BelongsToWorkspace; use Core\Mod\Tenant\Models\Workspace; diff --git a/src/Mod/Mcp/Models/McpToolCallStat.php b/src/Mcp/Models/McpToolCallStat.php similarity index 99% rename from src/Mod/Mcp/Models/McpToolCallStat.php rename to src/Mcp/Models/McpToolCallStat.php index 0ed58b2..113573e 100644 --- a/src/Mod/Mcp/Models/McpToolCallStat.php +++ b/src/Mcp/Models/McpToolCallStat.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Core\Mod\Tenant\Concerns\BelongsToWorkspace; use Core\Mod\Tenant\Models\Workspace; diff --git a/src/Mod/Mcp/Models/McpToolVersion.php b/src/Mcp/Models/McpToolVersion.php similarity index 99% rename from src/Mod/Mcp/Models/McpToolVersion.php rename to src/Mcp/Models/McpToolVersion.php index 3bff53a..7bf5bc6 100644 --- a/src/Mod/Mcp/Models/McpToolVersion.php +++ b/src/Mcp/Models/McpToolVersion.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/src/Mod/Mcp/Models/McpUsageQuota.php b/src/Mcp/Models/McpUsageQuota.php similarity index 99% rename from src/Mod/Mcp/Models/McpUsageQuota.php rename to src/Mcp/Models/McpUsageQuota.php index e58d18e..ee6c1ab 100644 --- a/src/Mod/Mcp/Models/McpUsageQuota.php +++ b/src/Mcp/Models/McpUsageQuota.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Core\Mod\Tenant\Concerns\BelongsToWorkspace; use Core\Mod\Tenant\Models\Workspace; diff --git a/src/Mod/Mcp/Models/ToolMetric.php b/src/Mcp/Models/ToolMetric.php similarity index 99% rename from src/Mod/Mcp/Models/ToolMetric.php rename to src/Mcp/Models/ToolMetric.php index 92bb7ac..1ee432a 100644 --- a/src/Mod/Mcp/Models/ToolMetric.php +++ b/src/Mcp/Models/ToolMetric.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\Models; +namespace Core\Mcp\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/src/Mod/Mcp/Resources/AppConfig.php b/src/Mcp/Resources/AppConfig.php similarity index 94% rename from src/Mod/Mcp/Resources/AppConfig.php rename to src/Mcp/Resources/AppConfig.php index ba42cf7..ac623ab 100644 --- a/src/Mod/Mcp/Resources/AppConfig.php +++ b/src/Mcp/Resources/AppConfig.php @@ -1,6 +1,6 @@
diff --git a/src/Mod/Mcp/View/Modal/Admin/ApiKeyManager.php b/src/Mcp/View/Modal/Admin/ApiKeyManager.php similarity index 98% rename from src/Mod/Mcp/View/Modal/Admin/ApiKeyManager.php rename to src/Mcp/View/Modal/Admin/ApiKeyManager.php index 3f98cd2..7fedf83 100644 --- a/src/Mod/Mcp/View/Modal/Admin/ApiKeyManager.php +++ b/src/Mcp/View/Modal/Admin/ApiKeyManager.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; use Core\Mod\Api\Models\ApiKey; use Core\Mod\Tenant\Models\Workspace; diff --git a/src/Mod/Mcp/View/Modal/Admin/AuditLogViewer.php b/src/Mcp/View/Modal/Admin/AuditLogViewer.php similarity index 98% rename from src/Mod/Mcp/View/Modal/Admin/AuditLogViewer.php rename to src/Mcp/View/Modal/Admin/AuditLogViewer.php index df98d14..92b0eea 100644 --- a/src/Mod/Mcp/View/Modal/Admin/AuditLogViewer.php +++ b/src/Mcp/View/Modal/Admin/AuditLogViewer.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\Models\McpAuditLog; -use Core\Mod\Mcp\Services\AuditLogService; +use Core\Mcp\Models\McpAuditLog; +use Core\Mcp\Services\AuditLogService; use Core\Mod\Tenant\Models\Workspace; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Support\Carbon; diff --git a/src/Mod/Mcp/View/Modal/Admin/McpPlayground.php b/src/Mcp/View/Modal/Admin/McpPlayground.php similarity index 99% rename from src/Mod/Mcp/View/Modal/Admin/McpPlayground.php rename to src/Mcp/View/Modal/Admin/McpPlayground.php index 3b4c983..1941e88 100644 --- a/src/Mod/Mcp/View/Modal/Admin/McpPlayground.php +++ b/src/Mcp/View/Modal/Admin/McpPlayground.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; use Core\Mod\Api\Models\ApiKey; -use Core\Mod\Mcp\Services\ToolRegistry; +use Core\Mcp\Services\ToolRegistry; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Session; diff --git a/src/Mod/Mcp/View/Modal/Admin/Playground.php b/src/Mcp/View/Modal/Admin/Playground.php similarity index 99% rename from src/Mod/Mcp/View/Modal/Admin/Playground.php rename to src/Mcp/View/Modal/Admin/Playground.php index ccea82e..12b3d66 100644 --- a/src/Mod/Mcp/View/Modal/Admin/Playground.php +++ b/src/Mcp/View/Modal/Admin/Playground.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; use Core\Mod\Api\Models\ApiKey; use Illuminate\Support\Facades\Http; diff --git a/src/Mod/Mcp/View/Modal/Admin/QuotaUsage.php b/src/Mcp/View/Modal/Admin/QuotaUsage.php similarity index 96% rename from src/Mod/Mcp/View/Modal/Admin/QuotaUsage.php rename to src/Mcp/View/Modal/Admin/QuotaUsage.php index 889afd1..3dc3564 100644 --- a/src/Mod/Mcp/View/Modal/Admin/QuotaUsage.php +++ b/src/Mcp/View/Modal/Admin/QuotaUsage.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\Services\McpQuotaService; +use Core\Mcp\Services\McpQuotaService; use Core\Mod\Tenant\Models\Workspace; use Illuminate\Support\Collection; use Livewire\Component; diff --git a/src/Mod/Mcp/View/Modal/Admin/RequestLog.php b/src/Mcp/View/Modal/Admin/RequestLog.php similarity index 96% rename from src/Mod/Mcp/View/Modal/Admin/RequestLog.php rename to src/Mcp/View/Modal/Admin/RequestLog.php index 1927c28..147266c 100644 --- a/src/Mod/Mcp/View/Modal/Admin/RequestLog.php +++ b/src/Mcp/View/Modal/Admin/RequestLog.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\Models\McpApiRequest; +use Core\Mcp\Models\McpApiRequest; use Livewire\Attributes\Layout; use Livewire\Component; use Livewire\WithPagination; diff --git a/src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php b/src/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php similarity index 98% rename from src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php rename to src/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php index 4676eeb..5e8c3ea 100644 --- a/src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php +++ b/src/Mcp/View/Modal/Admin/ToolAnalyticsDashboard.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\DTO\ToolStats; -use Core\Mod\Mcp\Services\ToolAnalyticsService; +use Core\Mcp\DTO\ToolStats; +use Core\Mcp\Services\ToolAnalyticsService; use Illuminate\Support\Collection; use Livewire\Attributes\Layout; use Livewire\Attributes\Url; diff --git a/src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php b/src/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php similarity index 95% rename from src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php rename to src/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php index e58f207..7353724 100644 --- a/src/Mod/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php +++ b/src/Mcp/View/Modal/Admin/ToolAnalyticsDetail.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\DTO\ToolStats; -use Core\Mod\Mcp\Services\ToolAnalyticsService; +use Core\Mcp\DTO\ToolStats; +use Core\Mcp\Services\ToolAnalyticsService; use Livewire\Attributes\Layout; use Livewire\Attributes\Url; use Livewire\Component; diff --git a/src/Mod/Mcp/View/Modal/Admin/ToolVersionManager.php b/src/Mcp/View/Modal/Admin/ToolVersionManager.php similarity index 98% rename from src/Mod/Mcp/View/Modal/Admin/ToolVersionManager.php rename to src/Mcp/View/Modal/Admin/ToolVersionManager.php index bea8367..74a862e 100644 --- a/src/Mod/Mcp/View/Modal/Admin/ToolVersionManager.php +++ b/src/Mcp/View/Modal/Admin/ToolVersionManager.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Core\Mod\Mcp\View\Modal\Admin; +namespace Core\Mcp\View\Modal\Admin; -use Core\Mod\Mcp\Models\McpToolVersion; -use Core\Mod\Mcp\Services\ToolVersionService; +use Core\Mcp\Models\McpToolVersion; +use Core\Mcp\Services\ToolVersionService; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Support\Carbon; use Illuminate\Support\Collection; diff --git a/src/Website/Mcp/View/Modal/McpMetrics.php b/src/Website/Mcp/View/Modal/McpMetrics.php index 00d20d6..50f2267 100644 --- a/src/Website/Mcp/View/Modal/McpMetrics.php +++ b/src/Website/Mcp/View/Modal/McpMetrics.php @@ -6,7 +6,7 @@ namespace Core\Website\Mcp\View\Modal; use Livewire\Attributes\Layout; use Livewire\Component; -use Core\Mod\Mcp\Services\McpMetricsService; +use Core\Mcp\Services\McpMetricsService; /** * MCP Metrics Dashboard diff --git a/src/Website/Mcp/View/Modal/McpPlayground.php b/src/Website/Mcp/View/Modal/McpPlayground.php index e879e99..2506153 100644 --- a/src/Website/Mcp/View/Modal/McpPlayground.php +++ b/src/Website/Mcp/View/Modal/McpPlayground.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\RateLimiter; use Livewire\Attributes\Layout; use Livewire\Component; -use Core\Mod\Mcp\Models\McpToolCall; +use Core\Mcp\Models\McpToolCall; use Symfony\Component\Process\Process; use Symfony\Component\Yaml\Yaml; diff --git a/src/Website/Mcp/View/Modal/RequestLog.php b/src/Website/Mcp/View/Modal/RequestLog.php index 0e81606..1bc6292 100644 --- a/src/Website/Mcp/View/Modal/RequestLog.php +++ b/src/Website/Mcp/View/Modal/RequestLog.php @@ -7,7 +7,7 @@ namespace Core\Website\Mcp\View\Modal; use Livewire\Attributes\Layout; use Livewire\Component; use Livewire\WithPagination; -use Core\Mod\Mcp\Models\McpApiRequest; +use Core\Mcp\Models\McpApiRequest; /** * MCP Request Log - view and replay API requests.