21817543ad
Adds a native Nextcloud app "Astroglobe" that provides: - Personal settings: OAuth authorization for background MCP access - Admin settings: Server status and vector sync monitoring - API endpoints for MCP server communication The app uses PKCE OAuth flow to obtain tokens for the MCP server, enabling features like background vector sync per ADR-018. Includes: - PHP app structure (controllers, services, settings) - Vue.js frontend components - Docker compose mount configuration - Installation hook for development testing - ADR-018 documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Astroglobe\Settings;
|
|
|
|
use OCA\Astroglobe\AppInfo\Application;
|
|
use OCA\Astroglobe\Service\McpServerClient;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\AppFramework\Services\IInitialState;
|
|
use OCP\IConfig;
|
|
use OCP\Settings\ISettings;
|
|
|
|
/**
|
|
* Admin settings panel for MCP Server.
|
|
*
|
|
* Displays server status, vector sync metrics, configuration,
|
|
* and provides administrative controls.
|
|
*/
|
|
class Admin implements ISettings {
|
|
private $client;
|
|
private $config;
|
|
private $initialState;
|
|
|
|
public function __construct(
|
|
McpServerClient $client,
|
|
IConfig $config,
|
|
IInitialState $initialState
|
|
) {
|
|
$this->client = $client;
|
|
$this->config = $config;
|
|
$this->initialState = $initialState;
|
|
}
|
|
|
|
/**
|
|
* @return TemplateResponse
|
|
*/
|
|
public function getForm(): TemplateResponse {
|
|
// Fetch data from MCP server
|
|
$serverStatus = $this->client->getStatus();
|
|
$vectorSyncStatus = $this->client->getVectorSyncStatus();
|
|
|
|
// Get configuration from config.php
|
|
$serverUrl = $this->config->getSystemValue('mcp_server_url', '');
|
|
$apiKeyConfigured = !empty($this->config->getSystemValue('mcp_server_api_key', ''));
|
|
|
|
// Check for server connection error
|
|
if (isset($serverStatus['error'])) {
|
|
return new TemplateResponse(
|
|
Application::APP_ID,
|
|
'settings/error',
|
|
[
|
|
'error' => 'Cannot connect to MCP server',
|
|
'details' => $serverStatus['error'],
|
|
'server_url' => $serverUrl,
|
|
'help_text' => 'Ensure MCP server is running and accessible. Check config.php for correct mcp_server_url.',
|
|
],
|
|
TemplateResponse::RENDER_AS_BLANK
|
|
);
|
|
}
|
|
|
|
// Provide initial state for Vue.js frontend (if needed)
|
|
$this->initialState->provideInitialState('server-data', [
|
|
'serverStatus' => $serverStatus,
|
|
'vectorSyncStatus' => $vectorSyncStatus,
|
|
'config' => [
|
|
'serverUrl' => $serverUrl,
|
|
'apiKeyConfigured' => $apiKeyConfigured,
|
|
],
|
|
]);
|
|
|
|
$parameters = [
|
|
'serverStatus' => $serverStatus,
|
|
'vectorSyncStatus' => $vectorSyncStatus,
|
|
'serverUrl' => $serverUrl,
|
|
'apiKeyConfigured' => $apiKeyConfigured,
|
|
'vectorSyncEnabled' => $serverStatus['vector_sync_enabled'] ?? false,
|
|
];
|
|
|
|
return new TemplateResponse(
|
|
Application::APP_ID,
|
|
'settings/admin',
|
|
$parameters,
|
|
TemplateResponse::RENDER_AS_BLANK
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return string The section ID
|
|
*/
|
|
public function getSection(): string {
|
|
return 'mcp';
|
|
}
|
|
|
|
/**
|
|
* @return int Priority (lower = higher up)
|
|
*/
|
|
public function getPriority(): int {
|
|
return 10;
|
|
}
|
|
}
|