openapi-2-mcpserver

gauravgarg/openapi-2-mcpserver

3.1

If you are the rightful owner of openapi-2-mcpserver and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This project sets up an MCP server using FastMCP to serve an OpenAPI specification.

openapi-2-mcpserver

This project downloads an OpenAPI specification (Petstore example), saves it locally, and starts an MCP server using FastMCP.

Setup

  1. (Optional) Create and activate a Python virtual environment:

    python3 -m venv venv
    source venv/bin/activate
    
  2. Install dependencies (using uv):

    uv pip install -r requirements.txt
    

Running on a VM (with uv installed)

  1. Upload your project files to the VM.
  2. Open a terminal and navigate to your project directory.
  3. Install dependencies:
    uv pip install -r requirements.txt
    
  4. Run the server:
    python main.py
    
    • The server will start on 0.0.0.0:8000.

How it works

  • Downloads the Petstore OpenAPI spec from https://petstore3.swagger.io/api/v3/openapi.json.
  • Saves it as petstore_openapi.json.
  • Creates an MCP server using FastMCP and serves it with Uvicorn.

Project Structure

  • main.py — Entry point
  • requirements.txt — Python dependencies