PHP
Get an OpenAPI spec from Symfony
Install NelmioApiDocBundle and run nelmio:apidoc:dump. API Platform projects already have a spec.
How it works
Symfony has no built-in spec. NelmioApiDocBundle builds one from your app: it reads your routes, Symfony attributes such as #[MapRequestPayload] and #[MapQueryString], your entity and DTO classes with their validator constraints, and any #[OA\...] attributes you add for the parts it cannot work out on its own.
By default it documents only routes under /api. The same bundle serves Swagger UI at /api/doc, so one install gives you browsable Swagger docs for your team and a file for MCPEasy.
If your project uses API Platform, skip the bundle: API Platform writes the OpenAPI document itself. See the second route below.
Step by step
Step 1: Install NelmioApiDocBundle
In your Symfony project folder. With Symfony Flex (the default) this also registers the bundle and creates config/packages/nelmio_api_doc.yaml.
Terminalcomposer require nelmio/api-doc-bundleStep 2: Set the title and which routes to document
Open config/packages/nelmio_api_doc.yaml. Put your API's name under documentation.info, and keep path_patterns matching your API prefix. The pattern below documents everything under /api except the docs page itself, which keeps routes like /_profiler out.
config/packages/nelmio_api_doc.yamlnelmio_api_doc: documentation: info: title: Bookings API description: Create and manage bookings version: 1.0.0 areas: path_patterns: - ^/api(?!/doc$)If your API is not under /api, change the pattern, for example ^/v1, or ^/ for every route.
Step 3: Export the file
This prints the whole spec. Save it to a file and upload that file to MCPEasy.
Terminalphp bin/console nelmio:apidoc:dump --format=json > openapi.jsonTerminal (YAML instead)php bin/console nelmio:apidoc:dump --format=yaml > openapi.yamlStep 4: Optional: Swagger UI and a live link
To browse the docs at /api/doc and serve the spec at /api/doc.json, check config/routes/nelmio_api_doc.yaml. If these two routes are missing or commented out, add them. Swagger UI also needs the Twig and Asset packages.
Terminalcomposer require twig assetconfig/routes/nelmio_api_doc.yamlapp.swagger_ui: path: /api/doc methods: GET defaults: { _controller: nelmio_api_doc.controller.swagger_ui } app.swagger: path: /api/doc.json methods: GET defaults: { _controller: nelmio_api_doc.controller.swagger }With /api/doc.json live, you can paste https://your-site.com/api/doc.json into MCPEasy instead of uploading a file, and the spec stays current as you add routes.
Step 5: Fill the gaps with attributes
Where a response or parameter comes out thin, describe it on the controller method. Model points the response at your DTO or entity class, so its fields and types appear in the spec.
src/Controller/BookingController.phpuse App\Dto\BookingDto; use Nelmio\ApiDocBundle\Attribute\Model; use OpenApi\Attributes as OA; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; #[Route('/api/bookings', methods: ['GET'])] #[OA\Response( response: 200, description: 'Bookings on the given date', content: new OA\JsonContent(type: 'array', items: new OA\Items(ref: new Model(type: BookingDto::class))) )] #[OA\Parameter(name: 'date', in: 'query', description: 'Day to list, YYYY-MM-DD', schema: new OA\Schema(type: 'string'))] #[OA\Tag(name: 'bookings')] public function list(): JsonResponseThe descriptions become each tool's description in MCPEasy, which is what the AI reads to decide when to call it. One plain sentence per endpoint is enough.
Check that it worked
- Open openapi.json. Each route under /api should be listed under "paths" with its method, and your DTO or entity classes should appear under "components" > "schemas".
- If you added the routes in step 4, /api/doc shows the same endpoints in Swagger UI.
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.
Using API Platform?
API Platform generates the OpenAPI document from your resources, so there is nothing to install.
Step 1: Export it as OpenAPI 3.0
Recent API Platform versions write OpenAPI 3.2 by default. MCPEasy reads OpenAPI 3.0 and 3.1, so ask for 3.0. The same document is served live at /api/docs.jsonopenapi; add ?spec_version=3.0.0 to that link.
Terminalphp bin/console api:openapi:export --spec-version=3.0.0 --output=openapi.jsonFor YAML add --yaml (it needs symfony/yaml installed).
If something goes wrong
- "paths" is empty, or only shows /api/doc.
- Your routes do not match path_patterns. Change the pattern to your prefix (step 2) and run the dump again.
- Routes like /_profiler or /_error appear.
- path_patterns is too wide. Keep it to your API prefix, such as ^/api(?!/doc$).
- There are no commands defined in the "nelmio:apidoc" namespace.
- The bundle is not registered. Without Flex, add Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true] to config/bundles.php.
- /api/doc fails with an error about Twig or assets.
- Swagger UI needs both packages: composer require twig asset.
- A response shows no fields.
- The bundle cannot see what you return from a plain JsonResponse. Add an #[OA\Response] with a Model of your DTO (step 5).
- MCPEasy says the API Platform file is not a supported format.
- It was written as OpenAPI 3.2. Export again with --spec-version=3.0.0.
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
More guides for MCP and OpenAPI
- OpenAPI to MCP serverHow a spec maps to MCP tools, which endpoints to keep, and how auth works.
- REST API to MCP serverConvert any API, with or without a spec: Postman, cURL, code, plus a worked example.
- MCP vs APIThe difference in plain terms, one request followed through both, and when to use which.
- OpenAPI MCP generators comparedSix tools checked against their own docs: inputs, transports, big APIs, hosting and price.
- MCP tool limits by clientTool limits in VS Code, Cursor, Windsurf and Claude, and how many tools 8 real APIs become.
- Get an OpenAPI spec from your frameworkExport an OpenAPI (Swagger) file from 12 frameworks, step by step.
- OpenAPI spec from FastAPINothing to install: FastAPI already serves your spec at /openapi.json.
- OpenAPI spec from ExpressThe packages, code and commands to produce a spec from an Express app.