Skip to main content

Quick Demo: Greenfield MCP+OpenAPI

This example shows how to:

  • Define a simple OpenAPI schema
  • Implement a minimal MCP-compliant API
  • Run and test locally

1. Define OpenAPI Schema

# ~/.hapi/specs/ping-pong.yaml
openapi: 3.1.0
info:
title: Quick Demo API
version: 1.0.0
paths:
/ping:
get:
summary: Ping endpoint
operationId: ping
responses:
'200':
description: Pong
content:
application/json:
schema:
type: object
properties:
pong:
type: boolean

2. Init and Start the MCP Server

hapi init ping-pong
hapi serve ping-pong --port 443 --cert ./certs/cert.pem --key ./certs/key.pem

3. Test the API

curl https://localhost:3000/ping
# { "pong": true }

From here you can connect your prefer MCP client.

tip

You can extend this demo by adding context, authentication, or more endpoints following MCP and OpenAPI best practices.

Further Reading