Skip to content

Commit 264c5c8

Browse files
authored
Generate cursor deeplink (#23)
* Generate cursor deeplink * Fix stan errors * Fix command config args
1 parent a8732ec commit 264c5c8

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

src/Commands/LoopMcpConfigCommand.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,50 @@ 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',
153+
'args' => [
154+
"{$projectPath}/artisan",
155+
'loop:mcp:start',
156+
...$args,
157+
],
158+
];
159+
160+
$configJson = json_encode($config, JSON_UNESCAPED_SLASHES);
161+
162+
if ($configJson) {
163+
$configBase64 = base64_encode($configJson);
164+
$deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}";
165+
$this->info('🎯🎯🎯 Cursor Deeplink: 🎯🎯🎯');
166+
167+
$this->newLine();
168+
169+
$this->table([], [[$deeplink]]);
170+
171+
$this->newLine();
172+
$this->comment('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.');
173+
}
174+
175+
$this->newLine();
176+
$this->comment('📋 You can copy the following JSON configuration:');
177+
$this->newLine();
178+
179+
$this->table([], [[
180+
json_encode(['laravel-loop-mcp' => $config], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
181+
]]);
182+
}
183+
136184
private function generateJsonConfig(string $projectPath, ?string $userId, ?string $userModel): void
137185
{
138186
$args = [
@@ -190,6 +238,51 @@ private function generateClaudeCodeHttpConfig(string $baseUrl, string $ssePath):
190238
$this->additionalHttpSetupMessages();
191239
}
192240

241+
private function generateCursorHttpDeeplink(string $baseUrl, string $ssePath): void
242+
{
243+
$headers = $this->collectHeaders();
244+
245+
$config = [
246+
'transport' => 'sse',
247+
'url' => rtrim($baseUrl, '/').$ssePath,
248+
];
249+
250+
if (! empty($headers)) {
251+
$config['headers'] = [];
252+
foreach ($headers as $header) {
253+
$parts = explode(':', $header, 2);
254+
if (count($parts) === 2) {
255+
$config['headers'][trim($parts[0])] = trim($parts[1]);
256+
}
257+
}
258+
}
259+
260+
$configJson = json_encode($config, JSON_UNESCAPED_SLASHES);
261+
if ($configJson) {
262+
$configBase64 = base64_encode($configJson);
263+
$deeplink = "cursor://anysphere.cursor-deeplink/mcp/install?name=laravel-loop-mcp&config={$configBase64}";
264+
265+
$this->comment('🎯🎯🎯 Cursor HTTP + SSE Deeplink Configuration: 🎯🎯🎯');
266+
$this->newLine();
267+
268+
$this->table([], [[$deeplink]]);
269+
270+
$this->newLine();
271+
$this->comment('💡 Click on the link above or copy and paste it into your browser to install the MCP server in Cursor.');
272+
}
273+
274+
$this->newLine();
275+
$this->comment('📋 You can copy the following JSON configuration:');
276+
$this->newLine();
277+
278+
$this->table([], [[
279+
json_encode(['laravel-loop-mcp' => $config], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
280+
]]);
281+
282+
$this->newLine();
283+
$this->additionalHttpSetupMessages();
284+
}
285+
193286
/**
194287
* @return array<string>
195288
*/

0 commit comments

Comments
 (0)