OpenAPI Specification for AI Integration
MockServer's REST API is fully documented via an OpenAPI 3.0 specification. This specification can be used as a fallback for AI tools that do not support the Model Context Protocol (MCP), or as supplementary reference material when working with any AI assistant.
OpenAPI Spec Locations
The OpenAPI specification is available from two locations:
From a Running Instance
Any running MockServer instance serves its OpenAPI specification at:
GET http://localhost:1080/mockserver/openapi.yaml
This always reflects the exact API version of the running server.
Published Specification
The latest published specification is also available at:
https://www.mock-server.com/mockserver-openapi.yaml
And on SwaggerHub:
https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi
Using with ChatGPT Actions
You can configure a Custom GPT in ChatGPT to interact with MockServer using the OpenAPI specification. This enables ChatGPT to create expectations, verify requests, and manage your MockServer instance through the ChatGPT interface.
Setup Steps
-
Open ChatGPT and navigate to My GPTs > Create a GPT
-
In the Configure tab, scroll down to Actions and click Create new action
-
In the Schema field, paste the contents of the MockServer OpenAPI specification. You can retrieve it with:
curl -s http://localhost:1080/mockserver/openapi.yaml -
Set the Server URL to your MockServer instance (e.g.,
http://localhost:1080) -
Set Authentication to None (or configure as appropriate if you have control plane authentication enabled)
-
Save the GPT. You can now ask it to create mocks, verify requests, and manage MockServer.
Note: ChatGPT Actions require your MockServer instance to be accessible from the internet. For local development, consider using a tunnelling service or the MCP integration instead.
Using as LLM Context
For AI assistants that don't support MCP or ChatGPT Actions, you can use the OpenAPI specification as reference material by pasting it directly into a conversation.
Steps
-
Download the specification:
curl -s http://localhost:1080/mockserver/openapi.yaml > mockserver-openapi.yaml -
Paste the specification content into your AI assistant's chat, or attach it as a file if your AI tool supports file uploads.
-
Ask the assistant to use the specification as a reference. For example:
"Using the MockServer OpenAPI spec I've provided, write a curl command to create an expectation that returns a 201 response for POST /api/users with a JSON body containing an id field."
The AI assistant can then generate accurate API calls based on the specification, including correct endpoints, request formats, and parameter types.
MCP vs OpenAPI for AI Integration
Both MCP and OpenAPI can be used to connect AI assistants to MockServer, but they have different strengths:
| Feature | MCP | OpenAPI |
|---|---|---|
| Communication | Bidirectional, real-time | Reference-only (AI generates API calls) |
| Tool invocation | AI calls tools directly through the protocol | AI generates curl/HTTP commands for the user to execute |
| Real-time state | Resources provide live server state (expectations, requests, logs) | No live state — must manually query the API |
| Setup complexity | One-time configuration in your AI tool | Paste spec into each conversation or configure ChatGPT Action |
| AI tool compatibility | Cursor, Claude Code, Windsurf, Cline, Continue, OpenCode | Any AI assistant (ChatGPT, Gemini, Copilot, etc.) |
| Feedback loop | AI receives tool results and can react immediately | AI generates commands; user must report results back |
| Best for | Interactive development and debugging workflows | One-off queries, AI tools without MCP support, documentation |
Recommendation: Use MCP when your AI tool supports it. The bidirectional communication enables a much more interactive workflow where the AI can create expectations, check results, and iterate — all without you having to copy-paste commands. Use OpenAPI as a fallback for AI tools that do not support MCP yet.
Related Pages
- MCP Setup — connect AI assistants via the Model Context Protocol
- MCP Tools Reference — full documentation of all MCP tools
- Using OpenAPI Specifications — how MockServer uses OpenAPI specs for request matching and expectation generation