Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into 3rd_party_prompt
Signed-off-by: Pushpak Chhajed <[email protected]>

# Conflicts:
#	src/Mcp/Boost.php
  • Loading branch information
pushpak1300 committed Dec 12, 2025
commit 3569fdc8d834547043d3c0f7780475ce92f10af0
83 changes: 52 additions & 31 deletions src/Mcp/Boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@

namespace Laravel\Boost\Mcp;

use DirectoryIterator;
use Laravel\Boost\Install\GuidelineAssist;
use Laravel\Boost\Mcp\Methods\CallToolWithExecutor;
use Laravel\Boost\Mcp\Prompts\BladePrompt;
use Laravel\Boost\Mcp\Resources\ApplicationInfo;
use Laravel\Boost\Mcp\Tools\ApplicationInfo;
use Laravel\Boost\Mcp\Tools\BrowserLogs;
use Laravel\Boost\Mcp\Tools\DatabaseConnections;
use Laravel\Boost\Mcp\Tools\DatabaseQuery;
use Laravel\Boost\Mcp\Tools\DatabaseSchema;
use Laravel\Boost\Mcp\Tools\GetAbsoluteUrl;
use Laravel\Boost\Mcp\Tools\GetConfig;
use Laravel\Boost\Mcp\Tools\LastError;
use Laravel\Boost\Mcp\Tools\ListArtisanCommands;
use Laravel\Boost\Mcp\Tools\ListAvailableConfigKeys;
use Laravel\Boost\Mcp\Tools\ListAvailableEnvVars;
use Laravel\Boost\Mcp\Tools\ListRoutes;
use Laravel\Boost\Mcp\Tools\ReadLogEntries;
use Laravel\Boost\Mcp\Tools\ReportFeedback;
use Laravel\Boost\Mcp\Tools\SearchDocs;
use Laravel\Boost\Mcp\Tools\Tinker;
use Laravel\Boost\Support\Composer;
use Laravel\Mcp\Server;
use Laravel\Mcp\Server\Prompt;
Expand Down Expand Up @@ -60,37 +74,20 @@ class Boost extends Server

protected function boot(): void
{
collect($this->discoverTools())->each(fn (string $tool): string => $this->tools[] = $tool);
collect($this->discoverResources())->each(fn (string $resource): string => $this->resources[] = $resource);

$this->discoverThirdPartyPrompts();
$this->tools = $this->discoverTools();
$this->resources = $this->discoverResources();
$this->prompts = $this->discoverPrompts();

// Override the tools/call method to use our ToolExecutor
$this->methods['tools/call'] = CallToolWithExecutor::class;
}

/**
* @param array<int, class-string> $availablePrimitives
* @return array<int, class-string>
*/
private function discoverPrimitives(array $availablePrimitives, string $type): array
{
return collect($availablePrimitives)
->diff(config("boost.mcp.{$type}.exclude", []))
->merge(
collect(config("boost.mcp.{$type}.include", []))
->filter(fn (string $class): bool => class_exists($class))
)
->values()
->all();
}

/**
* @return array<int, class-string<Tool>>
*/
protected function discoverTools(): array
{
return $this->discoverPrimitives([
return $this->filterPrimitives([
ApplicationInfo::class,
BrowserLogs::class,
DatabaseConnections::class,
Expand All @@ -115,27 +112,51 @@ protected function discoverTools(): array
*/
protected function discoverResources(): array
{
return $this->discoverPrimitives([
return $this->filterPrimitives([
Resources\ApplicationInfo::class,
], 'resources');
}

protected function discoverThirdPartyPrompts(): void
/**
* @return array<int, class-string<Prompt>>
*/
protected function discoverPrompts(): array
{
return $this->filterPrimitives(
$this->discoverThirdPartyPrompts(),
'prompts'
);
}

protected function discoverThirdPartyPrompts(): array
{
$thirdPartyPrompts = [];
$guidelineAssist = app(GuidelineAssist::class);

foreach (Composer::packagesDirectoriesWithBoostGuidelines() as $package => $path) {
$corePath = $path.DIRECTORY_SEPARATOR.'core.blade.php';
$guidelinePath = $path.DIRECTORY_SEPARATOR.'core.blade.php';

if (file_exists($corePath)) {
$this->registerThirdPartyPrompt($package, $corePath, $guidelineAssist);
if (file_exists($guidelinePath)) {
$thirdPartyPrompts[] = new BladePrompt($guidelineAssist, $package, $guidelinePath);
}
}

return $thirdPartyPrompts;
}

protected function registerThirdPartyPrompt(string $package, string $bladePath, GuidelineAssist $guidelineAssist): void
/**
* @param array<int, class-string> $availablePrimitives
* @return array<int, class-string>
*/
private function filterPrimitives(array $availablePrimitives, string $type): array
{
$prompt = new BladePrompt($guidelineAssist, $package, $bladePath);
$this->prompts[] = $prompt;
return collect($availablePrimitives)
->diff(config("boost.mcp.{$type}.exclude", []))
->merge(
collect(config("boost.mcp.{$type}.include", []))
->filter(fn (string $class): bool => class_exists($class))
)
->values()
->all();
}
}
You are viewing a condensed version of this merge commit. You can view the full changes here.