KE

keithagroves/elysia-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

24 stars 4 forks 品質 41 トレンド 10

モデル コンテキスト プロトコル (MCP) バンとエリャのサーバー

概要

BunとElysia Webフレームワークを使用したモデルコンテキストプロトコル(MCP)サーバの実装。 このプロジェクトでは、リソース、ツール、LLM を標準化されたインターフェイスで拡張する高性能な MCP サーバーを作成できます。 - Bun と Elysia の Server-Sent Events (SSE) トランスポート実装 - リソース、ツール、およびプロンプトで完全な MCP プロトコルのサポート - Bun の JavaScript ランタイムによる高性能 - 適切なタイプ定義の TypeScript サポート - MCP 互換サーバーを作成するための使いやすい API - あなたのシステムにインストールされているバン - TypeScriptとElysiaの基本的な知識 これにより、dist ディレクトリに minified Node.js 互換ビルドが作成されます。 - src/index.ts - サーバーのメインエントリーポイント - src/SSEElysiaTransport.

概要(AI 翻訳)

BunとElysia Webフレームワークを使用したモデルコンテキストプロトコル(MCP)サーバの実装。 このプロジェクトでは、リソース、ツール、LLM を標準化されたインターフェイスで拡張する高性能な MCP サーバーを作成できます。

##特徴

  • BunとElysiaのためのサーバー・セント・イベント(SSE)輸送の実装
  • リソース、ツール、およびプロンプトでMCPプロトコルをサポート
  • BunのJavaScriptのランタイムのおかげで高性能
  • 適切な型定義によるTypeScriptサポート
  • MCP対応サーバーを作成する使いやすいAPI

前提条件

  • お使いのシステムにインストールされているバン
  • TypeScriptとElysiaの基本的な知識

インストール

使用法

サーバの起動

生産のための建物

[dist] ディレクトリに、minified Node.js 互換ビルドを作成します。

開発

###プロジェクト構造

  • [src/index.ts - サーバーのメインエントリーポイント
  • [src/SSEElysiaTransport.ts - バンとエリジアのSSE輸送の実装

##MCPサーバーの作成

デバッグ

MCP 検査ツールを使用して MCP サーバーをデバッグし、sse を介して接続できます。

これは、あなたができるWebインターフェイスを開きます

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 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 
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

GitHub で README 全文を見る

インストール

npx @modelcontextprotocol/inspector
MCP 初心者?mcpskill.org のガイドから始めましょう →