diff --git a/src/Commands/LoopMcpConfigCommand.php b/src/Commands/LoopMcpConfigCommand.php index 31d2d48..dc03caa 100644 --- a/src/Commands/LoopMcpConfigCommand.php +++ b/src/Commands/LoopMcpConfigCommand.php @@ -87,6 +87,8 @@ private function generateStdioConfig(Providers $provider): void if ($provider === Providers::ClaudeCode) { $this->generateClaudeCodeCommand($projectPath, $userId, $userModel); + } elseif ($provider === Providers::Cursor) { + $this->generateCursorDeeplink($projectPath, $userId, $userModel); } else { $this->generateJsonConfig($projectPath, $userId, $userModel); } @@ -108,6 +110,8 @@ private function generateHttpSseConfig(Providers $provider): void if ($provider === Providers::ClaudeCode) { $this->generateClaudeCodeHttpConfig($baseUrl, $ssePath); + } elseif ($provider === Providers::Cursor) { + $this->generateCursorHttpDeeplink($baseUrl, $ssePath); } else { $this->generateJsonHttpConfig($provider, $baseUrl, $ssePath); } @@ -133,6 +137,50 @@ private function generateClaudeCodeCommand(string $projectPath, ?string $userId, $this->comment('💡 Copy and paste this command in your terminal to add the MCP server to Claude Code.'); } + private function generateCursorDeeplink(string $projectPath, ?string $userId, ?string $userModel): void + { + $args = []; + + if ($userId) { + $args[] = "--user-id={$userId}"; + if ($userModel && $userModel !== 'App\\Models\\User') { + $args[] = "--user-model={$userModel}"; + } + } + + $config = [ + 'command' => 'php', + 'args' => [ + "{$projectPath}/artisan", + 'loop:mcp:start', + ...$args, + ], + ]; + + $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); + + if ($configJson) { + $configBase64 = base64_encode($configJson); + $deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}"; + $this->info('🎯🎯🎯 Cursor Deeplink: 🎯🎯🎯'); + + $this->newLine(); + + $this->table([], [[$deeplink]]); + + $this->newLine(); + $this->comment('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.'); + } + + $this->newLine(); + $this->comment('📋 You can copy the following JSON configuration:'); + $this->newLine(); + + $this->table([], [[ + json_encode(['laravel-loop-mcp' => $config], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); + } + private function generateJsonConfig(string $projectPath, ?string $userId, ?string $userModel): void { $args = [ @@ -190,6 +238,51 @@ private function generateClaudeCodeHttpConfig(string $baseUrl, string $ssePath): $this->additionalHttpSetupMessages(); } + private function generateCursorHttpDeeplink(string $baseUrl, string $ssePath): void + { + $headers = $this->collectHeaders(); + + $config = [ + 'transport' => 'sse', + 'url' => rtrim($baseUrl, '/').$ssePath, + ]; + + if (! empty($headers)) { + $config['headers'] = []; + foreach ($headers as $header) { + $parts = explode(':', $header, 2); + if (count($parts) === 2) { + $config['headers'][trim($parts[0])] = trim($parts[1]); + } + } + } + + $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); + if ($configJson) { + $configBase64 = base64_encode($configJson); + $deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}"; + + $this->comment('🎯🎯🎯 Cursor HTTP + SSE Deeplink Configuration: 🎯🎯🎯'); + $this->newLine(); + + $this->table([], [[$deeplink]]); + + $this->newLine(); + $this->comment('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.'); + } + + $this->newLine(); + $this->comment('📋 You can copy the following JSON configuration:'); + $this->newLine(); + + $this->table([], [[ + json_encode(['laravel-loop-mcp' => $config], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); + + $this->newLine(); + $this->additionalHttpSetupMessages(); + } + /** * @return array */