mcpField
E
easyMcp

easyMcp

ローカル
github.com/wenb1n-dev開発ツール273 週間前に更新

easyMcp について

easyMcpは、STDIO、SSE、Streamable Httpに対応した拡張可能なMCPサーバーを構築するフレームワークです。`BaseHandler`を継承するハンドラークラスで独自ツールを追加します。

主な機能

  1. 01STDIO、SSE、Streamable Http対応
  2. 02ハンドラー形式の拡張可能なツール構造
  3. 03ツールの説明と実行メソッド
  4. 04任意の環境設定

活用シーン

  1. 01選択したトランスポートでのMCPサーバー構築
  2. 02ハンドラークラスによる独自ツールの追加

MCP 対応

MCPサーバー構築用のフレームワークで、STDIO、SSE、Streamable Httpを通じて独自のハンドラーツールをMCPクライアントに提供します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

インストール方法は未掲載です

このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。

リポジトリ

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

简体中文 English

easyMcp

たった2ステップで、すべてのModel Context Protocol(MCP)転送モード(STDIO、SSE、Streamable Http)に対応した、簡単に拡張できるMCPサーバーフレームワークをすばやく構築できます。

ぜひ「いいね」をお願いします!

ユーザーマニュアル

1. ステップ1[任意]必要な設定情報を定義する

src/config/.envで、プロジェクトに必要な設定情報を定義します。たとえば、データベースの設定が必要な場合は、次のようにします。

 # MySQL Database Configuration
MYSQL_HOST=192.168.3.229
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=a_llm
MYSQL_ROLE=admin
2. ステップ2 独自のツールを作成する

src/handlesディレクトリに独自のツールクラスを追加します。サンプルとしてexample.pyを参照してください。

  • BaseHandlerを継承する
  • ツール名となるnameプロパティを定義する
  • ツールの説明となるdescriptionプロパティを定義する
  • MCPクライアントにツールの機能を伝えるget_tool_descriptionメソッドを実装する
  • MCPクライアントがツールを使用する際に呼び出すrun_toolメソッドを実装し、ここにツールのロジックを記述する
  • __init__.pyで新しいツールをインポートする

example.py

from typing import Dict, Any, Sequence

from mcp import Tool
from mcp.types import TextContent
from .base import BaseHandler
from config import get_config


class Example(BaseHandler):
    name = "get_Example"
    description = (
        "this is Example xxxx"
    )

    def get_tool_description(self) -> Tool:
        return Tool(
            name=self.name,
            description=self.description,
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type": "string",
                        "description": "This is the text that must be entered for the example"
                    }
                },
                "required": ["text"]
            }
        )

    async def run_tool(self, arguments: Dict[str, Any]) -> Sequence[TextContent]:

            try:
                if "text" not in arguments:
                    raise ValueError("Missing text content")

                text = arguments["text"]

                # Reference configuration information
                config = get_config()

                ## todo something

                result = "xxxxxxx"

                # Join all results with commas
                return [TextContent(type="text", text=','.join(result))]

            except Exception as e:
                return [TextContent(type="text", text=f"error: {str(e)}")]

init.py

from .example import Example


__all__ = [
    "Example",
]
3. 起動する

現在、このフレームワークはすべてのModel Context Protocol(MCP)転送モード(STDIO、SSE、Streamable Http)に対応しています。

1. Streamable Httpモード
  • uvを使用してサービスを起動する

cursorやclineなどのMCPクライアントツールに、次の内容を追加します。

MCPのJSONの例:

{
  "mcpServers": {
    "easyMcp": {
      "name": "easyMcp",
      "type": "streamableHttp",
      "description": "",
      "isActive": true,
      "baseUrl": "http://localhost:3000/mcp/"
    }
  }
}

起動コマンド

# Install dependencies
uv sync

# Start
uv run src/server.py

2. SSEモード
  • uvを使用してサービスを起動する

cursorやclineなどのMCPクライアントツールに、次の内容を追加します。

MCPのJSONの例:

{
  "mcpServers": {
    "easyMcp": {
      "name": "easyMcp",
      "description": "",
      "isActive": true,
      "baseUrl": "http://localhost:9000/sse"
    }
  }
}

起動コマンド

# Install dependencies
uv sync

# Start
uv run src/server.py --sse
3. STDIOモード

cursorやclineなどのMCPクライアントツールに、次の内容を追加します。

MCPのJSONの例:

{
  "mcpServers": {
      "operateMysql": {
        "isActive": true,
        "name": "operateMysql",
        "command": "uv",
        "args": [
          "--directory",
          "G:\\python\\mysql_mcp\\src",  # Replace this with your project path
          "run",
          "server.py",
          "--stdio"
        ],
        "env": {
          "MYSQL_HOST": "192.168.xxx.xxx",
          "MYSQL_PORT": "3306",
          "MYSQL_USER": "root",
          "MYSQL_PASSWORD": "root",
          "MYSQL_DATABASE": "a_llm",
          "MYSQL_ROLE": "admin"
       }
    }
  }
}    

スクリーンショット

image

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。