Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

Elysia-mcp

MCP.Pizza Chef: keithagroves

Elysia-mcp is a high-performance Model Context Protocol (MCP) server built with Bun and the Elysia web framework. It fully supports the MCP protocol, enabling developers to expose resources, tools, and prompts to large language models (LLMs) via a standardized interface. Featuring Server-Sent Events (SSE) transport, TypeScript support, and an easy-to-use API, it is designed for efficient, scalable, and type-safe MCP server implementations.

Use This MCP server To

Create MCP servers exposing APIs and resources to LLMs Implement real-time SSE communication with LLM clients Build scalable LLM tool and prompt integrations Develop TypeScript-based MCP servers with strong typing Host MCP servers optimized for Bun JavaScript runtime Enable LLMs to access custom data sources via MCP Rapidly prototype MCP servers with hot reloading support

README

MCP Server for Bun and Elysia

An implementation of the Model Context Protocol (MCP) server using Bun and the Elysia web framework. This project enables you to create high-performance MCP servers that expose resources, tools, and prompts to LLMs through a standardized interface.

Features

  • Server-Sent Events (SSE) transport implementation for Bun and Elysia
  • Complete MCP protocol support with resources, tools, and prompts
  • High-performance thanks to Bun's JavaScript runtime
  • TypeScript support with proper type definitions
  • Easy-to-use API for creating MCP-compatible servers

Prerequisites

  • Bun installed on your system
  • Basic familiarity with TypeScript and Elysia

Installation

# Clone the repository
git clone <your-repo-url>
cd mcp-server

# Install dependencies
bun install

Usage

Starting the server

# Start the server
bun start

# Start with hot reloading for development
bun dev

Building for production

# Build for production
bun run build

This will create a minified Node.js-compatible build in the dist directory.

Development

Project Structure

  • src/index.ts - Main entry point for the server
  • src/SSEElysiaTransport.ts - SSE transport implementation for Bun and Elysia

Creating an MCP Server

import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { SSEElysiaTransport } from "./SSEElysiaTransport";
import { Elysia } from "elysia";

// Create MCP server
const server = new McpServer({
  name: "my-mcp-server",
  version: "1.0.0"
});

// Add resources, tools, and prompts
server.resource(
  "example",
  "example://resource",
  async (uri) => ({
    contents: [{
      uri: uri.href,
      text: "Example resource content"
    }]
  })
);

// Create Elysia app
const app = new Elysia()
  .get("/", () => "MCP Server")
  .get("/sse", async (context) => {
    try {
      // Create transport
      const transport = new SSEElysiaTransport("/messages", context);
      
      // Store transport
      const sessionId = transport.sessionId;
      // ... store transport in a map
      
      // Connect to MCP server
      await server.connect(transport);
      
      return;
    } catch (error) {
      // Handle error
    }
  })
  .post("/messages", async (context) => {
    // Handle incoming messages
  });

// Start server
app.listen(3001, () => {
  console.log("MCP Server running at http://localhost:3001");
});

Debugging

You can debug your MCP server using the MCP Inspector tool and connect through sse

npx @modelcontextprotocol/inspector

This will open a web interface where you can:

  • List available resources, tools, and prompts
  • Test calling tools and retrieving resources
  • Inspect the communication between the client and server

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Elysia-mcp FAQ

How do I install Elysia-mcp?
Clone the repository, then run 'bun install' to install dependencies.
What runtime environment does Elysia-mcp require?
It requires Bun, a fast JavaScript runtime, along with the Elysia web framework.
Does Elysia-mcp support TypeScript?
Yes, it includes full TypeScript support with proper type definitions.
How does Elysia-mcp handle real-time communication?
It uses Server-Sent Events (SSE) for efficient real-time data transport.
Can I use Elysia-mcp for production deployments?
Yes, it supports building optimized production servers with Bun.
Is hot reloading available during development?
Yes, you can start the server with hot reloading using 'bun dev'.
What MCP features are supported?
It fully supports MCP protocol features including resources, tools, and prompts.
What LLM providers can I integrate with using Elysia-mcp?
You can integrate with any LLM provider supporting MCP, such as OpenAI, Anthropic Claude, and Google Gemini.