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:
- Go to emcy.dev/deploy
- Upload your generated project or connect your GitHub repo
- Configure environment variables in the dashboard
- 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)
- Go to ChatGPT
- Open Settings → Connected Apps → Add App
- Enter your Emcy server URL:
https://my-api.mcp.emcy.dev - 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:
- Parsed your OpenAPI spec - extracted endpoints, parameters, schemas
- Generated tool definitions - each endpoint becomes an MCP tool
- Built authentication - proper headers, token validation, metadata endpoints
- Created transports - HTTP for ChatGPT, Stdio for Claude Desktop
- 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:
| Tool | Description | OpenAPI Endpoint |
|---|---|---|
get_pet_by_id | Find pet by ID | GET /pet/{petId} |
add_pet | Add a new pet | POST /pet |
update_pet | Update existing pet | PUT /pet |
find_pets_by_status | Find by status | GET /pet/findByStatus |
delete_pet | Delete a pet | DELETE /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:
- Paste your OpenAPI URL
- Toggle which endpoints to expose
- Configure authentication
- 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_URLmatches 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:
- Add OAuth for user-specific data - Add OAuth to your MCP server
- Attach the server to an agent before you embed it in your product - Agent setup guide
- Customize tool descriptions - edit the generated code for better AI understanding
- 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.
