easyMcp について
easyMcpは、STDIO、SSE、Streamable Httpに対応した拡張可能なMCPサーバーを構築するフレームワークです。`BaseHandler`を継承するハンドラークラスで独自ツールを追加します。
主な機能
- 01STDIO、SSE、Streamable Http対応
- 02ハンドラー形式の拡張可能なツール構造
- 03ツールの説明と実行メソッド
- 04任意の環境設定
活用シーン
- 01選択したトランスポートでのMCPサーバー構築
- 02ハンドラークラスによる独自ツールの追加
MCP 対応
MCPサーバー構築用のフレームワークで、STDIO、SSE、Streamable Httpを通じて独自のハンドラーツールをMCPクライアントに提供します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
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"
}
}
}
}
スクリーンショット
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。