mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-11 02:50:29 +00:00
✨ Add ResolvesEntities concern for name-based ID resolution
- 🤖 Introduced `ResolvesEntities` trait to simplify entity resolution by name or ID across MCP tools. - 📚 Updated tools (Meetups, Cities, Venues, Courses, Lecturers) to use the concern for resolving related entities (e.g., courses, venues, lecturers). - 🎯 Enhanced tool descriptions and schemas for better name-based parameter handling with fallback support for IDs. - ✅ Added dedicated feature tests for name resolution logic, partial matches, and error handling scenarios.
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Mcp\Tools\Meetup;
|
||||
|
||||
use App\Http\Requests\Api\StoreMeetupRequest;
|
||||
use App\Http\Resources\MeetupResource;
|
||||
use App\Mcp\Tools\Concerns\ResolvesEntities;
|
||||
use App\Models\City;
|
||||
use App\Models\Meetup;
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Illuminate\JsonSchema\Types\Type;
|
||||
@@ -13,9 +15,11 @@ use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Legt ein neues Meetup für den authentifizierten Nutzer an. Der Ersteller (created_by) wird automatisch gesetzt.')]
|
||||
#[Description('Legt ein neues Meetup für den authentifizierten Nutzer an. Die Stadt wird über ihren Namen angegeben; der Ersteller (created_by) wird automatisch gesetzt.')]
|
||||
class CreateMeetupTool extends Tool
|
||||
{
|
||||
use ResolvesEntities;
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
@@ -24,6 +28,10 @@ class CreateMeetupTool extends Tool
|
||||
return Response::error('Nicht berechtigt, ein Meetup anzulegen.');
|
||||
}
|
||||
|
||||
if ($error = $this->mergeForeignKey($request, 'city', 'city_id', City::query(), 'Stadt')) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
$storeRequest = new StoreMeetupRequest;
|
||||
|
||||
$validated = $request->validate(
|
||||
@@ -43,7 +51,8 @@ class CreateMeetupTool extends Tool
|
||||
{
|
||||
return [
|
||||
'name' => $schema->string()->description('Name des Meetups.')->required(),
|
||||
'city_id' => $schema->integer()->description('ID der zugehörigen Stadt (vorher per search-cities auflösen).')->required(),
|
||||
'city' => $schema->string()->description('Name der zugehörigen Stadt (z. B. "Ansbach"). Wird automatisch aufgelöst – bei Bedarf per search-cities den genauen Namen ermitteln.'),
|
||||
'city_id' => $schema->integer()->description('Optional: ID der Stadt, falls bereits bekannt (Alternative zu "city").'),
|
||||
'intro' => $schema->string()->description('Einleitungstext.'),
|
||||
'telegram_link' => $schema->string()->description('Telegram-Gruppen-URL.'),
|
||||
'webpage' => $schema->string()->description('Webseiten-URL.'),
|
||||
|
||||
Reference in New Issue
Block a user