MyAIServ MCP Server

by eagurin
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables vector search capabilities for AI queries, allowing efficient similarity searches and semantic retrieval of data stored in Elasticsearch indices.

  • Powers the REST, GraphQL, and WebSocket API interfaces, enabling different methods of interacting with the AI models through standardized endpoints.

  • Visualizes AI system metrics and performance data, providing dashboards for monitoring model behavior and operational health.

MCP サーバー - モデルコンテキストプロトコル API

MCP サーバーは、LLM モデルとアプリケーション間の相互作用のための標準化されたインターフェイスを提供するモデル コンテキスト プロトコル (MCP) の FastAPI ベースの実装です。

特徴

  • 🚀 FastAPIと非同期操作に基づく高性能API
  • 🔄 リソース、機器、プロンプト、サンプリングによる完全な MCP サポート
  • 📊 PrometheusとGrafanaによるモニタリングとメトリクス
  • 🧩 シンプルなインターフェースで新しいツールを追加できる拡張性
  • 📝 データを柔軟に操作できるGraphQL API
  • 💬 リアルタイムインタラクションのためのWebSocketサポート
  • 🔍 Elasticsearchとの統合によるセマンティック検索
  • 🗃️ Redis によるキャッシュでパフォーマンスを向上
  • 📦 信頼性の高いパッケージ管理のために、Poetry で依存関係を管理します

はじめる

インストール

  1. リポジトリのクローン:
    git clone https://github.com/yourusername/myaiserv.git cd myaiserv
  2. Poetry をインストールします (まだインストールされていない場合):
    curl -sSL https://install.python-poetry.org | python3 -
  3. Poetry 経由で依存関係をインストールします。
    poetry install

サーバーの起動

poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

または just ユーティリティ経由で:

just run

起動後、APIは次の場所で利用できます: http://localhost:8000

APIドキュメント

プロジェクト構造

myaiserv/ ├── app/ │ ├── core/ # Базовые компоненты MCP │ │ ├── base_mcp.py # Абстрактные классы MCP │ │ └── base_sampling.py # Базовые классы для сэмплирования │ ├── models/ # Pydantic модели │ │ ├── mcp.py # Модели данных MCP │ │ └── graphql.py # GraphQL схема │ ├── services/ # Бизнес-логика │ │ └── mcp_service.py # Сервис MCP │ ├── storage/ # Хранилище данных │ ├── tools/ # Инструменты MCP │ │ ├── example_tool.py # Примеры инструментов │ │ └── text_processor.py # Инструмент обработки текста │ ├── utils/ # Утилиты │ └── main.py # Точка входа FastAPI ├── app/tests/ # Тесты ├── docs/ # Документация │ └── MCP_API.md # Описание API ├── pyproject.toml # Конфигурация Poetry и инструментов └── .justfile # Задачи для утилиты just

利用可能なツール

ファイルシステムツール

ファイルの読み取り、書き込み、削除、一覧表示をサポートするファイル システム ツール。

curl -X POST "http://localhost:8000/tools/file_operations" \ -H "Content-Type: application/json" \ -d '{"operation": "list", "path": "."}'

天気ツール

座標によって天気データを取得するためのツール。

curl -X POST "http://localhost:8000/tools/weather" \ -H "Content-Type: application/json" \ -d '{"latitude": 37.7749, "longitude": -122.4194}'

テキスト分析ツール

感情の検出や要約を含むテキスト分析ツール。

curl -X POST "http://localhost:8000/tools/text_analysis" \ -H "Content-Type: application/json" \ -d '{"text": "Example text for analysis", "analysis_type": "sentiment"}'

テキストプロセッサツール

書式設定、統計計算、エンティティ抽出などのテキスト処理ツール。

curl -X POST "http://localhost:8000/tools/text_processor" \ -H "Content-Type: application/json" \ -d '{"operation": "statistics", "text": "Example text", "stat_options": ["chars", "words"]}'

画像処理ツール

サイズ変更、切り取り、フィルターの適用をサポートする画像処理ツール。

curl -X POST "http://localhost:8000/tools/image_processing" \ -H "Content-Type: application/json" \ -d '{"operation": "resize", "image_data": "base64...", "params": {"width": 800, "height": 600}}'

WebSocket API

WebSocket API に接続するには:

const socket = new WebSocket("ws://localhost:8000/ws"); socket.onopen = () => { socket.send(JSON.stringify({ type: "initialize", id: "my-request-id" })); }; socket.onmessage = (event) => { const data = JSON.parse(event.data); console.log("Received:", data); };

GraphQL API

GraphQL 経由のクエリの例:

# Получение списка всех инструментов query { getTools { name description } } # Выполнение инструмента mutation { executeTool(input: { name: "text_processor", parameters: { operation: "statistics", text: "Example text for analysis" } }) { content { type text } is_error } }

テストの実行

テストを実行するには、Poetry を使用します。

poetry run pytest

または just ユーティリティ経由で:

just test

ドッカー

Docker Compose によるビルドと実行

docker compose up -d

個々のサービスを起動するには:

docker compose up -d web redis elasticsearch

LLMとの統合

MCP サーバーは、さまざまなベンダーの LLM モデルとの統合のための標準化されたインターフェースを提供します。

import httpx async def query_mcp_with_llm(prompt: str): async with httpx.AsyncClient() as client: # Запрос к MCP для получения контекста и инструментов tools_response = await client.get("http://localhost:8000/tools") tools = tools_response.json()["tools"] # Отправка запроса к LLM с включением MCP контекста llm_response = await client.post( "https://api.example-llm.com/v1/chat", json={ "messages": [ {"role": "system", "content": "You have access to the following tools:"}, {"role": "user", "content": prompt} ], "tools": tools, "tool_choice": "auto" } ) return llm_response.json()

指標と監視

MCP サーバーは/metricsエンドポイントを介して Prometheus 形式のメトリックを提供します。指標には次のものが含まれます:

  • 各ツールへのリクエスト数
  • クエリ実行時間
  • エラーと例外

発達

コードをフォーマットしてリンターでチェックするには:

just fmt just lint

ライセンス

MITライセンス

-
security - not tested
A
license - permissive license
-
quality - not tested

大規模言語モデルとのシームレスな統合を実現するモデル コンテキスト プロトコル (MCP) をサポートする高性能 FastAPI サーバー。REST、GraphQL、WebSocket API に加え、リアルタイム監視およびベクトル検索機能を備えています。

  1. Особенности
    1. Начало работы
      1. Установка
      2. Запуск сервера
      3. Документация API
    2. Структура проекта
      1. Доступные инструменты
        1. File System Tool
        2. Weather Tool
        3. Text Analysis Tool
        4. Text Processor Tool
        5. Image Processing Tool
      2. WebSocket API
        1. GraphQL API
          1. Запуск тестов
            1. Docker
              1. Сборка и запуск через Docker Compose
            2. Интеграция с LLM
              1. Метрики и мониторинг
                1. Разработка
                  1. Лицензия
                    ID: xw8u4yj92j