API & MCP Server Skeleton logo

API & MCP Server Skeleton

by luridarmawan

A lightweight, high-performance API Server using ElysiaJS with Bun runtime, integrated with Model Context Protocol (MCP) and WebSocket support. It's designed for context-aware interactions with AI agents or applications.

View on GitHub

Last updated: N/A

API & MCP Server Skeleton (ElysiaJS + Bun)

bun

bun

elysia

elysia

mcp

mcp

websocket

websocket

license

license

(Documentation is not yet complete.)

<!-- TOC --> <details> <summary>šŸ“‘ Daftar Isi</summary> </details>

A lightweight, high-performance API Server using ElysiaJS with Bun runtime, integrated with Model Context Protocol (MCP) and WebSocket support.

šŸš€ Features

  • REST API Server powered by Bun runtime.
  • WebSocket Event Handling (realtime communication).
  • Model Context Protocol (MCP) base support:
    • MCP Plugin Registry
    • MCP Discovery Endpoint (/.well-known/mcp.json)
  • Hot reload during development.
  • Ready for scalable deployment.
  • Example Events: Prayer Schedule, Event Registration.

šŸ“‹ Requirements

  • Bun runtime (v1.0+): Install Bun
  • Node.js (optional, for installing tools like wscat)
  • WebSocket client (Postman, wscat, etc.)

šŸ› ļø Getting Started

Clone this project and install dependencies:

git clone https://github.com/luridarmawan/mcp-api-server.git
cd mcp-api-server
bun install

Run development server:

bun run dev

Open http://localhost:3000 in your browser.

🧠 Model Context Protocol (MCP)

MCP is a lightweight communication protocol designed to enable context-aware interactions with AI agents or applications.

  • Base URL: http://localhost:3000/mcp
  • Discovery Endpoint: http://localhost:3000/mcp/.well-known/mcp.json

Example basic MCP interaction via WebSocket:

{
  "event": "prayer:schedule",
  "data": {
    "city": "Jakarta"
  }
}

For full details, see MCP and API Explanation.

šŸ”Œ WebSocket Usage

You can interact with the server via WebSocket:

  1. Install wscat if needed:
npm install -g wscat
  1. Connect to the WebSocket server:
wscat -c ws://localhost:3000
  1. Example Events you can send:

| Event | Payload Example | Description | |---|---|---| | prayer:schedule | "Jakarta" | Get prayer times for a city | | registration:new | { "name": "Alice", "phone": "081122334455", "email": "[email protected]" } | Register a new user |

# Install wscat (jika belum ada)
npm install -g wscat

# Connect ke socket server
wscat -c ws://localhost:3000

# Setelah terhubung, kirim event:
>> {"event":"prayer:schedule","data":{"city":"Jakarta"}}
>> {"event":"registration:new","data":{"name":"Alice","phone":"081122334455","email":"[email protected]"}}

šŸ“ Project Structure

.
ā”œā”€ā”€ constants.ts
ā”œā”€ā”€ index.test.ts
ā”œā”€ā”€ index.ts
ā”œā”€ā”€ modules
│   ā”œā”€ā”€ mcp
│   │   ā”œā”€ā”€ index.ts
│   │   └── types.ts
│   ā”œā”€ā”€ prayer
│   │   ā”œā”€ā”€ index.ts
│   │   └── types.ts
│   └── registration
│       ā”œā”€ā”€ index.ts
│       └── types.ts
ā”œā”€ā”€ services
│   └── prayerService.ts
ā”œā”€ā”€ sockets
│   └── index.ts
└── utils
    └── http.ts

šŸš€ Deployment

Build and run for production:

bun run build
bun start

Ready to deploy on platforms like Vercel, Railway, Fly.io, or any Bun-supported environment.

šŸ“„ License

This project is licensed under the Apache 2.0 License.

šŸ“š References