mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-11 14:50:30 +00:00
d0544bfac9
- 🔒 Added migrations for `oauth_access_tokens`, `oauth_refresh_tokens`, `oauth_auth_codes`, `oauth_clients`, and `oauth_device_codes`. - 🤖 Created MCP tools (Meetups, Cities, Venues, Courses, Lecturers) for managing entities with authentication and validation. - 🛠️ Implemented Passport-backed OAuth API guard configuration and validation endpoints. - ✅ Added comprehensive feature tests for MCP tools and OAuth functionality (access control, validation, and token-based authentication).
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Mcp\Tools\Search;
|
|
|
|
use App\Models\Venue;
|
|
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\JsonSchema\Types\Type;
|
|
use Laravel\Mcp\Request;
|
|
use Laravel\Mcp\Response;
|
|
use Laravel\Mcp\Server\Attributes\Description;
|
|
use Laravel\Mcp\Server\Tool;
|
|
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
|
|
|
|
#[IsReadOnly]
|
|
#[Description('Sucht Veranstaltungsorte (öffentlich) und liefert id, name sowie die zugehörige Stadt/Land, alphabetisch sortiert, begrenzt auf 10 Einträge. Jeder Ort enthält zusätzlich flag (SVG-URL der Landesflagge) und description (Stadt + Straße). Dient zum Auflösen von venue_id.')]
|
|
class SearchVenuesTool extends Tool
|
|
{
|
|
public function handle(Request $request): Response
|
|
{
|
|
$search = $request->get('search');
|
|
|
|
$venues = Venue::query()
|
|
->with(['city:id,name,country_id', 'city.country:id,name,code'])
|
|
->select('id', 'name', 'city_id')
|
|
->orderBy('name')
|
|
->when(
|
|
$search,
|
|
fn (Builder $query) => $query
|
|
->where('name', 'ilike', "%{$search}%")
|
|
)
|
|
->limit(10)
|
|
->get()
|
|
->map(function (Venue $venue) {
|
|
$venue->flag = asset('vendor/blade-country-flags/4x3-'.$venue->city->country->code.'.svg');
|
|
$venue->description = $venue->city->name.', '.$venue->street;
|
|
|
|
return $venue;
|
|
});
|
|
|
|
return Response::json($venues->values());
|
|
}
|
|
|
|
/**
|
|
* @return array<string, Type>
|
|
*/
|
|
public function schema(JsonSchema $schema): array
|
|
{
|
|
return [
|
|
'search' => $schema->string()->description('Teilstring-Suche im Namen des Veranstaltungsortes.'),
|
|
];
|
|
}
|
|
}
|