mcpField
A
auto-mcp

auto-mcp

ローカル
auto-mcp.comAI・エージェント30180 週間前に更新

auto-mcp について

automcp は、既存のエージェントフレームワークのツール、エージェント、オーケストレーターを MCP サーバーに変換します。Cursor や Claude Desktop から標準的なインターフェースで既存のエージェントを呼び出したい開発者に向いています。コマンドラインで雛形を生成し、Naptha の MCPaaS にデプロイすることもできます。

主な機能

  1. 016 種類のエージェントフレームワークに対応
  2. 02automcp init による run_mcp.py の生成
  3. 03STDIO と SSE のトランスポート対応
  4. 04automcp serve コマンドによるサーバー起動
  5. 05Naptha MCPaaS へのデプロイ手順

活用シーン

  1. 01Cursor から既存の CrewAI チームを呼び出す
  2. 02LangGraph ワークフローを MCP サーバーとして公開する
  3. 03SSE エンドポイントでリモートクライアントからエージェントに接続する

MCP 対応

フレームワークのエージェントやツールを MCP サーバーとして包み、Cursor や Claude Desktop などの MCP クライアントが STDIO または SSE 経由で呼び出せるようにするツールです。

設定

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

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

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

リポジトリ

ツール

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

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

詳細

automcp

🚀 概要

automcp を使うと、既存のエージェントフレームワークのツール、エージェント、オーケストレーターを簡単に MCP サーバーに変換できます。変換したサーバーには、Cursor や Claude Desktop などのクライアントを通じて、標準化されたインターフェースでアクセスできます。

現在、以下のエージェントフレームワークのエージェント、ツール、オーケストレーターを MCP サーバーとしてデプロイできます。

  1. CrewAI
  2. LangGraph
  3. Llama Index
  4. OpenAI Agents SDK
  5. Pydantic AI
  6. mcp-agent

🔧 インストール

PyPI からインストールします。

# Basic installation
pip install naptha-automcp

# UV
uv add naptha-automcp

または、ソースからインストールします。

git clone https://github.com/napthaai/automcp.git
cd automcp
uv venv 
source .venv/bin/activate
pip install -e .

🧩 クイックスタート

プロジェクト用の新しい MCP サーバーを作成します。

エージェントの実装があるプロジェクトディレクトリに移動します。

cd your-project-directory

次のフラグ(crewai、langgraph、llamaindex、openai、pydantic、mcp_agent)のいずれかを指定して CLI から MCP サーバーのファイルを生成します。

automcp init -f crewai

生成された run_mcp.py ファイルを編集して、エージェントを設定します。

# Replace these imports with your actual agent classes
from your_module import YourCrewClass

# Define the input schema
class InputSchema(BaseModel):
    parameter1: str
    parameter2: str

# Set your agent details
name = "<YOUR_AGENT_NAME>"
description = "<YOUR_AGENT_DESCRIPTION>"

# For CrewAI projects
mcp_crewai = create_crewai_adapter(
    orchestrator_instance=YourCrewClass().crew(),
    name=name,
    description=description,
    input_schema=InputSchema,
)

依存関係をインストールし、MCP サーバーを実行します。

automcp serve -t sse

📁 生成されるファイル

automcp init -f <FRAMEWORK> を実行すると、次のファイルが生成されます。

run_mcp.py

MCP サーバーを設定して実行するメインファイルです。以下が含まれます。

  • サーバーの初期化コード
  • STDIO および SSE のトランスポートハンドラー
  • エージェント実装用のプレースホルダー
  • STDIO プロトコルを破損させる可能性のある警告を抑制するユーティリティ

このファイルを編集して、次の設定を行う必要があります。

  • エージェント/クルーのクラスをインポートする
  • 入力スキーマ(エージェントが受け付けるパラメーター)を定義する
  • アダプターにエージェントを設定する

🔍 例

例の実行

リポジトリには、サポート対象の各フレームワークの例が含まれています。

# Clone the repository
git clone https://github.com/NapthaAI/automcp.git
cd automcp

# Install automcp in development mode
pip install -e .

# Navigate to an example directory
cd examples/crewai/marketing_agents

# Generate the MCP server files (use the appropriate framework)
automcp init -f crewai

# Edit the generated run_mcp.py file to import and configure the example agent
# (See the specific example's README for details)

# Add a .env file with necessary environmental variables

# Install dependencies and run
automcp serve -t sse

各例では、通常のプロジェクトと同じワークフローに従います。

  1. automcp init -f <FRAMEWORK> を実行して、サーバーファイルを生成します
  2. run_mcp.py を編集して、例のエージェントをインポートし、設定します
  3. 必要な環境変数を含む .env ファイルを追加します
  4. 依存関係をインストールし、automcp serve -t sse を使ってサーバーを起動します
CrewAI の例

CrewAI の例で設定された一般的な run_mcp.py は次のようになります。

import warnings
from typing import Any
from automcp.adapters.crewai import create_crewai_adapter
from pydantic import BaseModel
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("MCP Server")

warnings.filterwarnings("ignore")

from crew import MarketingPostsCrew

class InputSchema(BaseModel):
    project_description: str
    customer_domain: str

name = "marketing_posts_crew"
description = "A crew that posts marketing posts to a social media platform"

# Create an adapter for crewai
mcp_crewai = create_crewai_adapter(
    orchestrator_instance=MarketingPostsCrew().crew(),
    name=name,
    description=description,
    input_schema=InputSchema,
)
mcp.add_tool(
    mcp_crewai,
    name=name,
    description=description
)

# Server entrypoints
def serve_sse():
    mcp.run(transport="sse")

def serve_stdio():
    # Redirect stderr to suppress warnings that bypass the filters
    import os
    import sys

    class NullWriter:
        def write(self, *args, **kwargs):
            pass
        def flush(self, *args, **kwargs):
            pass

    # Save the original stderr
    original_stderr = sys.stderr

    # Replace stderr with our null writer to prevent warnings from corrupting STDIO
    sys.stderr = NullWriter()

    # Set environment variable to ignore Python warnings
    os.environ["PYTHONWARNINGS"] = "ignore"

    try:
        mcp.run(transport="stdio")
    finally:
        # Restore stderr for normal operation
        sys.stderr = original_stderr

if __name__ == "__main__":
    import sys
    if len(sys.argv) > 1 and sys.argv[1] == "sse":
        serve_sse()
    else:
        serve_stdio()

🔄 MCP サーバーの実行

ファイルの設定が完了したら、次のいずれかの方法でサーバーを実行できます。

# Using the automcp CLI
automcp serve -t stdio    # STDIO transport
automcp serve -t sse      # SSE transport

# Or run the Python file directly
python run_mcp.py       # STDIO transport
python run_mcp.py sse   # SSE transport

# Or with uv run (if configured in pyproject.toml)
uv run serve_stdio
uv run serve_sse

トランスポートモードに関する注意:

  • STDIO:サーバーを手動で実行する必要はありません。クライアント(Cursor)が起動します
  • SSE:次の 2 つの手順が必要です。
    1. サーバーを別途起動します:python run_mcp.py sse または automcp serve -t sse
    2. 実行中のサーバーに接続するため、mcp.json の設定を追加します

uv run コマンドを使用する場合は、次の内容を pyproject.toml に追加します。

[tool.uv.scripts]
serve_stdio = "python run_mcp.py"
serve_sse = "python run_mcp.py sse"

☁️ Naptha の MCPaaS にデプロイする

Naptha は、新しく作成した MCP サーバーを、サービスとしての MCP サーバープラットフォームにデプロイできます。簡単に始められます。

セットアップ

Naptha の MCPaaS プラットフォームでは、リポジトリが uv でセットアップされている必要があります。 そのため、pyproject.toml にいくつかの設定が必要です。

まず、naptha-automcp が生成した run_mcp.py ファイルがリポジトリのルートにあることを確認します。

次に、pyproject.toml に以下の設定があることを確認します。

[build-system]
requires = [ "hatchling",]
build-backend = "hatchling.build"

[project.scripts]
serve_stdio = "run_mcp:serve_stdio"
serve_sse = "run_mcp:serve_sse"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
include = [ "run_mcp.py",]
exclude = [ "__pycache__", "*.pyc",]
sources = [ ".",]
packages = ["."]

エージェントがリポジトリ内のサブディレクトリまたはパッケージにある場合:

pyproject.toml
run_mcp.py
my_agent/
|---| __init__.py
    | agent.py

run_mcp.py で次のようにインポートされていることを確認します。

from my_agent.agent

以下のようにするとビルドが失敗するため、この方法は使わないでください。

from .my_agent.agent

すべての設定が完了したら、コードを github にコミットしてプッシュします(環境変数は含めないでください)。その後、次の方法で正しく設定できたかテストできます。

uvx --from https://github.com/your-username/your-repo serve_sse

この操作により MCP サーバーがポート 8000 で正常に起動すれば、準備完了です!

サーバーの起動
  1. labs.naptha.ai にアクセスします
  2. github アカウントでサインインします
  3. リポジトリ一覧から編集したリポジトリを選択します。github のリポジトリは自動検出されます
  4. OPENAI_API_KEY などの環境変数を追加します
  5. Launch をクリックします。
  6. SSE URL をコピーして、MCP クライアントに貼り付けます:

🔌 MCP クライアントでの使用

Cursor

Cursor IDE と統合するには、プロジェクトのルートに .cursor フォルダーを作成し、次の設定を含む mcp.json ファイルを追加します。

{
    "mcpServers": {
        "crew-name-stdio": {
            "type": "stdio",
            "command": "/absolute/path/to/your/.venv/bin/uv",
            "args": [
                "--directory",
                "/absolute/path/to/your/project_dir",
                "run",
                "serve_stdio"
            ],
            "env": {
                "OPENAI_API_KEY": "sk-",
                "SERPER_API_KEY": ""
            }
        },
        
        "crew-name-python": {
            "type": "stdio",
            "command": "/absolute/path/to/your/.venv/bin/python",
            "args": [
                "/absolute/path/to/your/project_dir/run_mcp.py"
            ],
            "env": {
                "OPENAI_API_KEY": "sk-",
                "SERPER_API_KEY": ""
            }
        },
        
        "crew-name-automcp": {
            "type": "stdio",
            "command": "/absolute/path/to/your/.venv/bin/automcp",
            "args": [
                "serve",
                "-t",
                "stdio"
            ],
            "cwd": "/absolute/path/to/your/project_dir",
            "env": {
                "OPENAI_API_KEY": "sk-",
                "SERPER_API_KEY": ""
            }
        },
        
        "crew-name-sse": {
            "type": "sse",
            "url": "http://localhost:8000/sse"
        }
    }
}

注記: すべてのプレースホルダーのパスを、実際のファイルとディレクトリへの絶対パスに置き換えてください。

GitHub から直接実行

プロジェクトを GitHub にプッシュして、次を使用します。

{
   "mcpServers": {
       "My Agent": {
           "command": "uvx",
           "args": [
               "--from",
               "git+https://github.com/your-username/your-repo",
               "serve_stdio"
           ],
           "env": {
               "OPENAI_API_KEY": "your-key-here"
           }
       }
   }
}

🛠️ 新しいアダプターの作成

新しいエージェントフレームワークのサポートを追加する方法は次のとおりです。

  1. automcp/adapters/ に新しいアダプターファイルを作成します(または、既存のフレームワークファイルに追加します)。
# automcp/adapters/framework.py
import json
import contextlib
import io
from typing import Any, Callable, Type
from pydantic import BaseModel

def create_framework_adapter(
    agent_instance: Any,
    name: str,
    description: str,
    input_schema: Type[BaseModel],
) -> Callable:
    """Doc string for your function"""
    
    # Get the field names and types from the input schema
    schema_fields = input_schema.model_fields

    # Create the parameter string for the function signature
    params_str = ", ".join(
        f"{field_name}: {field_info.annotation.__name__}"
        for field_name, field_info in schema_fields.items()
    )

    # Create the function body that constructs the input schema
    # Note: You may need to adjust the method calls (kickoff, model_dump_json)
    # to match your framework's specific API
    body_str = f"""def run_agent({params_str}):
        inputs = input_schema({', '.join(f'{name}={name}' for name in schema_fields)})
        with contextlib.redirect_stdout(io.StringIO()):
            result = agent_instance.framework_specific_run(inputs=inputs.model_dump())
        return result.framework_specific_result()
    """

    # Create a namespace for the function
    namespace = {
        "input_schema": input_schema,
        "agent_instance": agent_instance,
        "json": json,
        "contextlib": contextlib,
        "io": io,
    }

    # Execute the function definition in the namespace
    exec(body_str, namespace)

    # Get the created function
    run_agent = namespace["run_agent"]

    # Add proper function metadata
    run_agent.__name__ = name
    run_agent.__doc__ = description

    return run_agent
  1. examples/your_framework/ に例を作成します。

📝 注記

  • STDIO トランスポートを使用する場合、エージェントコードの print 文には注意してください。プロトコルが破損する可能性があります。
  • デバッグには MCP Inspector を使用できます:npx @modelcontextprotocol/inspector
  • STDIO モードでは、クライアント(Cursor など)がサーバーを起動することにご留意ください。
  • SSE モードでは、サーバーを手動で起動してから、接続するようクライアントを設定する必要があります。

コメント

MCP は初めてですか?

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

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