mcps and skills

This commit is contained in:
2026-08-11 00:42:46 +03:00
parent 6ffb24f20a
commit 4e67077e12
44 changed files with 2158 additions and 0 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Filament\Resources\McpServers;
use App\Filament\Resources\McpServers\Pages\CreateMcpServer;
use App\Filament\Resources\McpServers\Pages\EditMcpServer;
use App\Filament\Resources\McpServers\Pages\ListMcpServers;
use App\Filament\Resources\McpServers\Schemas\McpServerForm;
use App\Filament\Resources\McpServers\Tables\McpServersTable;
use App\Models\McpServer;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
class McpServerResource extends Resource
{
protected static ?string $model = McpServer::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedServerStack;
protected static string|\UnitEnum|null $navigationGroup = 'Tools';
protected static ?string $navigationLabel = 'MCP Servers';
protected static ?string $recordTitleAttribute = 'name';
public static function form(Schema $schema): Schema
{
return McpServerForm::configure($schema);
}
public static function table(Table $table): Table
{
return McpServersTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListMcpServers::route('/'),
'create' => CreateMcpServer::route('/create'),
'edit' => EditMcpServer::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\McpServers\Pages;
use App\Filament\Resources\McpServers\McpServerResource;
use Filament\Resources\Pages\CreateRecord;
class CreateMcpServer extends CreateRecord
{
protected static string $resource = McpServerResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\McpServers\Pages;
use App\Filament\Resources\McpServers\McpServerResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditMcpServer extends EditRecord
{
protected static string $resource = McpServerResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\McpServers\Pages;
use App\Filament\Resources\McpServers\McpServerResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListMcpServers extends ListRecords
{
protected static string $resource = McpServerResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,110 @@
<?php
namespace App\Filament\Resources\McpServers\Schemas;
use App\Models\McpServer;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class McpServerForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(3)
->components([
Section::make('Details')
->columnSpan(2)
->components([
TextInput::make('name')
->required()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, callable $set) {
if ($operation === 'create') {
$set('slug', Str::slug($state));
}
}),
TextInput::make('slug')
->required()
->unique(McpServer::class, 'slug', ignoreRecord: true)
->helperText('Used in the URL, e.g. /mcp-servers/your-slug'),
Textarea::make('description')
->required()
->rows(4)
->columnSpanFull(),
TextInput::make('url')
->label('Repository / homepage URL')
->url()
->required(),
TextInput::make('docs_url')
->label('Documentation URL')
->url(),
TextInput::make('logo_url')
->label('Logo URL')
->url(),
Textarea::make('install_command')
->label('Install command')
->rows(2)
->helperText('e.g. npx -y @modelcontextprotocol/server-filesystem /path')
->columnSpanFull(),
Textarea::make('config_example')
->label('Example client configuration')
->rows(6)
->helperText('The JSON snippet a user pastes into their MCP client config')
->columnSpanFull(),
TagsInput::make('capabilities')
->placeholder('Add a capability and press enter')
->helperText('e.g. Read files, Write files, List directories')
->columnSpanFull(),
TagsInput::make('tags')
->placeholder('Add a tag and press enter')
->helperText('e.g. official, read-only, requires-api-key')
->columnSpanFull(),
]),
Section::make('Classification')
->columnSpan(1)
->components([
Select::make('category')
->options(config('mcp_servers.categories'))
->required()
->searchable(),
Select::make('transport')
->options(config('mcp_servers.transports')),
TextInput::make('language')
->helperText('e.g. TypeScript, Python'),
]),
Section::make('Moderation')
->columnSpan(3)
->columns(4)
->components([
Toggle::make('approved')
->helperText('Only approved servers are shown publicly.')
->default(false),
Toggle::make('featured')
->helperText('Highlight this server.')
->default(false),
Select::make('user_id')
->label('Submitted by')
->relationship('user', 'name')
->searchable()
->preload(),
TextInput::make('views')
->numeric()
->default(0)
->disabled()
->dehydrated(),
TextInput::make('clicks')
->numeric()
->default(0)
->disabled()
->dehydrated(),
]),
]);
}
}
@@ -0,0 +1,71 @@
<?php
namespace App\Filament\Resources\McpServers\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
class McpServersTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
ImageColumn::make('logo_url')
->label(''),
TextColumn::make('name')
->searchable()
->weight('medium'),
TextColumn::make('category')
->formatStateUsing(fn (string $state) => config("mcp_servers.categories.{$state}", $state))
->badge()
->sortable(),
TextColumn::make('transport')
->placeholder('—'),
TextColumn::make('language')
->placeholder('—'),
TextColumn::make('views')
->numeric()
->sortable(),
TextColumn::make('clicks')
->numeric()
->sortable(),
IconColumn::make('featured')
->boolean()
->sortable(),
IconColumn::make('approved')
->boolean()
->sortable(),
TextColumn::make('user.name')
->label('Submitted by')
->placeholder('—')
->searchable(),
TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('created_at', 'desc')
->filters([
SelectFilter::make('category')
->options(config('mcp_servers.categories')),
TernaryFilter::make('approved'),
TernaryFilter::make('featured'),
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Skills\Pages;
use App\Filament\Resources\Skills\SkillResource;
use Filament\Resources\Pages\CreateRecord;
class CreateSkill extends CreateRecord
{
protected static string $resource = SkillResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Skills\Pages;
use App\Filament\Resources\Skills\SkillResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditSkill extends EditRecord
{
protected static string $resource = SkillResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Skills\Pages;
use App\Filament\Resources\Skills\SkillResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListSkills extends ListRecords
{
protected static string $resource = SkillResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,104 @@
<?php
namespace App\Filament\Resources\Skills\Schemas;
use App\Models\Skill;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class SkillForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(3)
->components([
Section::make('Details')
->columnSpan(2)
->components([
TextInput::make('name')
->required()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, callable $set) {
if ($operation === 'create') {
$set('slug', Str::slug($state));
}
}),
TextInput::make('slug')
->required()
->unique(Skill::class, 'slug', ignoreRecord: true)
->helperText('Used in the URL, e.g. /skills/your-slug'),
Textarea::make('description')
->required()
->rows(4)
->columnSpanFull(),
TextInput::make('url')
->label('Repository / homepage URL')
->url()
->required(),
TextInput::make('docs_url')
->label('Documentation URL')
->url(),
TextInput::make('logo_url')
->label('Logo URL')
->url(),
Textarea::make('install_instructions')
->label('Install instructions')
->rows(2)
->helperText('e.g. Copy into ~/.claude/skills/ and restart Claude')
->columnSpanFull(),
Textarea::make('example_prompt')
->label('Example prompt')
->rows(2)
->helperText('A sample prompt that would trigger or use this skill')
->columnSpanFull(),
TagsInput::make('tags')
->placeholder('Add a tag and press enter')
->helperText('e.g. official, anthropic, community')
->columnSpanFull(),
]),
Section::make('Classification')
->columnSpan(1)
->components([
Select::make('category')
->options(config('skills.categories'))
->required()
->searchable(),
TextInput::make('requirements')
->helperText('e.g. Claude Code, Code Execution tool'),
]),
Section::make('Moderation')
->columnSpan(3)
->columns(4)
->components([
Toggle::make('approved')
->helperText('Only approved skills are shown publicly.')
->default(false),
Toggle::make('featured')
->helperText('Highlight this skill.')
->default(false),
Select::make('user_id')
->label('Submitted by')
->relationship('user', 'name')
->searchable()
->preload(),
TextInput::make('views')
->numeric()
->default(0)
->disabled()
->dehydrated(),
TextInput::make('clicks')
->numeric()
->default(0)
->disabled()
->dehydrated(),
]),
]);
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Filament\Resources\Skills;
use App\Filament\Resources\Skills\Pages\CreateSkill;
use App\Filament\Resources\Skills\Pages\EditSkill;
use App\Filament\Resources\Skills\Pages\ListSkills;
use App\Filament\Resources\Skills\Schemas\SkillForm;
use App\Filament\Resources\Skills\Tables\SkillsTable;
use App\Models\Skill;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
class SkillResource extends Resource
{
protected static ?string $model = Skill::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSparkles;
protected static string|\UnitEnum|null $navigationGroup = 'Tools';
protected static ?string $navigationLabel = 'Skills';
protected static ?string $recordTitleAttribute = 'name';
public static function form(Schema $schema): Schema
{
return SkillForm::configure($schema);
}
public static function table(Table $table): Table
{
return SkillsTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListSkills::route('/'),
'create' => CreateSkill::route('/create'),
'edit' => EditSkill::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,69 @@
<?php
namespace App\Filament\Resources\Skills\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
class SkillsTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
ImageColumn::make('logo_url')
->label(''),
TextColumn::make('name')
->searchable()
->weight('medium'),
TextColumn::make('category')
->formatStateUsing(fn (string $state) => config("skills.categories.{$state}", $state))
->badge()
->sortable(),
TextColumn::make('requirements')
->placeholder('—'),
TextColumn::make('views')
->numeric()
->sortable(),
TextColumn::make('clicks')
->numeric()
->sortable(),
IconColumn::make('featured')
->boolean()
->sortable(),
IconColumn::make('approved')
->boolean()
->sortable(),
TextColumn::make('user.name')
->label('Submitted by')
->placeholder('—')
->searchable(),
TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('created_at', 'desc')
->filters([
SelectFilter::make('category')
->options(config('skills.categories')),
TernaryFilter::make('approved'),
TernaryFilter::make('featured'),
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreMcpServerRequest;
use App\Http\Requests\UpdateMcpServerRequest;
use App\Http\Resources\McpServerResource;
use App\Models\McpServer;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Http\Response;
class McpServerController extends Controller
{
public function index(Request $request): AnonymousResourceCollection
{
$servers = McpServer::query()
->with('user')
->when($request->string('category')->toString(), fn ($query, $category) => $query->where('category', $category))
->when($request->has('approved'), fn ($query) => $query->where('approved', $request->boolean('approved')))
->latest('created_at')
->paginate(20);
return McpServerResource::collection($servers);
}
public function store(StoreMcpServerRequest $request): McpServerResource
{
$server = McpServer::query()->create([
'featured' => false,
'approved' => false,
...$request->validated(),
'user_id' => $request->user()->id,
]);
return new McpServerResource($server->refresh()->load('user'));
}
public function show(McpServer $mcpServer): McpServerResource
{
return new McpServerResource($mcpServer->load('user'));
}
public function update(UpdateMcpServerRequest $request, McpServer $mcpServer): McpServerResource
{
$mcpServer->update($request->validated());
return new McpServerResource($mcpServer->load('user'));
}
public function destroy(McpServer $mcpServer): Response
{
$mcpServer->delete();
return response()->noContent();
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreSkillRequest;
use App\Http\Requests\UpdateSkillRequest;
use App\Http\Resources\SkillResource;
use App\Models\Skill;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Http\Response;
class SkillController extends Controller
{
public function index(Request $request): AnonymousResourceCollection
{
$skills = Skill::query()
->with('user')
->when($request->string('category')->toString(), fn ($query, $category) => $query->where('category', $category))
->when($request->has('approved'), fn ($query) => $query->where('approved', $request->boolean('approved')))
->latest('created_at')
->paginate(20);
return SkillResource::collection($skills);
}
public function store(StoreSkillRequest $request): SkillResource
{
$skill = Skill::query()->create([
'featured' => false,
'approved' => false,
...$request->validated(),
'user_id' => $request->user()->id,
]);
return new SkillResource($skill->refresh()->load('user'));
}
public function show(Skill $skill): SkillResource
{
return new SkillResource($skill->load('user'));
}
public function update(UpdateSkillRequest $request, Skill $skill): SkillResource
{
$skill->update($request->validated());
return new SkillResource($skill->load('user'));
}
public function destroy(Skill $skill): Response
{
$skill->delete();
return response()->noContent();
}
}
@@ -0,0 +1,103 @@
<?php
namespace App\Http\Controllers;
use App\Models\McpServer;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class McpServerController extends Controller
{
public function index(Request $request): View
{
$category = $request->string('category')->toString();
$search = $request->string('q')->toString();
$servers = McpServer::approved()
->when($category, fn ($query) => $query->where('category', $category))
->when($search, fn ($query) => $query->where('name', 'like', "%{$search}%"))
->orderByDesc('featured')
->orderByDesc('views')
->paginate(12)
->withQueryString();
return view('mcp-servers.index', [
'servers' => $servers,
'categories' => config('mcp_servers.categories'),
'activeCategory' => $category,
'search' => $search,
'title' => 'MCP Servers Directory — '.config('app.name'),
'description' => 'Discover Model Context Protocol servers, with docs, install instructions, and config examples.',
'canonical' => route('mcp-servers.index'),
]);
}
public function category(string $category): View
{
abort_unless(array_key_exists($category, config('mcp_servers.categories')), 404);
$servers = McpServer::approved()
->where('category', $category)
->orderByDesc('featured')
->orderByDesc('views')
->paginate(12);
$label = config("mcp_servers.categories.{$category}");
return view('mcp-servers.category', [
'servers' => $servers,
'categories' => config('mcp_servers.categories'),
'category' => $category,
'label' => $label,
'title' => $label.' MCP Servers — '.config('app.name'),
'description' => "MCP servers for {$label}.",
'canonical' => route('mcp-servers.category', $category),
]);
}
public function show(McpServer $mcpServer): View
{
abort_unless($mcpServer->approved, 404);
$mcpServer->increment('views');
$related = McpServer::approved()
->where('category', $mcpServer->category)
->whereKeyNot($mcpServer->id)
->limit(4)
->get();
return view('mcp-servers.show', [
'server' => $mcpServer,
'related' => $related,
'title' => $mcpServer->name.' — MCP Servers — '.config('app.name'),
'description' => $this->metaDescription($mcpServer->description),
'canonical' => route('mcp-servers.show', $mcpServer),
'image' => $mcpServer->logo_url,
]);
}
public function visit(McpServer $mcpServer): RedirectResponse
{
abort_unless($mcpServer->approved, 404);
$mcpServer->increment('clicks');
return redirect()->away($mcpServer->url);
}
/**
* Truncate to ~155 chars without cutting a word in half. Google appends
* its own ellipsis when it truncates in search results, so we don't add one.
*/
private function metaDescription(string $description, int $limit = 155): string
{
if (Str::length($description) <= $limit) {
return $description;
}
return Str::of($description)->limit($limit, '')->beforeLast(' ')->toString();
}
}
@@ -3,8 +3,10 @@
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\McpServer;
use App\Models\Page;
use App\Models\Post;
use App\Models\Skill;
use App\Models\Tag;
use App\Models\Tool;
use Illuminate\Http\Response;
@@ -18,6 +20,10 @@ class SitemapController extends Controller
$tags = Tag::all(['slug', 'updated_at']);
$tools = Tool::approved()->get(['slug', 'updated_at']);
$toolCategories = array_keys(config('tools.categories'));
$mcpServers = McpServer::approved()->get(['slug', 'updated_at']);
$mcpServerCategories = array_keys(config('mcp_servers.categories'));
$skills = Skill::approved()->get(['slug', 'updated_at']);
$skillCategories = array_keys(config('skills.categories'));
$pages = Page::published()->get(['slug', 'updated_at']);
$xml = view('sitemap', [
@@ -26,6 +32,10 @@ class SitemapController extends Controller
'tags' => $tags,
'tools' => $tools,
'toolCategories' => $toolCategories,
'mcpServers' => $mcpServers,
'mcpServerCategories' => $mcpServerCategories,
'skills' => $skills,
'skillCategories' => $skillCategories,
'pages' => $pages,
])->render();
+103
View File
@@ -0,0 +1,103 @@
<?php
namespace App\Http\Controllers;
use App\Models\Skill;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class SkillController extends Controller
{
public function index(Request $request): View
{
$category = $request->string('category')->toString();
$search = $request->string('q')->toString();
$skills = Skill::approved()
->when($category, fn ($query) => $query->where('category', $category))
->when($search, fn ($query) => $query->where('name', 'like', "%{$search}%"))
->orderByDesc('featured')
->orderByDesc('views')
->paginate(12)
->withQueryString();
return view('skills.index', [
'skills' => $skills,
'categories' => config('skills.categories'),
'activeCategory' => $category,
'search' => $search,
'title' => 'Claude Skills Directory — '.config('app.name'),
'description' => 'Discover Claude Skills, with docs, install instructions, and example prompts.',
'canonical' => route('skills.index'),
]);
}
public function category(string $category): View
{
abort_unless(array_key_exists($category, config('skills.categories')), 404);
$skills = Skill::approved()
->where('category', $category)
->orderByDesc('featured')
->orderByDesc('views')
->paginate(12);
$label = config("skills.categories.{$category}");
return view('skills.category', [
'skills' => $skills,
'categories' => config('skills.categories'),
'category' => $category,
'label' => $label,
'title' => $label.' Claude Skills — '.config('app.name'),
'description' => "Claude Skills for {$label}.",
'canonical' => route('skills.category', $category),
]);
}
public function show(Skill $skill): View
{
abort_unless($skill->approved, 404);
$skill->increment('views');
$related = Skill::approved()
->where('category', $skill->category)
->whereKeyNot($skill->id)
->limit(4)
->get();
return view('skills.show', [
'skill' => $skill,
'related' => $related,
'title' => $skill->name.' — Claude Skills — '.config('app.name'),
'description' => $this->metaDescription($skill->description),
'canonical' => route('skills.show', $skill),
'image' => $skill->logo_url,
]);
}
public function visit(Skill $skill): RedirectResponse
{
abort_unless($skill->approved, 404);
$skill->increment('clicks');
return redirect()->away($skill->url);
}
/**
* Truncate to ~155 chars without cutting a word in half. Google appends
* its own ellipsis when it truncates in search results, so we don't add one.
*/
private function metaDescription(string $description, int $limit = 155): string
{
if (Str::length($description) <= $limit) {
return $description;
}
return Str::of($description)->limit($limit, '')->beforeLast(' ')->toString();
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreMcpServerRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'slug' => ['nullable', 'string', 'max:255', Rule::unique('mcp_servers', 'slug')],
'description' => ['required', 'string'],
'url' => ['required', 'url', 'max:255'],
'docs_url' => ['nullable', 'url', 'max:255'],
'logo_url' => ['nullable', 'url', 'max:255'],
'category' => ['required', Rule::in(array_keys(config('mcp_servers.categories')))],
'install_command' => ['nullable', 'string'],
'config_example' => ['nullable', 'string'],
'transport' => ['nullable', Rule::in(array_keys(config('mcp_servers.transports')))],
'language' => ['nullable', 'string', 'max:100'],
'capabilities' => ['sometimes', 'array'],
'capabilities.*' => ['string', 'max:255'],
'tags' => ['sometimes', 'array'],
'tags.*' => ['string', 'max:50'],
'featured' => ['sometimes', 'boolean'],
'approved' => ['sometimes', 'boolean'],
];
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreSkillRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'slug' => ['nullable', 'string', 'max:255', Rule::unique('skills', 'slug')],
'description' => ['required', 'string'],
'url' => ['required', 'url', 'max:255'],
'docs_url' => ['nullable', 'url', 'max:255'],
'logo_url' => ['nullable', 'url', 'max:255'],
'category' => ['required', Rule::in(array_keys(config('skills.categories')))],
'install_instructions' => ['nullable', 'string'],
'example_prompt' => ['nullable', 'string'],
'requirements' => ['nullable', 'string', 'max:255'],
'tags' => ['sometimes', 'array'],
'tags.*' => ['string', 'max:50'],
'featured' => ['sometimes', 'boolean'],
'approved' => ['sometimes', 'boolean'],
];
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateMcpServerRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'name' => ['sometimes', 'required', 'string', 'max:255'],
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('mcp_servers', 'slug')->ignore($this->route('mcp_server'))],
'description' => ['sometimes', 'required', 'string'],
'url' => ['sometimes', 'required', 'url', 'max:255'],
'docs_url' => ['nullable', 'url', 'max:255'],
'logo_url' => ['nullable', 'url', 'max:255'],
'category' => ['sometimes', 'required', Rule::in(array_keys(config('mcp_servers.categories')))],
'install_command' => ['nullable', 'string'],
'config_example' => ['nullable', 'string'],
'transport' => ['nullable', Rule::in(array_keys(config('mcp_servers.transports')))],
'language' => ['nullable', 'string', 'max:100'],
'capabilities' => ['sometimes', 'array'],
'capabilities.*' => ['string', 'max:255'],
'tags' => ['sometimes', 'array'],
'tags.*' => ['string', 'max:50'],
'featured' => ['sometimes', 'boolean'],
'approved' => ['sometimes', 'boolean'],
];
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateSkillRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'name' => ['sometimes', 'required', 'string', 'max:255'],
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('skills', 'slug')->ignore($this->route('skill'))],
'description' => ['sometimes', 'required', 'string'],
'url' => ['sometimes', 'required', 'url', 'max:255'],
'docs_url' => ['nullable', 'url', 'max:255'],
'logo_url' => ['nullable', 'url', 'max:255'],
'category' => ['sometimes', 'required', Rule::in(array_keys(config('skills.categories')))],
'install_instructions' => ['nullable', 'string'],
'example_prompt' => ['nullable', 'string'],
'requirements' => ['nullable', 'string', 'max:255'],
'tags' => ['sometimes', 'array'],
'tags.*' => ['string', 'max:50'],
'featured' => ['sometimes', 'boolean'],
'approved' => ['sometimes', 'boolean'],
];
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class McpServerResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
'url' => $this->url,
'docs_url' => $this->docs_url,
'logo_url' => $this->logo_url,
'category' => $this->category,
'category_label' => $this->category_label,
'install_command' => $this->install_command,
'config_example' => $this->config_example,
'transport' => $this->transport,
'transport_label' => $this->transport_label,
'language' => $this->language,
'capabilities' => $this->capabilities,
'tags' => $this->tags,
'views' => $this->views,
'clicks' => $this->clicks,
'featured' => $this->featured,
'approved' => $this->approved,
'submitted_by' => new UserResource($this->whenLoaded('user')),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class SkillResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
'url' => $this->url,
'docs_url' => $this->docs_url,
'logo_url' => $this->logo_url,
'category' => $this->category,
'category_label' => $this->category_label,
'install_instructions' => $this->install_instructions,
'example_prompt' => $this->example_prompt,
'requirements' => $this->requirements,
'tags' => $this->tags,
'views' => $this->views,
'clicks' => $this->clicks,
'featured' => $this->featured,
'approved' => $this->approved,
'submitted_by' => new UserResource($this->whenLoaded('user')),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace App\Models;
use Database\Factories\McpServerFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\RouteKey;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
#[Fillable([
'name', 'slug', 'description', 'url', 'docs_url', 'logo_url', 'category',
'install_command', 'config_example', 'transport', 'language', 'capabilities',
'tags', 'featured', 'approved', 'user_id',
])]
#[RouteKey('slug')]
class McpServer extends Model
{
/** @use HasFactory<McpServerFactory> */
use HasFactory;
protected function casts(): array
{
return [
'capabilities' => 'array',
'tags' => 'array',
'featured' => 'boolean',
'approved' => 'boolean',
];
}
protected static function booted(): void
{
static::creating(function (McpServer $server) {
if (empty($server->slug)) {
$server->slug = Str::slug($server->name);
}
});
}
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @param Builder<McpServer> $query
*/
#[Scope]
protected function approved(Builder $query): void
{
$query->where('approved', true);
}
protected function categoryLabel(): Attribute
{
return Attribute::get(fn () => config("mcp_servers.categories.{$this->category}", $this->category));
}
protected function transportLabel(): Attribute
{
return Attribute::get(fn () => $this->transport ? config("mcp_servers.transports.{$this->transport}", $this->transport) : null);
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Database\Factories\SkillFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\RouteKey;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
#[Fillable([
'name', 'slug', 'description', 'url', 'docs_url', 'logo_url', 'category',
'install_instructions', 'example_prompt', 'requirements', 'tags',
'featured', 'approved', 'user_id',
])]
#[RouteKey('slug')]
class Skill extends Model
{
/** @use HasFactory<SkillFactory> */
use HasFactory;
protected function casts(): array
{
return [
'tags' => 'array',
'featured' => 'boolean',
'approved' => 'boolean',
];
}
protected static function booted(): void
{
static::creating(function (Skill $skill) {
if (empty($skill->slug)) {
$skill->slug = Str::slug($skill->name);
}
});
}
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @param Builder<Skill> $query
*/
#[Scope]
protected function approved(Builder $query): void
{
$query->where('approved', true);
}
protected function categoryLabel(): Attribute
{
return Attribute::get(fn () => config("skills.categories.{$this->category}", $this->category));
}
}