@@ -87,6 +87,8 @@ private function generateStdioConfig(Providers $provider): void
8787
8888 if ($ provider === Providers::ClaudeCode) {
8989 $ this ->generateClaudeCodeCommand ($ projectPath , $ userId , $ userModel );
90+ } elseif ($ provider === Providers::Cursor) {
91+ $ this ->generateCursorDeeplink ($ projectPath , $ userId , $ userModel );
9092 } else {
9193 $ this ->generateJsonConfig ($ projectPath , $ userId , $ userModel );
9294 }
@@ -108,6 +110,8 @@ private function generateHttpSseConfig(Providers $provider): void
108110
109111 if ($ provider === Providers::ClaudeCode) {
110112 $ this ->generateClaudeCodeHttpConfig ($ baseUrl , $ ssePath );
113+ } elseif ($ provider === Providers::Cursor) {
114+ $ this ->generateCursorHttpDeeplink ($ baseUrl , $ ssePath );
111115 } else {
112116 $ this ->generateJsonHttpConfig ($ provider , $ baseUrl , $ ssePath );
113117 }
@@ -133,6 +137,42 @@ private function generateClaudeCodeCommand(string $projectPath, ?string $userId,
133137 $ this ->comment ('💡 Copy and paste this command in your terminal to add the MCP server to Claude Code. ' );
134138 }
135139
140+ private function generateCursorDeeplink (string $ projectPath , ?string $ userId , ?string $ userModel ): void
141+ {
142+ $ args = [];
143+
144+ if ($ userId ) {
145+ $ args [] = "--user-id= {$ userId }" ;
146+ if ($ userModel && $ userModel !== 'App \\Models \\User ' ) {
147+ $ args [] = "--user-model= {$ userModel }" ;
148+ }
149+ }
150+
151+ $ config = [
152+ 'command ' => "php {$ projectPath }/artisan loop:mcp:start " ,
153+ 'args ' => $ args ,
154+ ];
155+
156+ $ configJson = json_encode ($ config , JSON_UNESCAPED_SLASHES );
157+ $ configBase64 = base64_encode ($ configJson );
158+ $ deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config= {$ configBase64 }" ;
159+
160+ $ this ->info ('🎯🎯🎯 Cursor Deeplink: 🎯🎯🎯 ' );
161+ $ this ->newLine ();
162+
163+ $ this ->table ([], [[$ deeplink ]]);
164+
165+ $ this ->newLine ();
166+ $ this ->comment ('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor. ' );
167+ $ this ->newLine ();
168+ $ this ->comment ('📋 Alternatively, you can copy the following JSON configuration manually: ' );
169+ $ this ->newLine ();
170+
171+ $ this ->table ([], [[
172+ json_encode (['laravel-loop-mcp ' => $ config ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )
173+ ]]);
174+ }
175+
136176 private function generateJsonConfig (string $ projectPath , ?string $ userId , ?string $ userModel ): void
137177 {
138178 $ args = [
@@ -159,9 +199,7 @@ private function generateJsonConfig(string $projectPath, ?string $userId, ?strin
159199 $ this ->comment ('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯 ' );
160200 $ this ->newLine ();
161201
162- $ this ->table ([], [[
163- json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ),
164- ]]);
202+ $ this ->line (json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
165203
166204 $ this ->newLine ();
167205 $ this ->newLine ();
@@ -190,6 +228,48 @@ private function generateClaudeCodeHttpConfig(string $baseUrl, string $ssePath):
190228 $ this ->additionalHttpSetupMessages ();
191229 }
192230
231+ private function generateCursorHttpDeeplink (string $ baseUrl , string $ ssePath ): void
232+ {
233+ $ headers = $ this ->collectHeaders ();
234+
235+ $ config = [
236+ 'transport ' => 'sse ' ,
237+ 'url ' => rtrim ($ baseUrl , '/ ' ).$ ssePath ,
238+ ];
239+
240+ if (!empty ($ headers )) {
241+ $ config ['headers ' ] = [];
242+ foreach ($ headers as $ header ) {
243+ $ parts = explode (': ' , $ header , 2 );
244+ if (count ($ parts ) === 2 ) {
245+ $ config ['headers ' ][trim ($ parts [0 ])] = trim ($ parts [1 ]);
246+ }
247+ }
248+ }
249+
250+ $ configJson = json_encode ($ config , JSON_UNESCAPED_SLASHES );
251+ $ configBase64 = base64_encode ($ configJson );
252+ $ deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config= {$ configBase64 }" ;
253+
254+ $ this ->comment ('🎯🎯🎯 Cursor HTTP + SSE Deeplink Configuration: 🎯🎯🎯 ' );
255+ $ this ->newLine ();
256+
257+ $ this ->table ([], [[$ deeplink ]]);
258+
259+ $ this ->newLine ();
260+ $ this ->comment ('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor. ' );
261+ $ this ->newLine ();
262+ $ this ->comment ('📋 Alternatively, you can copy the following JSON configuration manually: ' );
263+ $ this ->newLine ();
264+
265+ $ this ->table ([], [[
266+ json_encode (['laravel-loop-mcp ' => $ config ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )
267+ ]]);
268+
269+ $ this ->newLine ();
270+ $ this ->additionalHttpSetupMessages ();
271+ }
272+
193273 /**
194274 * @return array<string>
195275 */
@@ -273,9 +353,7 @@ private function generateJsonHttpConfigWithProxy(string $baseUrl, array $headers
273353 $ this ->comment ('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯 ' );
274354 $ this ->newLine ();
275355
276- $ this ->table ([], [[
277- json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ),
278- ]]);
356+ $ this ->line (json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
279357
280358 $ this ->newLine ();
281359 $ this ->additionalHttpSetupMessages ();
@@ -300,9 +378,7 @@ private function generateJsonHttpConfigFirstPartySupport(string $baseUrl, string
300378 $ this ->comment ('🎯🎯🎯 Please copy the following JSON configuration to your MCP client configuration file. 🎯🎯🎯 ' );
301379 $ this ->newLine ();
302380
303- $ this ->table ([], [[
304- json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ),
305- ]]);
381+ $ this ->line (json_encode ($ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
306382
307383 $ this ->newLine ();
308384 $ this ->newLine ();
0 commit comments