tutorials2026-01-126 min read

From OpenAPI to ChatGPT App in 5 Minutes

Turn any API with an OpenAPI spec into a ChatGPT-compatible MCP server. No OAuth expertise required. Here's exactly how to do it.

E

Emcy Team

Engineering

Terminal showing OpenAPI to MCP generation with ChatGPT connection

You have an API. You want ChatGPT to use it. The traditional path involves understanding MCP protocols, implementing OAuth flows, building server infrastructure, and debugging authentication errors.

Or you could just generate everything in 5 minutes.

What We're Building

By the end of this tutorial, you'll have:

  • A working MCP server generated from your OpenAPI spec
  • Proper authentication configured (API key, Bearer token, or OAuth)
  • A ChatGPT app that can call your API's endpoints as tools

Let's go.

Prerequisites

  • Node.js 18+ installed
  • An OpenAPI 3.x spec (URL or local file)
  • 5 minutes

Step 1: Generate the MCP Server (30 seconds)

If your API has a public OpenAPI spec URL:

npx @emcy/openapi-to-mcp generate --url https://api.example.com/openapi.json

Or from a local file:

npx @emcy/openapi-to-mcp generate --file ./openapi.yaml

This creates a complete TypeScript project in ./my-api-mcp-server/.

Step 2: Configure Authentication (1 minute)

The generator detects security schemes from your OpenAPI spec. Configure credentials in the .env file:

For API key or static bearer-style token

Use a header secret (see your generated server’s security scheme env vars). For Authorization: Bearer <token>, configure API key mode with header Authorization and prefix Bearer, or set the env vars your generator emits for bearer schemes (for example BEARER_TOKEN_*).

# .env (example — names depend on your OpenAPI security scheme)
UPSTREAM_API_KEY=your-actual-api-key

For OAuth (User Authentication)

If you want ChatGPT users to authenticate:

# .env
OAUTH_AUTHORIZATION_SERVER=https://auth.example.com
MCP_RESOURCE_URL=https://your-deployed-server.com

Step 3: Build and Test Locally (1 minute)

cd my-api-mcp-server
npm install
npm run build
npm start

You should see:

MCP Server started on http://localhost:3000
Available tools: get_users, create_user, get_orders...

Test with a quick curl:

curl http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

Step 4: Deploy to Emcy (2 minutes)

Option A: Emcy Hosting (Recommended)

The fastest way to get your MCP server live:

  1. Go to emcy.dev/deploy
  2. Upload your generated project or connect your GitHub repo
  3. Configure environment variables in the dashboard
  4. Click Deploy

Emcy gives you a production URL like https://my-api.mcp.emcy.dev with:

  • Automatic HTTPS and SSL certificates
  • Built-in telemetry and monitoring
  • One-click environment variable management
  • Zero-downtime deployments

Option B: Self-Hosted

If you prefer to manage your own infrastructure, the generated project includes a Dockerfile:

docker build -t my-mcp-server .
docker run -p 3000:3000 --env-file .env my-mcp-server

Deploy this container to any cloud provider or your own servers.

Step 5: Connect to ChatGPT (30 seconds)

  1. Go to ChatGPT
  2. Open SettingsConnected AppsAdd App
  3. Enter your Emcy server URL: https://my-api.mcp.emcy.dev
  4. ChatGPT discovers your tools automatically

If you configured OAuth, you'll be prompted to authenticate.

That's it. ChatGPT can now use your API.

What Just Happened?

The generator did a lot of work for you:

  1. Parsed your OpenAPI spec - extracted endpoints, parameters, schemas
  2. Generated tool definitions - each endpoint becomes an MCP tool
  3. Built authentication - proper headers, token validation, metadata endpoints
  4. Created transports - HTTP for ChatGPT, Stdio for Claude Desktop
  5. Set up infrastructure - Dockerfile, environment config, build scripts

Example: Pet Store API

Let's walk through a real example with the classic Petstore API:

npx @emcy/openapi-to-mcp generate \
  --url https://petstore3.swagger.io/api/v3/openapi.json \
  --name petstore

Generated tools include:

ToolDescriptionOpenAPI Endpoint
get_pet_by_idFind pet by IDGET /pet/{petId}
add_petAdd a new petPOST /pet
update_petUpdate existing petPUT /pet
find_pets_by_statusFind by statusGET /pet/findByStatus
delete_petDelete a petDELETE /pet/{petId}

Each tool has typed parameters matching the OpenAPI schema:

// Generated tool definition
{
  name: "add_pet",
  description: "Add a new pet to the store",
  inputSchema: {
    type: "object",
    properties: {
      name: { type: "string", description: "Pet name" },
      status: {
        type: "string",
        enum: ["available", "pending", "sold"],
        description: "Pet status in the store"
      },
      photoUrls: {
        type: "array",
        items: { type: "string" }
      }
    },
    required: ["name", "photoUrls"]
  }
}

Customizing the Output

Exclude Endpoints

Don't want certain endpoints exposed as tools?

npx @emcy/openapi-to-mcp generate \
  --url https://api.example.com/openapi.json \
  --exclude "deleteUser,adminEndpoint"

Custom Server Name

npx @emcy/openapi-to-mcp generate \
  --url https://api.example.com/openapi.json \
  --name "my-awesome-api"

Add Emcy Telemetry

Track tool usage in the Emcy dashboard:

npx @emcy/openapi-to-mcp generate \
  --url https://api.example.com/openapi.json \
  --emcy

Then set your API key:

EMCY_API_KEY=your-emcy-api-key

Using the Web Wizard

Prefer a visual interface? Use the Emcy wizard at emcy.dev/wizard:

  1. Paste your OpenAPI URL
  2. Toggle which endpoints to expose
  3. Configure authentication
  4. Deploy directly to Emcy Hosting or download the project

The wizard shows you exactly which tools will be created and lets you customize everything before generating. With Emcy Hosting, you can go from OpenAPI spec to live ChatGPT app without ever touching a terminal.

Common Issues

"Invalid OpenAPI spec"

Ensure your spec is valid OpenAPI 3.x. Test with:

npx swagger-cli validate ./openapi.yaml

"Connection refused" in ChatGPT

Your server must be publicly accessible. Local localhost URLs won't work. Deploy to Emcy Hosting for the easiest setup, or use any cloud provider with public HTTPS access.

"Authentication failed"

Check your environment variables are set correctly. For OAuth, ensure:

  • Authorization Server URL is correct
  • Server is deployed with HTTPS
  • MCP_RESOURCE_URL matches your deployed URL

Tools not appearing

ChatGPT caches tool lists. Try disconnecting and reconnecting the app, or wait a few minutes.

Next Steps

Now that your basic integration is working:

  1. Add OAuth for user-specific data - Add OAuth to your MCP server
  2. Attach the server to an agent before you embed it in your product - Agent setup guide
  3. Customize tool descriptions - edit the generated code for better AI understanding
  4. Add rate limiting - protect your API from excessive calls

From Zero to ChatGPT App

What used to take days of reading specs, implementing protocols, and debugging authentication now takes 5 minutes:

# 1. Generate
npx @emcy/openapi-to-mcp generate --url YOUR_OPENAPI_URL --emcy

# 2. Configure
cd my-api-mcp-server && cp .env.example .env
# Edit .env with your credentials

# 3. Deploy to Emcy
emcy deploy
# Or use the web dashboard at emcy.dev/deploy

# 4. Connect
# Add your Emcy URL to ChatGPT Connected Apps

Your API is now accessible to millions of ChatGPT users.


Need help? Check out the full documentation or join our Discord.

Tags
MCP
ChatGPT
OpenAPI
Tutorial
Quick Start