KE

kerlos/elysia-mcp

Developer tools

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

49 stars 5 forks 品質 60 トレンド 17MIT

ElysiaJS プラグイン、HTTP トランスポート付きモデルコンテキストプロトコル

概要

包括的な ElysiaJS プラグインで、HTTP トランスポート対応のモデルコンテキストプロトコル (MCP) サーバを実装できます。 - : ストリーム可能な HTTP でフル HTTP ベースの MCP 輸送 - : ヘッダ経由でのステートフルなセッション処理 - : TypeScript と Zod 検証で構築 - : Elysia アプリケーション用のシンプルなプラグインアーキテクチャ - : ツール、リソース、プロンプト、およびロギング - : 任意のロガー (ピノ、ウィンストン、bunyan など) - : 適切な JSON-RPC 2.0 エラー応答 - : バンテスト ランナーとの完全なユニットテストカバレッジ 設定済みの Elysia MCP プロジェクトからすぐに始めるには、スターターテンプレートを使用できます。 elysia-mcp-starterテンプレートには以下が含まれます。 - MCPプラグインを使用した事前構成済みのElysia設定 - TypeScript設定 - 開発スクリプト - 基本的なプロジェクト構造 - MCPサーバーの実装例 この例では、単一のElysiaアプリケーションで複数のMCPプラグインを作成する方法を示します。 - 追加 - 2つの数字を追加 - 乗算 - 2つの数字を乗算 - 電源 - 指数関数の力にベースを計算する -...

概要(AI 翻訳)

実装のための包括的なElysiaJSプラグイン モデル コンテキスト プロトコル (MCP) サーバー HTTP トランスポート対応

##特徴

  • ** HTTP トランスポート**: ストリーム可能な HTTP を使用したフル HTTP ベースの MCP トランスポート
  • セッション管理: ヘッダーによるステートフルなセッション処理
  • Type-Safe:TypeScriptとZodの検証で構築
  • 容易な統合: Elysiaアプリ用のシンプルなプラグインアーキテクチャ
  • 包括的なサポート:ツール、リソース、プロンプト、およびロギング -カスタムロガーサポート:任意のロガー(ピノ、ウィンストン、バンヤンなど)を使用してください。
  • エラー処理:適切なJSON-RPC 2.0エラー応答
  • テスト: Bunテスト ランナーが付いている完全な単位のテストの適用範囲

インストール

##スターターテンプレート

設定済みの Elysia MCP プロジェクトからすぐに始めるには、スターターテンプレートを使用できます。

elysia-mcp-starterテンプレートには以下が含まれます。

  • MCPプラグインで事前設定されたElysia設定
  • TypeScript の設定
  • 開発スクリプト
  • 基本プロジェクト構造
  • MCP サーバーの実装例

クイックスタート

使用法

サンプルの実行

基本例:

複数のサーバー例:

この例では、単一のElysiaアプリケーションで複数のMCPプラグインを作成する方法を示します

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

README

以下は原文 README の抜粋です。原文を見る。

Elysia MCP Plugin

A comprehensive ElysiaJS plugin for implementing Model Context Protocol (MCP) servers with HTTP transport support.

Features

  • HTTP Transport: Full HTTP-based MCP transport with Streamable HTTP
  • Session Management: Stateful session handling via headers
  • Type-Safe: Built with TypeScript and Zod validation
  • Easy Integration: Simple plugin architecture for Elysia apps
  • Comprehensive Support: Tools, Resources, Prompts, and Logging
  • Custom Logger Support: Use any logger (pino, winston, bunyan, etc.)
  • Error Handling: Proper JSON-RPC 2.0 error responses
  • Testing: Full unit test coverage with Bun test runner

Installation

bun add elysia-mcp
# or
npm install elysia-mcp

Starter Template

To quickly get started with a pre-configured Elysia MCP project, you can use our starter template:

# Create a new project from the starter template
bun create https://github.com/kerlos/elysia-mcp-starter my-mcp-project

# Navigate to the project
cd my-mcp-project

# Install dependencies
bun install

# Start development server
bun run dev

The elysia-mcp-starter template includes:

  • Pre-configured Elysia setup with MCP plugin
  • TypeScript configuration
  • Development scripts
  • Basic project structure
  • Example MCP server implementation

Quick Start

import { Elysia } from 'elysia';
import { mcp } from 'elysia-mcp';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';

const app = new Elysia()
  .use(
    mcp({
      serverInfo: {
        name: 'my-mcp-server',
        version: '1.0.0',
      },
      capabilities: {
        tools: {},
        resources: {},
        prompts: {},
        logging: {},
      },
      setupServer: async (server: McpServer) => {
        // Register your MCP tools, resources, and prompts here
        server.registerTool(
          'echo',
          {
            description: 'Echoes back the provided text',
            inputSchema: {
              text: z.string().describe('Text to echo back'),
            },
          },
          async (args) => {
            return {
              content: [{ type: 'text', text: `Echo: ${args.text}` }],
            };
          }
        );
      },
    })
  )
  .listen(3000);

Usage

Running the Examples

Basic Example:

# Run the basic example server (port 3000)
bun run example

# Or with development mode (auto-restart)
bun run dev

Multiple Servers Example:

# Run the multiple MCP servers example (port 3000)
bun example:multi

This example demonstrates how to create multiple MCP plugins in a single Elysia application:

  • Math Operations Plugin (/math) - Basic arithmetic tools:

    • add - Add two numbers
    • multiply - Multiply two numbers
    • power - Calculate base to the power of exponent
GitHub で README 全文を見る

インストール

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