Python
Get an OpenAPI spec from FastAPI
Nothing to install. Your spec is already live at /openapi.json.
How it works
FastAPI builds the spec from your route functions, their type hints and your Pydantic models. It is complete and accurate, including field types and required fields.
Step by step
Step 1: Open your spec
Add /openapi.json to your API's address, for example https://api.example.com/openapi.json. If you see JSON with "paths", you are done: paste that link into MCPEasy under OpenAPI URL.
Locally, start the app and open http://localhost:8000/openapi.json. A browsable version is at /docs.
Terminaluvicorn main:app --reloadChange main:app to your file and variable name, for example app.main:app.
Step 2: Optional: save it as a file
If the API is not reachable from the internet, save the file and upload it. Run this in the project folder, with the same import you use to start the app:
Terminalpython -c "import json; from main import app; open('openapi.json', 'w').write(json.dumps(app.openapi(), indent=2))"If your app lives in app/main.py, write from app.main import app instead.
Step 3: Optional: better tool descriptions
The summary and docstring become the tool's description. Response models and auth dependencies are picked up too.
main.pyfrom fastapi import Depends, FastAPI from fastapi.security import HTTPBearer from pydantic import BaseModel app = FastAPI(title="My API", version="1.0.0") bearer = HTTPBearer() class BookingIn(BaseModel): service_id: str start_time: str @app.post("/bookings", summary="Create a booking", status_code=201) def create_booking(body: BookingIn, token=Depends(bearer)): """Books an appointment in a free slot.""" ...
Check that it worked
- https://your-api.com/openapi.json shows JSON with every route under "paths".
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.
If something goes wrong
- /openapi.json returns 404.
- Look for FastAPI(openapi_url=None) (turned off) or a custom openapi_url such as "/api/openapi.json". Use that path, or save the file with step 2.
- The API runs under a prefix behind a proxy, and the link does not work.
- Try your prefix plus /openapi.json, for example https://example.com/api/openapi.json, or save the file with step 2.
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.
- Get an OpenAPI spec from your frameworkExport an OpenAPI (Swagger) file from 11 frameworks, step by step.
- OpenAPI spec from ExpressThe packages, code and commands to produce a spec from an Express app.