Skip to main content
Glama

MCP Command and Search Server

by mjunaid46

Command Executor と Brave Search 向けの MCP ベースのクライアント サーバー アプリ

概要

このプロジェクトは、MCP(モデル・コンテキスト・プロトコル)を用いたクライアントサーバーアーキテクチャを実装し、ユーザープロンプトを処理し、**大規模言語モデル(LLM)**を用いてその意図を判定し、適切なサービスにルーティングして実行します。システムは2つの主要コンポーネントで構成されています。

  • **クライアント:**ユーザー入力を処理して LLM に送信し、LLM の決定に基づいて適切なサーバーに要求を転送します。
  • サーバー: LLMのJSONレスポンスで指定されたツールに基づいてリクエストを処理します。システムコマンドを実行するか、Brave Search APIを使用してWebデータを取得します。

LLMは、ユーザーリクエストがコマンド実行またはWeb検索のどちらを必要とするかを判断します。プロンプトが不明瞭な場合、LLMはツール名( command_executionまたはfetch_web_data )と必要な引数を指定する構造化されたJSONレスポンスを生成する前に、追加の質問をします。

フロー図

働く

  1. **ユーザー入力:**ユーザーは CLI にプロンプトを入力します。
  2. **クライアント処理:**クライアントはプロンプトを LLM に転送します。
  3. LLM決定:
    • 意図が不明瞭な場合、LLM は追加の質問をします。
    • ツール名と必要な引数を指定した JSON 応答を生成します。
  4. クライアントルーティング:
    • ツールがcommand_executionの場合:
      • 要求はコマンド サーバーに送信されます。
      • コマンド サーバーは、 Python のsubprocessモジュールを使用してコマンドを実行します。
      • 成功または失敗の応答が返されます。
    • ツールがfetch_web_data場合:
      • リクエストはFetch Web Data Serverに送信されます。
      • サーバーは関連する結果をBrave Search API に照会します。
      • 検索結果がクライアントに返されます。
  5. **クライアント応答:**クライアントは CLI 経由で最終応答をユーザーに返します。

前提条件

インストール

1. リポジトリをクローンする

git clone -https://github.com/mjunaid46/mcp cd mcp

2. 仮想環境を作成してアクティブ化する

# Create a virtual environment uv venv # Activate virtual environment # On Unix or MacOS: source .venv/bin/activate # On Windows: .venv\Scripts\activate

3. 依存関係をインストールする

pip install -r requirements.txt python -m ensurepip

4. LLMモデルを構成する

Ollamaモデルの使用
  1. Ollama インストール ガイドの指示に従って、Ollama CLI ツールをインストールします。
  2. 次に、Ollama を確認します。
    ollama list
  3. クライアント コマンドでモデルを指定します (llama3 または llama2)。
    uv run client/client.py server/command_server.py server/web_server.py ollama llama3
Groqモデルの使用
  1. Groq の API キーを保存するための.envファイルを作成します。
    touch .env
  2. Groq の API キーを.envファイルに追加します。
    GROQ_API_KEY=<your_groq_api_key_here>

5. Brave Search APIを設定する

Brave の API キーを.envファイルに追加します。

BRAVE_SEARCH_API_KEY=<your_brave_search_api_key_here>

走る

  • Ollamaモデルを使用するには
uv run client/client.py server/command_server.py server/web_server.py ollama llama3
  • Groqモデルを使用するには
uv run client/client.py server/command_server.py server/web_server.py groq

テスト

クライアントにクエリを渡します (例: touch test.txtcreate text file with testrm test.txt fileなど)

# Try the below prompts one by one to test. What is the capital of Pakistan. What is MCP? Create a file in my present working directory

🚀 Docker プロジェクトのセットアップガイド

📌 コード実行手順

1️⃣ Gitリポジトリをクローンする

git clone https://github.com/mjunaid46/mcp/ cd mcp

2️⃣ モデル選択の設定を編集する

config.ini ファイルを変更して、モデルのタイプと名前を指定します。

[settings] model_type = ollama # Change to "groq" if using Groq model_name = llama3 # Update model name if needed

3️⃣ Dockerコンテナを構築する

docker-compose build

4️⃣ モデルクライアントを実行する

docker-compose run pull-model-client
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

大規模言語モデル (LLM) を介してユーザーの意図を解釈することにより、Brave Search API を使用してシステム コマンドの実行と Web データの取得を容易にします。

  1. 概要
    1. フロー図
      1. 働く
        1. 前提条件
          1. インストール
            1. リポジトリをクローンする
            2. 仮想環境を作成してアクティブ化する
            3. 依存関係をインストールする
            4. LLMモデルを構成する
            5. Brave Search APIを設定する
          2. 走る
            1. テスト
              1. 🚀 Docker プロジェクトのセットアップガイド
                1. 📌 コード実行手順

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                Facilitates integration of Brave Search functionalities with AI assistants through the Model Context Protocol, enabling web and local searches using the Brave Search API.
                Last updated -
                2
                4
                Python
                MIT License
              • -
                security
                F
                license
                -
                quality
                Enables LLMs to perform sophisticated web searches through proxy servers using Tavily's API, supporting comprehensive web searches, direct question answering, and recent news article retrieval with AI-extracted content.
                Last updated -
                1
                Python
              • A
                security
                A
                license
                A
                quality
                Enables extracting data from websites using natural language prompts, allowing users to specify exactly what content they want in plain English and returning structured JSON data.
                Last updated -
                1
                1,379
                4
                TypeScript
                MIT License
                • Apple
                • Linux
              • -
                security
                A
                license
                -
                quality
                Provides AI-powered web search capabilities using Tavily's search API, enabling LLMs to perform sophisticated web searches, get direct answers to questions, and search recent news articles.
                Last updated -
                53
                Python
                MIT License
                • Linux
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/mjunaid46/mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server