> */ protected array $tools = []; /** * The resources registered with this MCP server. * * @var array> */ protected array $resources = []; /** * The prompts registered with this MCP server. * * @var array> */ protected array $prompts = []; protected function boot(): void { $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; } /** * @return array> */ protected function discoverTools(): array { return $this->filterPrimitives([ ApplicationInfo::class, BrowserLogs::class, DatabaseConnections::class, DatabaseQuery::class, DatabaseSchema::class, GetAbsoluteUrl::class, GetConfig::class, LastError::class, ListArtisanCommands::class, ListAvailableConfigKeys::class, ListAvailableEnvVars::class, ListRoutes::class, ReadLogEntries::class, SearchDocs::class, Tinker::class, ], 'tools'); } /** * @return array> */ protected function discoverResources(): array { $availableResources = [ Resources\ApplicationInfo::class, ...$this->discoverThirdPartyPrimitives(Resource::class), ]; return $this->filterPrimitives($availableResources, 'resources'); } /** * @return array> */ protected function discoverPrompts(): array { return $this->filterPrimitives( $this->discoverThirdPartyPrimitives(Prompt::class), 'prompts' ); } /** * @template T of Prompt|Resource * * @param class-string $primitiveType * @return array */ private function discoverThirdPartyPrimitives(string $primitiveType): array { $primitiveClass = match ($primitiveType) { Prompt::class => PackageGuidelinePrompt::class, Resource::class => PackageGuidelineResource::class, default => throw new InvalidArgumentException('Invalid Primitive Type'), }; $primitives = []; foreach (Composer::packagesDirectoriesWithBoostGuidelines() as $package => $path) { $corePath = $path.DIRECTORY_SEPARATOR.'core.blade.php'; if (file_exists($corePath)) { $primitives[] = new $primitiveClass($package, $corePath); } } return $primitives; } /** * @param array $availablePrimitives * @return array */ private function filterPrimitives(array $availablePrimitives, string $type): array { $excludeList = config("boost.mcp.{$type}.exclude", []); $includeList = config("boost.mcp.{$type}.include", []); $filtered = collect($availablePrimitives)->reject(function (string|object $item) use ($excludeList): bool { $className = is_string($item) ? $item : $item::class; return in_array($className, $excludeList, true); }); $explicitlyIncluded = collect($includeList) ->filter(fn (string $class): bool => class_exists($class)); return $filtered ->merge($explicitlyIncluded) ->values() ->all(); } }