PHP code example of yoanbernabeu / webmcp-bundle

1. Go to this page and download the library: Download yoanbernabeu/webmcp-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yoanbernabeu / webmcp-bundle example snippets


#[Route('/api/restaurants', name: 'api_restaurants', methods: ['GET'])]
#[AsWebMcpTool(
    name: 'search_restaurants',
    description: 'Search restaurants by cuisine type',
    inputs: [
        new WebMcpInput('cuisine', type: 'string', description: 'Cuisine type'),
    ]
)]
public function search(): JsonResponse { /* ... */ }

use Symfony\Component\Routing\Attribute\Route;
use YoanBernabeu\WebMcpBundle\Attribute\AsWebMcpTool;

#[Route('/api/menu', name: 'api_menu', methods: ['GET'])]
#[AsWebMcpTool(
    name: 'get_menu',
    description: 'Get the full restaurant menu',
)]
public function menu(): JsonResponse
{
    return $this->json($this->menuRepository->findAll());
}

use YoanBernabeu\WebMcpBundle\Attribute\WebMcpInput;

#[Route('/api/restaurants', name: 'api_restaurants', methods: ['GET'])]
#[AsWebMcpTool(
    name: 'search_restaurants',
    description: 'Search restaurants, optionally filter by cuisine type',
    inputs: [
        new WebMcpInput('cuisine', type: 'string', description: 'Cuisine type filter'),
        new WebMcpInput('limit', type: 'number', description: 'Max results'),
    ]
)]
public function search(Request $request): JsonResponse
{
    $cuisine = $request->query->get('cuisine');
    // ...
}

#[Route('/api/restaurants/{id}/menu', name: 'api_restaurant_menu', methods: ['GET'])]
#[AsWebMcpTool(
    name: 'get_restaurant_menu',
    description: 'Get menu for a specific restaurant',
    inputs: [
        new WebMcpInput('restaurant_id', type: 'number', description: 'Restaurant ID', 

#[Route('/api/orders', name: 'api_create_order', methods: ['POST'])]
#[AsWebMcpTool(
    name: 'place_order',
    description: 'Place a new order',
    inputs: [
        new WebMcpInput('restaurant_id', type: 'number', description: 'Restaurant ID', onse
{
    $data = json_decode($request->getContent(), true);
    // ...
}