feat: multi-domain support for MCP portal routes

Register routes for each domain in config('mcp.domains') array,
allowing the portal to serve from multiple subdomains (e.g.
mcp.host.test and mcp.lthn.test simultaneously).

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-03 16:59:26 +00:00
parent 547860dd57
commit 27e1336b24

View file

@ -6,17 +6,19 @@ use Core\Website\Mcp\Controllers\McpRegistryController;
/*
|--------------------------------------------------------------------------
| MCP Portal Routes (mcp.host.uk.com)
| MCP Portal Routes (mcp.host.uk.com / mcp.lthn.test etc.)
|--------------------------------------------------------------------------
|
| Public routes for the MCP server registry and documentation portal.
| These routes serve both human-readable docs and machine-readable JSON.
|
| Supports multiple domains via config('mcp.domains').
|
*/
$mcpDomain = config('mcp.domain', 'mcp.host.uk.com');
$mcpDomains = config('mcp.domains', [config('mcp.domain', 'mcp.host.uk.com')]);
Route::domain($mcpDomain)->name('mcp.')->group(function () {
$registerMcpRoutes = function () {
// Agent discovery endpoint (always JSON)
Route::get('.well-known/mcp-servers.json', [McpRegistryController::class, 'registry'])
->name('registry');
@ -45,4 +47,12 @@ Route::domain($mcpDomain)->name('mcp.')->group(function () {
// OpenAPI spec
Route::get('openapi.json', [McpRegistryController::class, 'openapi'])->name('openapi.json');
Route::get('openapi.yaml', [McpRegistryController::class, 'openapi'])->name('openapi.yaml');
});
};
// Primary domain gets named routes (mcp.landing, mcp.servers.index, etc.)
Route::domain($mcpDomains[0])->name('mcp.')->group($registerMcpRoutes);
// Additional domains get the same routes without named duplicates
foreach (array_slice($mcpDomains, 1) as $domain) {
Route::domain($domain)->group($registerMcpRoutes);
}