All framework guides

PHP

Get an OpenAPI spec from Laravel

Install Scramble and run php artisan scramble:export. No annotations needed.

Tool
Scramble
Time
About 5 minutes
You get
api.json (OpenAPI 3.1)

How it works

Scramble reads your API routes, controllers, validation rules ($request->validate and Form Requests) and API resources, and builds the spec without any comments or annotations.

By default it documents routes whose address starts with api/, which is everything in routes/api.php.

Step by step

  1. Step 1: Install Scramble

    In your Laravel project folder:

    Terminal
    composer require dedoc/scramble
  2. Step 2: Export the file

    This writes api.json in the project root. Upload that file to MCPEasy.

    Terminal
    php artisan scramble:export
    Terminal (choose the path)
    php artisan scramble:export --path=public/openapi.json

    Exporting to public/ makes it reachable at https://your-site.com/openapi.json, so you can paste the link into MCPEasy instead.

  3. Step 3: Optional: the live link

    While the app runs, the spec is also at /docs/api.json and a browsable page at /docs/api. By default these only open in the local environment.

    To allow them on your live site, define the viewApiDocs gate in app/Providers/AppServiceProvider.php:

    app/Providers/AppServiceProvider.php
    use Illuminate\Support\Facades\Gate;
    
    public function boot(): void
    {
        Gate::define('viewApiDocs', function ($user = null) {
            return true; // anyone can read the API description
        });
    }
  4. Step 4: If your API is not under /api

    Publish Scramble's config and change api_path to your prefix (or an empty string for all routes).

    Terminal
    php artisan vendor:publish --provider="Dedoc\Scramble\ScrambleServiceProvider" --tag="scramble-config"
    config/scramble.php
    'api_path' => 'api',

Check that it worked

  • Open api.json. Your routes from routes/api.php should be under "paths", with fields from your validation rules.

Give it to MCPEasy

Have a link? Paste it (best)

In MCPEasy, create a server, choose OpenAPI URL and paste the link, for example https://api.example.com/openapi.json. Later changes to your API can be picked up with a sync.

Have a file? Upload it

Choose Upload file and drop in the .json or .yaml file (up to 5 MB). MCPEasy turns each endpoint into a tool, and you review them all before anything goes live.

Already using Scribe?

Scribe also writes an OpenAPI file. It reads the same things plus your docblock comments.

  1. Step 1: Install, publish the config, generate

    At the end, the generate command prints where it wrote openapi.yaml. Upload that file.

    Terminal
    composer require --dev knuckleswtf/scribe
    php artisan vendor:publish --tag=scribe-config
    php artisan scribe:generate

If something goes wrong

"paths" is empty.
Your routes do not start with api/. Change api_path (step 4).
/docs/api.json returns 403 on the live site.
Define the viewApiDocs gate (step 3), or use the exported file instead.
Export runs out of memory on a large app.
Run php -d memory_limit=-1 artisan scramble:export.

Still stuck, or no time to set this up? In MCPEasy choose From code (GitHub): it reads your routes straight from the repository, read-only, and tests every tool against your live API before it goes live.

Official documentation

Other frameworks