### Run Example Project with MCP
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/quickstart.md
Use these commands to list available API specs and serve the example project with MCP enabled in headless mode. This is for on-premise setup.
```sh
# Check available API Specs
hapi list
# Start the example project
hapi serve example --mcp --headless
```
--------------------------------
### Load Balancer Setup Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/runmcp/scaling-instances.md
Configure a load balancer with a round-robin strategy for distributing traffic across multiple RunMCP instances. Ensure backend instances are correctly listed.
```yaml
load_balancer:
type: round_robin
backends:
- runmcp-1.internal
- runmcp-2.internal
- runmcp-3.internal
```
--------------------------------
### Install HAPI CLI
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Installs the HAPI CLI binary for Linux/macOS, Windows PowerShell, or via Docker. Verify the installation using the `--help` flag.
```bash
# Linux / macOS — one-liner install
curl -fsSL https://get.mcp.com.ai/hapi.sh | bash
```
```powershell
# Windows PowerShell
irm https://get.mcp.com.ai/hapi.ps1 | iex
```
```bash
# Or pull the Docker image directly
docker pull hapimcp/hapi-cli:latest
```
```bash
# Verify installation
hapi --help
```
--------------------------------
### Run HAPI MCP Server Locally
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Starts a HAPI MCP server in detached mode, mapping ports, mounting a local HAPI home directory, and running the petstore example.
```sh
docker run --name hapi-petstore -d --rm \
-p 3030:3030 \
-v ~/.hapi:/app/.hapi \
hapimcp/hapi-cli:latest serve petstore \
--port 3030 \
--headless
```
--------------------------------
### Run LangFlow with Docker and Configure HAPI URL
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/10-integrations/orchestrators/langflow.md
This example shows how to run LangFlow using Docker, expose its port, add a host entry for the Docker daemon, and then execute commands inside the container to set the HAPI_URL and start LangFlow. Use 'host.docker.internal' to refer to the host machine from within the Docker container.
```bash
docker run -p 7860:7860 --add-host host.docker.internal:host-gateway --name langflow -d langflowai/langflow:1.5.1
```
```bash
docker exec -it langflow /bin/bash
```
```bash
export HAPI_URL=http://host.docker.internal:3000/mcp
```
```bash
langflow
```
--------------------------------
### Start and Test HAPI Server Locally
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Start a HAPI server locally with the `--headless` option for development. Includes commands to test the REST endpoint and the MCP endpoint.
```bash
# Step 2 — Start HAPI Server locally (brownfield / headless)
hapi serve hello-api --headless --url https://api.example.com --port 3000
# Step 3 — Test the REST endpoint
curl http://localhost:3000/hello
# {"message":"Hello, AI World!"}
# Step 4 — Test the MCP endpoint
curl http://localhost:3000/mcp
# Step 5 — Deploy to Cloudflare for production
hapi deploy \
--openapi ./hello-api.yaml \
--url https://api.example.com \
--name hello-mcp
```
--------------------------------
### Full HAPI MCP Server Deployment Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/cloudflare/index.mdx
A comprehensive example command for deploying the HAPI MCP Server, including OpenAPI URL, backend URL, custom worker name, and an environment variable.
```sh
hapi deploy --openapi https://petstore3.swagger.io/api/v3/openapi.json \
--url https://petstore3.swagger.io/api/v3 \
--name petstore-hapi \
--var API_KEY=your-key
```
--------------------------------
### Start MCP Server with OpenAPI Specification
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/10-integrations/auth/workos.mdx
Use the HAPI server CLI to start the MCP server, loading your API specification with security configurations. The `--headless` flag is used for backend integration.
```bash
hapi serve demo -f "api.yaml" --headless
```
```bash
hapi serve https://docs.mcp.com.ai/apis/openapi/demo.yaml -f "api.yaml" --headless
```
--------------------------------
### Start HAPI Server with MCP
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/10-integrations/orchestrators/langflow.md
Ensure your HAPI server is running with MCP support enabled. This command starts the HAPI server and enables MCP.
```bash
hapi start --mcp
```
--------------------------------
### Quick Start: Run HAPI MCP Server Instantly
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/flyio.mdx
Use `fly machine run` for rapid prototyping or testing. Replace `latest` with a specific version tag if needed. The `--command` flag starts the server, and `-e` sets environment variables. Add `-p 8080` to expose a specific port, more `-e VAR=value` for additional variables, or override the default command. Use `--ephemeral` for machines destroyed when stopped.
```sh
fly machine run hapimcp/hapi-cli:latest --command "hapi serve" \
-e openapi="https://petstore3.swagger.io/api/v3/openapi.json" \
-e url="https://petstore3.swagger.io/api/v3"
```
--------------------------------
### Install HAPI CLI on Windows
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Installs the HAPI CLI using a PowerShell script for Windows users.
```powershell
irm https://get.mcp.com.ai/hapi.ps1 | iex
```
--------------------------------
### Agent Code Example (Node.js)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/agent-integration.md
A Node.js example demonstrating how an agent can call the `/agent/act` endpoint using `node-fetch` to send an action and log the received result.
```javascript
const fetch = require('node-fetch');
async function act(action) {
const res = await fetch('http://localhost:3000/agent/act', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action })
});
const data = await res.json();
console.log('Agent result:', data.result);
}
act('greet');
```
--------------------------------
### Fly.toml Example for HAPI MCP Server
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/flyio.mdx
Example `fly.toml` configuration for deploying the HAPI MCP Server using the pre-built image. It specifies the app name, primary region, build image, HTTP service settings, environment variables, and VM resources.
```toml
app = 'my-mcp-server'
primary_region = 'dfw'
[build]
image = 'hapimcp/hapi-cli:latest'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[env]
openapi = 'https://petstore3.swagger.io/api/v3/openapi.json'
url = 'https://petstore3.swagger.io/api/v3'
[[vm]]
memory = '256mb'
cpus = 1
memory_mb = 256
```
--------------------------------
### Install HAPI CLI on Linux
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Installs the HAPI CLI using a curl script for Linux users.
```bash
curl -fsSL https://get.mcp.com.ai/hapi.sh | bash
```
--------------------------------
### OpenAPI Specification Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/serve-and-consume-apis.md
Define your API contract using OpenAPI specification in YAML format. This example shows a basic structure for an API with a single GET endpoint.
```yaml
openapi: 3.1.0
info:
title: Example API for MCP
version: 1.0.0
paths:
/hello:
get:
summary: Greet the AI world
responses:
'200':
description: Success
```
--------------------------------
### gRPC Request Validation Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/grpc-idl/validation-layers.md
This example demonstrates a gRPC service definition for creating a user, which implies schema validation will be applied to the User message.
```proto
rpc CreateUser (User) returns (UserResponse);
```
--------------------------------
### Start HAPI Server for Greenfield Project
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
Starts the HAPI server for a greenfield project, enabling MCP support. This command serves the API defined by the project's OpenAPI schema.
```sh
hapi serve example --mcp
```
--------------------------------
### Bootstrap HAPI Server with OpenAPI
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/index.md
Starts the HAPI server for a specified project using OpenAPI, with options for port, headless mode, and SSL certificates. Ensure your OpenAPI spec is kept up-to-date to avoid validation errors.
```bash
hapi serve linkedin --port 443 --headless --cert ./certs/cert.pem --key ./certs/key.pem
```
--------------------------------
### Start HAPI Server for Brownfield Project (Headless)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
Starts the HAPI server in headless mode for brownfield projects. This mode allows the server to consume services defined in the OpenAPI schema without implementing them from scratch.
```sh
hapi serve example --headless
```
--------------------------------
### Frontend Example (React)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/fullstack-example.md
A React component that fetches a greeting from the backend API. It includes input for a name and displays the returned message.
```jsx
import React, { useState } from 'react';
export default function Greet() {
const [name, setName] = useState('');
const [message, setMessage] = useState('');
const greet = async () => {
const res = await fetch(`/greet?name=${name}`);
const data = await res.json();
setMessage(data.message);
};
return (
);
}
```
--------------------------------
### Initialize Greenfield HAPI Project
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
Use the 'hapi init' command to create a new HAPI project based on an OpenAPI schema. The 'example' parameter specifies the name of your project, derived from the schema file name.
```sh
# Check available API Specs
hapi list
# GREENFIELD: Create a new project with the OpenAPI schema
hapi init example
```
--------------------------------
### Integrate WorkOS Authentication with HAPI MCP
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Integrates enterprise authentication using WorkOS AuthKit and Dynamic Client Registration. Security is derived from the OpenAPI specification. This example shows downloading demo specs and starting the server.
```bash
# Download a demo spec and a security-extension overlay
curl -o demo.yaml https://docs.mcp.com.ai/apis/openapi/demo.yaml
curl -o api.yaml https://docs.mcp.com.ai/apis/openapi/api-to-mcp.yaml
```
```bash
# Start the server with WorkOS auth enabled
hapi serve demo -f "api.yaml" --headless
```
```yaml
x-hapi:
security:
- oauth2_authorization_code:
client_id: "YOUR_WORKOS_CLIENT_ID"
client_secret: "YOUR_WORKOS_CLIENT_SECRET"
cors:
allowedOrigins:
- "https://your-mcp-client.example.com"
```
--------------------------------
### Start and Inspect LinkedIn MCP Server
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Start the LinkedIn MCP server locally and inspect it using the MCP Inspector. This allows for testing and debugging the wrapped API.
```bash
# 3. Start the LinkedIn MCP Server
hapi serve linkedin --headless --port 3030 --url https://api.linkedin.com
# 4. Inspect with MCP Inspector
hapi serve linkedin --headless --port 3030 --url https://api.linkedin.com \
| bunx @modelcontextprotocol/inspector
```
--------------------------------
### RunMCP Docker Compose Example (Dev)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/runmcp/deployment-models.md
A basic Docker Compose configuration for running a single RunMCP gateway instance. Suitable for development and testing environments.
```yaml
version: '3.8'
services:
runmcp:
image: larebelion/runmcp:latest
ports:
- "8080:8080"
volumes:
- ./config:/app/config
```
--------------------------------
### Run HAPI MCP Server in Air-Gapped Environment
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Starts a HAPI MCP server in an air-gapped environment using a locally loaded image and a specified offline API URL.
```sh
docker run --name hapi-offline -d --rm \
-p 3030:3030 \
-v ~/.hapi:/app/.hapi \
hapimcp/hapi-cli:latest serve petstore \
--port 3030 \
--headless \
--url "https://petstore3.air-gapped.local/api/v3"
```
--------------------------------
### API Handler Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/agent-integration.md
Example of an API handler that processes agent actions. This handler is designed to work with the OpenAPI schema defined for agent interactions.
```javascript
app.post('/agent/act', (req, res) => {
const { action } = req.body;
// Implement custom logic or call plugins
res.json({ result: `Action ${action} performed!` });
});
```
--------------------------------
### Serve HAPI MCP Project Locally or Remotely
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Starts a HAPI MCP server for a local project or a remote OpenAPI URL. Options can be appended for customization.
```bash
# local file
hapi serve [options]
# remote URL
hapi serve https://petstore3.swagger.io/api/v3/openapi.json [options]
```
--------------------------------
### Serve Protobuf/gRPC Services as MCP Tools
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Consumes Protobuf IDL files to expose gRPC service methods as MCP tools. Uses gRPC metadata for authentication. This example defines a WeatherService and serves it using the proto IDL.
```proto
// weather.proto
syntax = "proto3";
service WeatherService {
rpc GetWeather (WeatherRequest) returns (WeatherResponse) {
option (mcp.tool) = true; // expose this RPC as an MCP tool
}
}
message WeatherRequest {
string city = 1;
}
message WeatherResponse {
float temperature = 1;
string condition = 2;
}
```
```bash
# Serve using the proto IDL
hapi serve weather-grpc --mcp
```
--------------------------------
### Start Strava MCP Server for Agentic Workflow
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Start the Strava MCP server locally to pull activity data for an agentic social media workflow. This server acts as a proxy to the Strava API.
```bash
# Start Strava MCP Server (port 3301)
hapi serve strava --headless --port 3301 --url https://www.strava.com/api/v3
```
--------------------------------
### Get HAPI MCP CLI Help
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Displays help information for the HAPI MCP CLI commands and options.
```sh
docker run --rm hapimcp/hapi-cli:latest help
```
--------------------------------
### API Handler Example (Node.js/Express)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/agent-integration.md
An example of an API handler, likely using Express.js, that implements the `/agent/act` POST endpoint. It parses the incoming action from the request body and sends back a JSON response indicating the action was performed.
```javascript
app.post('/agent/act', (req, res) => {
const { action } = req.body;
// Implement custom logic or call plugins
res.json({ result: `Action ${action} performed!` });
});
```
--------------------------------
### Serve HAPI MCP Project in Headless Mode
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Starts the HAPI MCP server for the specified project in headless mode, disabling the REST API and enabling only MCP functionality.
```bash
hapi serve petstore --headless
```
--------------------------------
### Serve HAPI MCP Project with TLS (HTTPS)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Starts the HAPI MCP server with HTTPS enabled by providing certificate and key files. The port is set to 443.
```bash
hapi serve linkedin --port 443 --cert ./certs/cert.pem --key ./certs/key.pem
```
--------------------------------
### Deploy HAPI MCP Pre-Built Image
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/flyio.mdx
Deploy your app using the official pre-built image. Replace `latest` with a specific version tag if needed. This command pushes the image and starts your HAPI MCP Server.
```sh
fly deploy -- serve
```
```sh
fly deploy --image hapimcp/hapi-cli:latest
```
--------------------------------
### Run Docker Compose Services
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Starts the services defined in a Docker Compose file in detached mode.
```sh
docker-compose up -d
```
--------------------------------
### Example Context Flow with Tool Invocation
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/chatmcp/chat-flow-design.md
TypeScript pseudocode demonstrating a chat flow where an agent processes user input, potentially invokes tools via OpenAPI, and returns an answer.
```typescript
// User sends input
addMessage(chat.id, { content: 'Hello!', senderId: 'user' });
// Prompt is constructed from chat history
const prompt = buildPrompt(chat.history);
// Agent processes prompt, may invoke RAG or tools
const answer = agent.processPrompt(prompt);
// Agent may call tools via OpenAPI
const toolResult = agent.invokeTool('getWeather', { location: 'Berlin' });
// Answer is returned and stored in memory
addMessage(chat.id, { content: answer, senderId: 'agent' });
```
--------------------------------
### List Available HAPI MCP Specs
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Lists all available OpenAPI specs and configurations mounted within the HAPI CLI container without starting a server.
```sh
docker run --rm \
-v ~/.hapi:/app/.hapi \
hapimcp/hapi-cli:latest list
```
--------------------------------
### Agent Code Example (Node.js)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/agent-integration.md
Node.js code to interact with the agent API. It sends a POST request to the '/agent/act' endpoint and logs the result.
```javascript
const fetch = require('node-fetch');
async function act(action) {
const res = await fetch('http://localhost:3000/agent/act', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action })
});
const data = await res.json();
console.log('Agent result:', data.result);
}
act('greet');
```
--------------------------------
### Run HAPI CLI with Docker
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Execute the HAPI CLI within a Docker container for local development or air-gapped environments. This example serves a petstore specification on port 3030.
```bash
docker run --name hapi-petstore -d --rm \
-p 3030:3030 \
-v ~/.hapi:/app/.hapi \
hapimcp/hapi-cli:latest serve petstore --port 3030 --headless
```
--------------------------------
### Define Custom Tool Operation with Protobuf Option
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/grpc-idl/index.md
This example shows how to use Protobuf options to mark an RPC as a custom tool operation, enabling HAPI-specific features or MCP context integration.
```proto
service WeatherService {
rpc GetWeather (WeatherRequest) returns (WeatherResponse) {
option (mcp.tool) = true;
}
}
```
--------------------------------
### Start OpenAI MCP Server
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/mcp-servers-from-oas/openai-mcp.md
Launch the MCP server using the HAPI CLI with the pre-configured OpenAI Tools specification. This command specifies the OpenAPI spec, runs it headless, sets the port, and defines the upstream URL for the OpenAI API.
```bash
hapi serve openai-tools --headless --port 3030 --url https://api.openai.com/v1
```
--------------------------------
### Start LinkedIn MCP Server
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/mcp-servers-from-oas/linkedin-mcp.md
Launch the HAPI MCP server, specifying the LinkedIn configuration file, port, and the target LinkedIn API URL. The --headless flag runs the server in the background.
```bash
hapi serve linkedin --headless --port 3030 --url https://api.linkedin.com
```
--------------------------------
### Test HAPI Server Endpoints
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
After starting a HAPI server, test its REST and MCP endpoints using `curl`, and browse the Swagger UI.
```bash
# Test the REST endpoint
curl http://localhost:3000/hello
# {"success":true,"path":"/hello","method":"GET","timestamp":"2025-07-27T12:00:00Z"}
```
```bash
# Test the MCP endpoint
curl http://localhost:3000/mcp
```
```bash
# Browse the built-in Swagger UI
open http://localhost:3000/swagger
```
--------------------------------
### RunMCP Kubernetes Deployment Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/runmcp/deployment-models.md
A Kubernetes Deployment manifest for running multiple RunMCP gateway replicas. This configuration includes volume mounts for configuration and specifies replica count for high availability.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: runmcp-gateway
spec:
replicas: 3
selector:
matchLabels:
app: runmcp-gateway
template:
metadata:
labels:
app: runmcp-gateway
spec:
containers:
- name: runmcp
image: larebelion/runmcp:latest
ports:
- containerPort: 8080
volumeMounts:
- name: config
mountPath: /app/config
volumes:
- name: config
configMap:
name: runmcp-config
```
--------------------------------
### Implement Hello World Endpoint Logic
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
This TypeScript code provides the implementation for the '/hello' GET endpoint in a greenfield HAPI project. It returns a JSON object with success status, path, method, and a timestamp.
```typescript
// #region functions for path /hello
async getHello() {
console.log('This is the get method for /hello')
return {
success: true,
path: '/hello',
method: 'GET',
timestamp: new Date().toISOString()
}
},
// #endregion
```
--------------------------------
### Test Hello World API Endpoint
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
Uses curl to test the '/hello' endpoint of the HAPI server. This demonstrates a successful GET request and the expected JSON response.
```sh
curl http://localhost:3000/hello
```
--------------------------------
### Enable Debug Mode for HAPI MCP Server
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Starts the HAPI MCP server with debug mode enabled, providing detailed logs and registered routes for easier troubleshooting.
```bash
hapi serve myproject --dev
```
--------------------------------
### Serve HAPI MCP Server (Greenfield)
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Starts an HTTP server that generates REST and MCP endpoints from an OpenAPI specification. Use `--mcp` to scaffold handler implementations. Supports custom ports, HTTPS, developer mode, and CORS restrictions.
```bash
# Serve a local project on default port 3000
hapi serve petstore --mcp
```
```bash
# Serve from a remote OpenAPI URL
hapi serve https://petstore3.swagger.io/api/v3/openapi.json --mcp
```
```bash
# Serve with a custom port and HTTPS
hapi serve myproject --port 8443 --cert ./certs/cert.pem --key ./certs/key.pem
```
```bash
# Enable developer / debug mode (verbose route logging)
hapi serve myproject --dev
```
```bash
# Restrict CORS to specific origins
hapi serve myproject --cors "https://app.example.com,https://staging.example.com"
```
--------------------------------
### Initialize and Serve MCP API
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/quick-demo.md
Initialize a new MCP project and serve the API locally. Ensure you have the necessary certificates for HTTPS.
```bash
hapi init ping-pong
```
```bash
hapi serve ping-pong --port 443 --cert ./certs/cert.pem --key ./certs/key.pem
```
--------------------------------
### Generated Handler Stub (TypeScript)
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Example of an auto-generated handler stub for a `GET /hello` operation created by `hapi init`. This stub includes a basic implementation and logging.
```typescript
// Auto-generated by `hapi init`
async getHello() {
console.log('This is the get method for /hello')
return {
success: true,
path: '/hello',
method: 'GET',
timestamp: new Date().toISOString()
}
}
```
--------------------------------
### Configure LangFlow with HAPI URL
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/10-integrations/orchestrators/langflow.md
Set the HAPI_URL environment variable to point to your HAPI server's MCP endpoint when starting LangFlow. This example assumes a local HAPI server on port 3000.
```bash
HAPI_URL=http://localhost:3000/mcp langflow
```
--------------------------------
### Create and Configure Fly.io App
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/flyio.mdx
Create a new Fly.io app and generate a `fly.toml` configuration file. Provide a unique app name and region when prompted. Ensure `openapi` and `url` environment variables are set.
```sh
fly launch --no-deploy --image hapimcp/hapi-cli:latest \
-e openapi="https://petstore3.swagger.io/api/v3/openapi.json" \
-e url="https://petstore3.swagger.io/api/v3"
```
--------------------------------
### Connect to MCP Server with QBot
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/qbot.md
Use this command to connect QBot to your MCP server. Ensure the URL is correct for your server instance.
```bash
qbot --url http://localhost:3000/mcp
```
--------------------------------
### Bootstrap Greenfield Project with HAPI CLI
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Scaffolds a new HAPI project directory from an OpenAPI schema, generating handler stubs, project configuration, and directory layout. After initialization, serve the project using `hapi serve`.
```bash
# Create a new project named "example"
hapi init example
```
```bash
# Then serve it
hapi serve example --mcp
```
--------------------------------
### Start LinkedIn MCP Server
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Starts a HAPI MCP server for LinkedIn on port 3302, connecting to the specified URL. This is useful for exposing LinkedIn APIs to LLMs and agents.
```bash
hapi serve linkedin --headless --port 3302 --url https://api.linkedin.com
```
--------------------------------
### Configure LLM Provider and Model
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/qbot.md
Configure your LLM provider, model, and API key using these slash commands. Alternatively, these settings can be managed in the `~/.qbot/config.json` file.
```bash
/llm provider groq
```
```bash
/llm model llama-3.3-70b-versatile
```
```bash
/llm key groq
```
--------------------------------
### Display HAPI CLI Help
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Access comprehensive help information for the HAPI CLI, listing all available commands and their options.
```bash
hapi --help
```
--------------------------------
### Backend Implementation (Express)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/fullstack-example.md
A basic Express.js server that implements the /greet endpoint. It handles a 'name' query parameter and returns a JSON greeting.
```javascript
const express = require('express');
const app = express();
app.get('/greet', (req, res) => {
const name = req.query.name || 'World';
res.json({ message: `Hello, ${name}!` });
});
app.listen(3001, () => console.log('API running on port 3001'));
```
--------------------------------
### Register Plugins with Configuration (YAML)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/runmcp/plugin-system.md
Define and configure plugins, such as authentication or logging, within the gateway's configuration file.
```yaml
plugins:
- name: auth-oauth2
type: authentication
config:
clientId: "..."
clientSecret: "..."
- name: logging
type: logging
config:
provider: datadog
```
--------------------------------
### Check Container Logs
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Retrieves logs for a specific Docker container. Use when a container exits immediately after starting.
```sh
docker logs hapi-petstore
```
--------------------------------
### Lambda Function Example (Node.js)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/4-examples/serverless-deploy.md
A basic Node.js Lambda function handler that returns a JSON response. This function is designed to be triggered by API Gateway.
```js
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from serverless MCP!' })
};
};
```
--------------------------------
### Run HAPI MCP Server with Environment Variables
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Runs a HAPI MCP server with specified environment variables for HAPI_HOME and backend API URL, enabling development mode.
```sh
docker run --name hapi-petstore -d --rm \
-p 3030:3030 \
-v ~/.hapi:/app/.hapi \
-e HAPI_HOME=/app/.hapi \
hapimcp/hapi-cli:0.6.0 serve petstore \
--port 3030 \
--headless \
--dev \
--url "https://petstore3.swagger.io/api/v3"
```
--------------------------------
### Run MCP Server Locally with Docker
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/servers-apis/openapi.mdx
This command runs the MCP Server locally using Docker. Ensure you have Docker installed and replace placeholders with your specific details.
```bash
docker run -d --name mcp-server \
hapimcp/hapi-cli:0.6.0 serve mcp-server \
--openapi \
--url --headless
```
--------------------------------
### Serve HAPI MCP Project in Headless Mode (Alternative)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Enables headless mode for the HAPI MCP server, disabling the REST API and focusing solely on MCP functionality.
```bash
hapi serve myproject --headless
```
--------------------------------
### Serve HAPI MCP Server (Headless/Proxy)
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Runs HAPI in headless mode, acting as an MCP façade that proxies requests to an upstream backend. Requires `--url` or a `servers` field in the OpenAPI spec. Can be combined with MCP Inspector for testing or run in Docker.
```bash
# Point HAPI at an existing LinkedIn API backend
hapi serve linkedin --headless --port 3030 --url https://api.linkedin.com
```
```bash
# Combine with MCP Inspector for interactive testing
hapi serve linkedin --headless --port 3030 --url https://api.linkedin.com \
| bunx @modelcontextprotocol/inspector
```
```bash
# Run in Docker, mounting ~/.hapi for spec discovery
docker run --name hapi-petstore -d --rm \
-p 3030:3030 \
-v ~/.hapi:/app/.hapi \
hapimcp/hapi-cli:latest serve petstore --port 3030 --headless
```
--------------------------------
### Declarative Service and Route Configuration for RunMCP
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Configure services and routes declaratively using YAML for GitOps workflows. This allows for defining multiple services and routing rules.
```yaml
# gateway-config.yaml
services:
- name: chatmcp
openapi: ./chatmcp-openapi.json
url: https://chat.mcp.com.ai
subdomain: chatmcp
- name: hapi
openapi: ./hapi-openapi.json
url: https://hapi.mcp.com.ai
subdomain: hapi
routes:
- match:
subdomain: "*.run.mcp.com.ai"
forwardTo: service
```
--------------------------------
### gRPC Security Validation Example
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/grpc-idl/validation-layers.md
This comment indicates the use of gRPC metadata for passing security credentials like API keys or tokens, which is part of the security validation layer.
```proto
// Use gRPC metadata for API keys or tokens
```
--------------------------------
### Docker Compose for HAPI MCP Deployment
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/docker.md
Defines a Docker Compose setup for running multiple HAPI MCP services, including configuration for ports, environment variables, and volumes.
```yaml
version: '3.8'
services:
hapi-mcp:
image: hapimcp/hapi-cli:latest
container_name: hapi-mcp-server
ports:
- "3030:3030"
environment:
- NODE_ENV=development
- HAPI_HOME=/app/.hapi
volumes:
- ~/.hapi:/app/.hapi
- ./more-specs:/app/.hapi/specs
command: serve petstore --port 3030 --headless --dev
restart: unless-stopped
my-crm-mcp:
image: hapimcp/hapi-cli:latest
container_name: my-crm-mcp-server
ports:
- "4040:3030"
environment:
- NODE_ENV=production
- HAPI_HOME=/app/.hapi
volumes:
- ~/.hapi:/app/.hapi
- ./crm-specs:/app/.hapi/specs
command: serve crm-api --port 3030 --headless
restart: unless-stopped
```
--------------------------------
### Deploy to Cloudflare Workers
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Deploy a worker to Cloudflare using the `hapi deploy` command. Requires Wrangler to be installed. Specify the OpenAPI spec URL, backend URL, and worker name.
```bash
hapi deploy --openapi https://petstore3.swagger.io/api/v3/openapi.json \
--url https://petstore3.swagger.io/api/v3 \
--name petstore-hapi
```
--------------------------------
### Configure OAuth2 Security with OpenAPI Extension
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Extends an OpenAPI spec with HAPI security configuration for OAuth2 flows, including token acquisition and injection. This example uses the `authorization_code` flow.
```yaml
# Extend your OpenAPI spec with HAPI security config
components:
securitySchemes:
oauth2_authorization_code:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://auth.example.com/oauth/authorize
tokenUrl: https://auth.example.com/oauth/token
scopes:
read:data: Read data
x-hapi:
security:
- oauth2_authorization_code:
client_id: $SECRETS.CLIENT_ID # resolved from env at runtime
client_secret: $SECRETS.CLIENT_SECRET
```
```bash
# Start the secured server
hapi serve myapi --headless --url https://api.example.com
```
--------------------------------
### Define OpenAPI Schema for Hello World API
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/2-getting-started/hello-world.mdx
This YAML defines the OpenAPI 3.1.0 schema for a simple 'Hello World' API, specifying the '/hello' GET endpoint and its JSON response.
```yaml
openapi: 3.1.0
info:
title: Hello World API
version: 1.0.0
paths:
/hello:
get:
summary: Returns Hello World
operationId: getHello
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
message:
type: string
```
--------------------------------
### List Available OpenAPI Specs
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/hapi-cli.md
Use this command to discover all OpenAPI specifications that HAPI has found in your HAPI home directory.
```bash
hapi list
```
--------------------------------
### Define Endpoints using OpenAPI Schema
Source: https://context7.com/la-rebelion/mcp-docs/llms.txt
Defines API endpoints as MCP tools. The `operationId` in the OpenAPI spec maps directly to the tool name. This example shows a weather API definition.
```yaml
# weather-api.yaml
openapi: 3.1.0
info:
title: Weather API
version: 1.0.0
paths:
/weather/{city}:
get:
summary: Get weather for a city
operationId: getWeather # ← becomes the MCP tool name
parameters:
- name: city
in: path
required: true
schema:
type: string
responses:
'200':
description: Weather data
content:
application/json:
schema:
type: object
properties:
temperature:
type: number
condition:
type: string
```
```json
{
"tools": [
{
"name": "getWeather",
"description": "Get weather for a city",
"parameters": {
"city": { "type": "string", "required": true }
}
}
]
}
```
```bash
hapi serve weather-api --headless --url https://api.weather.example.com
```
--------------------------------
### Authenticate with Cloudflare CLI
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/cloudflare/index.mdx
Use these commands to authenticate your CLI with Cloudflare. Run `wrangler whoami` first to check your status.
```sh
wrangler whoami
```
```sh
wrangler login
```
```sh
hapi login
```
--------------------------------
### Deploy HAPI MCP Server with Environment Variables
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/8-deployment/cloud/cloudflare/index.mdx
Deploy the HAPI MCP Server and pass additional environment variables to the worker. Use the `--var` flag for each variable.
```sh
hapi deploy --openapi --var API_KEY=your-key --var DEBUG=true
```
--------------------------------
### Implement a Plugin Hook (JavaScript)
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/runmcp/plugin-system.md
Use pseudocode to illustrate how a plugin can hook into the request lifecycle, executing custom logic before a request is processed.
```javascript
// Pseudocode for a plugin hook
gateway.on('beforeRequest', (req, res, next) => {
// Custom logic here
next();
});
```
--------------------------------
### Dynamic Routing for Multi-Tenancy
Source: https://github.com/la-rebelion/mcp-docs/blob/main/docs/3-components/hapi-server/openapi/advanced-usage.md
Implement dynamic routing logic to direct traffic based on hostnames, enabling multi-tenancy or SaaS patterns. This pseudocode illustrates routing to customer-specific logic when a subdomain matches a pattern.
```javascript
// Pseudocode for dynamic routing
if (req.hostname.endsWith('.customer.com')) {
// Route to customer-specific logic
}
```