From 39e5289b2b14d27cb60e70de484c558eda56be04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= <34519027+fsmonter@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:32:35 +0100 Subject: [PATCH 1/3] Generate cursor deeplink --- src/Commands/LoopMcpConfigCommand.php | 94 ++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 9 deletions(-) diff --git a/src/Commands/LoopMcpConfigCommand.php b/src/Commands/LoopMcpConfigCommand.php index 31d2d48..9f8ea71 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,42 @@ 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 {$projectPath}/artisan loop:mcp:start", + 'args' => $args, + ]; + + $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); + $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('📋 Alternatively, you can copy the following JSON configuration manually:'); + $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 = [ @@ -159,9 +199,7 @@ private function generateJsonConfig(string $projectPath, ?string $userId, ?strin $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->table([], [[ - json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), - ]]); + $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $this->newLine(); $this->newLine(); @@ -190,6 +228,48 @@ 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); + $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('📋 Alternatively, you can copy the following JSON configuration manually:'); + $this->newLine(); + + $this->table([], [[ + json_encode(['laravel-loop-mcp' => $config], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); + + $this->newLine(); + $this->additionalHttpSetupMessages(); + } + /** * @return array */ @@ -273,9 +353,7 @@ private function generateJsonHttpConfigWithProxy(string $baseUrl, array $headers $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->table([], [[ - json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), - ]]); + $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $this->newLine(); $this->additionalHttpSetupMessages(); @@ -300,9 +378,7 @@ private function generateJsonHttpConfigFirstPartySupport(string $baseUrl, string $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->table([], [[ - json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), - ]]); + $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $this->newLine(); $this->newLine(); From 835010cd56bf127d84fe1c653b77f32698984d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= <34519027+fsmonter@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:38:04 +0100 Subject: [PATCH 2/3] Fix stan errors --- src/Commands/LoopMcpConfigCommand.php | 50 +++++++++++++++++---------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Commands/LoopMcpConfigCommand.php b/src/Commands/LoopMcpConfigCommand.php index 9f8ea71..0c9d721 100644 --- a/src/Commands/LoopMcpConfigCommand.php +++ b/src/Commands/LoopMcpConfigCommand.php @@ -154,18 +154,21 @@ private function generateCursorDeeplink(string $projectPath, ?string $userId, ?s ]; $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); - $configBase64 = base64_encode($configJson); - $deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}"; + if ($configJson) { + $configBase64 = base64_encode($configJson); + $deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}"; + $this->info('🎯🎯🎯 Cursor Deeplink: 🎯🎯🎯'); - $this->info('🎯🎯🎯 Cursor Deeplink: 🎯🎯🎯'); - $this->newLine(); + $this->newLine(); - $this->table([], [[$deeplink]]); + $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('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.'); - $this->newLine(); - $this->comment('📋 Alternatively, you can copy the following JSON configuration manually:'); + $this->comment('📋 You can copy the following JSON configuration:'); $this->newLine(); $this->table([], [[ @@ -199,7 +202,9 @@ private function generateJsonConfig(string $projectPath, ?string $userId, ?strin $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->table([], [[ + json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); $this->newLine(); $this->newLine(); @@ -248,18 +253,21 @@ private function generateCursorHttpDeeplink(string $baseUrl, string $ssePath): v } $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); - $configBase64 = base64_encode($configJson); - $deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}"; + 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->comment('🎯🎯🎯 Cursor HTTP + SSE Deeplink Configuration: 🎯🎯🎯'); + $this->newLine(); - $this->table([], [[$deeplink]]); + $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('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.'); - $this->newLine(); - $this->comment('📋 Alternatively, you can copy the following JSON configuration manually:'); + $this->comment('📋 You can copy the following JSON configuration:'); $this->newLine(); $this->table([], [[ @@ -353,7 +361,9 @@ private function generateJsonHttpConfigWithProxy(string $baseUrl, array $headers $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->table([], [[ + json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); $this->newLine(); $this->additionalHttpSetupMessages(); @@ -378,7 +388,9 @@ private function generateJsonHttpConfigFirstPartySupport(string $baseUrl, string $this->comment('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯'); $this->newLine(); - $this->line(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->table([], [[ + json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), + ]]); $this->newLine(); $this->newLine(); From dd2e2415de85361ef30921d0c365c60e9cc964d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= <34519027+fsmonter@users.noreply.github.com> Date: Thu, 5 Jun 2025 15:56:24 +0100 Subject: [PATCH 3/3] Fix command config args --- src/Commands/LoopMcpConfigCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Commands/LoopMcpConfigCommand.php b/src/Commands/LoopMcpConfigCommand.php index 0c9d721..dc03caa 100644 --- a/src/Commands/LoopMcpConfigCommand.php +++ b/src/Commands/LoopMcpConfigCommand.php @@ -149,11 +149,16 @@ private function generateCursorDeeplink(string $projectPath, ?string $userId, ?s } $config = [ - 'command' => "php {$projectPath}/artisan loop:mcp:start", - 'args' => $args, + '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}";