mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-11 02:50:29 +00:00
✨ Add OAuth functionality, MCP tools, and feature tests
- 🔒 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).
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\Search;
|
||||
|
||||
use App\Models\Course;
|
||||
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 Kurse (öffentlich) und liefert id und name, alphabetisch sortiert, begrenzt auf 10 Einträge. Jeder Kurs enthält zusätzlich ein image (Logo-Thumbnail-URL). Optional nach Ersteller (user_id) filterbar. Dient zum Auflösen von course_id.')]
|
||||
class SearchCoursesTool extends Tool
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$search = $request->get('search');
|
||||
$userId = $request->get('user_id');
|
||||
|
||||
$courses = Course::query()
|
||||
->select('id', 'name')
|
||||
->orderBy('name')
|
||||
->when($userId !== null,
|
||||
fn (Builder $query) => $query->where('created_by', (int) $userId))
|
||||
->when(
|
||||
$search,
|
||||
fn (Builder $query) => $query
|
||||
->where('name', 'ilike', "%{$search}%")
|
||||
)
|
||||
->limit(10)
|
||||
->get()
|
||||
->map(function (Course $course) {
|
||||
$course->image = $course->getFirstMediaUrl('logo',
|
||||
'thumb');
|
||||
|
||||
return $course;
|
||||
});
|
||||
|
||||
return Response::json($courses->values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Type>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'search' => $schema->string()->description('Teilstring-Suche im Namen des Kurses.'),
|
||||
'user_id' => $schema->integer()->description('Filtert die Kurse nach ihrem Ersteller.'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user